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

Method write_face_elements

src/IO/PLYWriter.cpp:253–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253void PLYWriter::write_face_elements(Mesh& mesh, p_ply& ply) {
254 const size_t num_faces = mesh.get_num_faces();
255 const size_t num_vertex_per_face = mesh.get_vertex_per_face();
256 const VectorI& faces = mesh.get_faces();
257
258 std::vector<const VectorF*> attributes;
259 std::vector<size_t> per_face_sizes;
260 for (NameArray::const_iterator itr = m_face_attr_names.begin();
261 itr != m_face_attr_names.end(); itr++) {
262 const std::string& name = *itr;
263 const VectorF& attr = mesh.get_attribute(name);
264 attributes.push_back(&attr);
265 per_face_sizes.push_back(attr.size() / num_faces);
266 }
267
268 const size_t num_attributes = attributes.size();
269 for (size_t i=0; i<num_faces; i++) {
270 ply_write(ply, num_vertex_per_face);
271 for (size_t j=0; j<num_vertex_per_face; j++) {
272 ply_write(ply, faces[i*num_vertex_per_face + j]);
273 }
274 for (size_t j=0; j<num_attributes; j++) {
275 const size_t per_face_size = per_face_sizes[j];
276 if (per_face_size != 1) {
277 ply_write(ply, per_face_size);
278 }
279 for (size_t k=0; k<per_face_size; k++) {
280 ply_write(ply, attributes[j]->coeff(i*per_face_size + k));
281 }
282 }
283 }
284}
285
286void PLYWriter::write_voxel_elements(Mesh& mesh, p_ply& ply) {
287 const size_t num_voxels = mesh.get_num_voxels();

Callers

nothing calls this directly

Calls 8

ply_writeFunction · 0.85
get_num_facesMethod · 0.45
get_vertex_per_faceMethod · 0.45
get_facesMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
get_attributeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected