MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / trim

Method trim

python/pymesh/wires/WireNetwork.py:160–174  ·  view source on GitHub ↗

Remove all hanging edges. e.g. edge with at least one vertex of valance <= 1

(self)

Source from the content-addressed store, hash-verified

158 self.raw_wires.center_at_origin()
159
160 def trim(self):
161 """ Remove all hanging edges.
162 e.g. edge with at least one vertex of valance <= 1
163 """
164 while np.any(self.vertex_valance <= 1):
165 edge_to_keep = np.all(self.vertex_valance[self.edges] > 1,
166 axis=1).tolist()
167 self.raw_wires.filter_edges(edge_to_keep)
168 vertex_to_keep = [len(self.get_vertex_neighbors(i)) > 0 for i in
169 range(self.num_vertices)]
170 self.raw_wires.filter_vertices(vertex_to_keep)
171
172 self.__initialize_wires()
173 if len(self.vertices) == 0:
174 raise RuntimeError("Zero vertices left after trimming.")
175
176 def filter_vertices(self, to_keep):
177 """ Remove all vertices other than the ones marked with to_keep.

Callers 4

test_trimMethod · 0.80
tile_with_guide_boxFunction · 0.80
tile_with_guide_meshFunction · 0.80
tile_with_mixed_patternsFunction · 0.80

Calls 5

get_vertex_neighborsMethod · 0.95
__initialize_wiresMethod · 0.95
RuntimeErrorClass · 0.85
filter_edgesMethod · 0.45
filter_verticesMethod · 0.45

Tested by 1

test_trimMethod · 0.64