| 81 | return wires; |
| 82 | |
| 83 | def add_frame(wires): |
| 84 | if wires.num_vertices == 0: |
| 85 | return wires; |
| 86 | vertices = wires.vertices; |
| 87 | edges = wires.edges; |
| 88 | |
| 89 | bbox_min = np.amin(vertices, axis=0); |
| 90 | bbox_max = np.amax(vertices, axis=0); |
| 91 | bbox_center = 0.5 * (bbox_min + bbox_max); |
| 92 | diag_len = norm(bbox_max - bbox_min); |
| 93 | offset = np.ones(2) * diag_len / 20; |
| 94 | bbox_min -= offset; |
| 95 | bbox_max += offset; |
| 96 | |
| 97 | frame_vertices = np.array([ |
| 98 | [bbox_min[0], bbox_min[1]], |
| 99 | [bbox_max[0], bbox_min[1]], |
| 100 | [bbox_max[0], bbox_max[1]], |
| 101 | [bbox_min[0], bbox_max[1]], |
| 102 | ]); |
| 103 | frame_edges = np.array([ |
| 104 | [0, 1], |
| 105 | [1, 2], |
| 106 | [2, 3], |
| 107 | [3, 0], |
| 108 | ]) + wires.num_vertices; |
| 109 | |
| 110 | vertices = np.vstack([vertices, frame_vertices]); |
| 111 | edges = np.vstack([edges, frame_edges]); |
| 112 | wires.load(vertices, edges); |
| 113 | return wires; |
| 114 | |
| 115 | def resolve_self_intersection(wires, logger): |
| 116 | if wires.num_vertices == 0: |