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

Method remove_duplicated_vertices

tools/Wires/Tiler/TilerEngine.cpp:145–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145void TilerEngine::remove_duplicated_vertices(WireNetwork& wire_network, Float tol) {
146 const size_t num_input_vertices = wire_network.get_num_vertices();
147
148 DuplicatedVertexRemoval remover(wire_network.get_vertices(), wire_network.get_edges());
149 remover.run(tol);
150 MatrixFr vertices = remover.get_vertices();
151 MatrixIr edges = remover.get_faces();
152 VectorI index_map = remover.get_index_map();
153 assert(num_input_vertices == index_map.size());
154
155 wire_network.set_vertices(vertices);
156 wire_network.set_edges(edges);
157
158 const size_t num_output_vertices = wire_network.get_num_vertices();
159 std::vector<std::string> attr_names = wire_network.get_attribute_names();
160 for (auto itr : attr_names) {
161 const std::string& name = itr;
162 if (wire_network.is_vertex_attribute(name)) {
163 MatrixFr values = wire_network.get_attribute(name);
164 MatrixFr updated_values = MatrixFr::Zero(num_output_vertices, values.cols());
165 VectorF count = VectorF::Zero(num_output_vertices);
166 for (size_t i=0; i<num_input_vertices; i++) {
167 size_t j = index_map[i];
168 updated_values.row(j) += values.row(i);
169 count[j] += 1;
170 }
171
172 for (size_t i=0; i<num_output_vertices; i++) {
173 assert(count[i] > 0);
174 updated_values.row(i) /= count[i];
175 }
176 wire_network.set_attribute(name, updated_values);
177 }
178 }
179}
180
181void TilerEngine::remove_duplicated_edges(WireNetwork& wire_network) {
182 const MatrixIr& edges = wire_network.get_edges();

Callers

nothing calls this directly

Calls 13

set_edgesMethod · 0.80
get_num_verticesMethod · 0.45
get_verticesMethod · 0.45
get_edgesMethod · 0.45
runMethod · 0.45
get_facesMethod · 0.45
get_index_mapMethod · 0.45
sizeMethod · 0.45
set_verticesMethod · 0.45
get_attribute_namesMethod · 0.45
is_vertex_attributeMethod · 0.45
get_attributeMethod · 0.45

Tested by

no test coverage detected