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

Function collapse_short_edges_raw

python/pymesh/meshutils/collapse_short_edges.py:111–149  ·  view source on GitHub ↗

Convenient function for collapsing short edges. Args: vertices (``numpy.ndarray``): Vertex array. One vertex per row. faces (``numpy.ndarray``): Face array. One face per row. abs_threshold (``float``): (optional) All edge with length below or equal to this t

(vertices, faces, abs_threshold=0.0,
        rel_threshold=None, preserve_feature=False)

Source from the content-addressed store, hash-verified

109 self.faces = remover.get_faces()
110
111def collapse_short_edges_raw(vertices, faces, abs_threshold=0.0,
112 rel_threshold=None, preserve_feature=False):
113 """ Convenient function for collapsing short edges.
114
115 Args:
116 vertices (``numpy.ndarray``): Vertex array. One vertex per row.
117 faces (``numpy.ndarray``): Face array. One face per row.
118 abs_threshold (``float``): (optional) All edge with length below or
119 equal to this threshold will be collapsed. This value is ignored
120 if ``rel_thresold`` is not ``None``.
121 rel_threashold (``float``): (optional) Relative edge length threshold
122 based on average edge length. e.g. ``rel_threshold=0.1`` means all
123 edges with length less than ``0.1 * ave_edge_length`` will be collapsed.
124 preserve_feature (``bool``): True if shape features should be preserved.
125 Default is false.
126
127 Returns:
128 3 values are returned.
129
130 * ``output_vertices``: Output vertex array. One vertex per row.
131 * ``output_faces``: Output face array. One face per row.
132 * ``information``: A ``dict`` of additional informations.
133
134 The following fields are defined in ``information``:
135
136 * ``num_edge_collapsed``: Number of edge collapsed.
137 * ``source_face_index``: An array tracks the source of each output face.
138 That is face ``i`` of the ``output_faces`` comes from face
139 ``source_face_index[i]`` of the input faces.
140 """
141 collapser = _EdgeCollapser.create_raw(vertices, faces)
142 if preserve_feature:
143 collapser.keep_features()
144 num_collapsed = collapser.collapse(abs_threshold, rel_threshold)
145 info = {
146 "num_edge_collapsed": num_collapsed,
147 "source_face_index": collapser.face_index_map
148 }
149 return collapser.vertices, collapser.faces, info
150
151def collapse_short_edges(mesh,
152 abs_threshold=0.0, rel_threshold=None, preserve_feature=False):

Callers 6

test_simple_3DMethod · 0.90
test_collapse_all_3DMethod · 0.90
test_slim_trianglesMethod · 0.90
test_simple_2DMethod · 0.90
collapse_short_edgesFunction · 0.85

Calls 3

keep_featuresMethod · 0.80
create_rawMethod · 0.45
collapseMethod · 0.45

Tested by 5

test_simple_3DMethod · 0.72
test_collapse_all_3DMethod · 0.72
test_slim_trianglesMethod · 0.72
test_simple_2DMethod · 0.72