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

Method add_voxel_elements_header

src/IO/PLYWriter.cpp:194–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194void PLYWriter::add_voxel_elements_header(Mesh& mesh, p_ply& ply) {
195 const size_t num_voxels = mesh.get_num_voxels();
196 if (num_voxels == 0) return;
197 assert_success(ply_add_element(ply, "voxel", num_voxels), "Add voxel failed");
198 assert_success(ply_add_list_property(ply, "vertex_indices", PLY_UCHAR,
199 PLY_INT), "Add voxel vertex indices failed");
200
201 for (NameArray::const_iterator itr = m_voxel_attr_names.begin();
202 itr != m_voxel_attr_names.end(); itr++) {
203 const std::string name = strip_prefix(*itr, "voxel_");
204 const VectorF& attr = mesh.get_attribute(*itr);
205 const size_t per_voxel_size = attr.size() / num_voxels;
206 e_ply_type ply_type = m_scalar;
207 if (name == "red" || name == "green" || name == "blue") {
208 ply_type = PLY_UCHAR;
209 }
210 if (per_voxel_size == 1) {
211 assert_success(ply_add_scalar_property(ply, name.c_str(), ply_type),
212 "Add per voxel scalar attribute failed");
213 } else {
214 assert_success(ply_add_list_property(ply, name.c_str(), PLY_UCHAR,
215 ply_type), "Add per voxel vector attribute failed");
216 }
217 }
218}
219
220void PLYWriter::write_vertex_elements(Mesh& mesh, p_ply& ply) {
221 const size_t dim = mesh.get_dim();

Callers

nothing calls this directly

Calls 10

ply_add_elementFunction · 0.85
ply_add_list_propertyFunction · 0.85
strip_prefixFunction · 0.85
ply_add_scalar_propertyFunction · 0.85
assert_successFunction · 0.70
get_num_voxelsMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
get_attributeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected