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

Method filter_vertices

tools/Wires/WireNetwork/WireNetwork.cpp:176–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176void WireNetwork::filter_vertices(const std::vector<bool>& to_keep) {
177 const size_t num_vertices = m_vertices.rows();
178 MatrixFr vertices;
179 filter(m_vertices, to_keep, vertices);
180 m_vertices = vertices;
181 const auto& attr_names = m_attributes.get_attribute_names();
182 for (const auto& name : attr_names) {
183 if (is_vertex_attribute(name)) {
184 const MatrixFr& val = m_attributes.get_attribute(name);
185 MatrixFr filtered_val;
186 filter(val, to_keep, filtered_val);
187 m_attributes.set_attribute(*this, name, filtered_val);
188 }
189 }
190
191 size_t count = 0;
192 VectorI index_map = VectorI::Ones(num_vertices) * -1;
193 for (size_t i=0; i<num_vertices; i++) {
194 if (to_keep[i]) {
195 index_map[i] = count;
196 count++;
197 }
198 }
199
200 const size_t num_edges = m_edges.rows();
201 std::vector<bool> edge_to_keep(num_edges, false);
202 for (size_t i=0; i<num_edges; i++) {
203 m_edges(i, 0) = index_map[m_edges(i, 0)];
204 m_edges(i, 1) = index_map[m_edges(i, 1)];
205 if ((m_edges.row(i).array() >= 0).all()) {
206 edge_to_keep[i] = true;
207 }
208 }
209 filter_edges(edge_to_keep);
210 assert((m_edges.array() >= 0).all());
211
212 m_connectivity.reset();
213 update_bbox();
214}
215
216void WireNetwork::filter_edges(const std::vector<bool>& to_keep) {
217 MatrixIr edges;

Callers 1

trim_irrelavent_edgesMethod · 0.45

Calls 5

filterFunction · 0.70
get_attribute_namesMethod · 0.45
get_attributeMethod · 0.45
set_attributeMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected