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

Method compute_and_drop_zero_dim

src/MeshFactory.cpp:170–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170void MeshFactory::compute_and_drop_zero_dim() {
171 const size_t num_vertices = m_mesh->get_num_vertices();
172 if (num_vertices == 0) return;
173 int zero_dim = m_mesh->get_geometry()->project_out_zero_dim();
174 if (zero_dim < 0) return;
175 const char axis[3] = {'X', 'Y', 'Z'};
176 std::cerr << "Dropping " << axis[zero_dim]
177 << " coordinate because flat geometry." << std::endl;
178 std::vector<std::string> attr_names = m_mesh->get_attribute_names();
179 for (auto itr = attr_names.begin(); itr != attr_names.end(); itr++) {
180 VectorF& attr = m_mesh->get_attribute(*itr);
181 if (attr.size() == num_vertices * 3) {
182 VectorF reduced_attr(num_vertices * 2);
183 for (size_t i=0; i<num_vertices; i++) {
184 reduced_attr[i*2 ] = (zero_dim == 0) ?
185 attr[i*3+1] : attr[i*3];
186 reduced_attr[i*2+1] = (zero_dim == 2) ?
187 attr[i*3+1] : attr[i*3+2];
188 }
189 m_mesh->set_attribute(*itr, reduced_attr);
190 }
191 }
192}
193

Callers

nothing calls this directly

Calls 9

project_out_zero_dimMethod · 0.80
get_geometryMethod · 0.80
get_num_verticesMethod · 0.45
get_attribute_namesMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
get_attributeMethod · 0.45
sizeMethod · 0.45
set_attributeMethod · 0.45

Tested by

no test coverage detected