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

Method write_vertex_elements

src/IO/PLYWriter.cpp:220–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220void PLYWriter::write_vertex_elements(Mesh& mesh, p_ply& ply) {
221 const size_t dim = mesh.get_dim();
222 const size_t num_vertices = mesh.get_num_vertices();
223 const VectorF& vertices = mesh.get_vertices();
224
225 std::vector<const VectorF*> attributes;
226 std::vector<size_t> per_vertex_sizes;
227 for (NameArray::const_iterator itr = m_vertex_attr_names.begin();
228 itr != m_vertex_attr_names.end(); itr++) {
229 const std::string& name = *itr;
230 const VectorF& attr = mesh.get_attribute(name);
231 attributes.push_back(&attr);
232 per_vertex_sizes.push_back(attr.size() / num_vertices);
233 }
234
235 const size_t num_attributes = attributes.size();
236
237 for (size_t i=0; i<num_vertices; i++) {
238 for (size_t j=0; j<dim; j++) {
239 ply_write(ply, vertices[i*dim + j]);
240 }
241 for (size_t j=0; j<num_attributes; j++) {
242 const size_t per_vertex_size = per_vertex_sizes[j];
243 if (per_vertex_size != 1) {
244 ply_write(ply, per_vertex_size);
245 }
246 for (size_t k=0; k<per_vertex_size; k++) {
247 ply_write(ply, attributes[j]->coeff(i*per_vertex_size + k));
248 }
249 }
250 }
251}
252
253void PLYWriter::write_face_elements(Mesh& mesh, p_ply& ply) {
254 const size_t num_faces = mesh.get_num_faces();

Callers

nothing calls this directly

Calls 8

ply_writeFunction · 0.85
get_dimMethod · 0.45
get_num_verticesMethod · 0.45
get_verticesMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
get_attributeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected