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

Method add_vertex_elements_header

src/IO/PLYWriter.cpp:133–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133void PLYWriter::add_vertex_elements_header(Mesh& mesh, p_ply& ply) {
134 const size_t dim = mesh.get_dim();
135 const size_t num_vertices = mesh.get_num_vertices();
136 assert_success(ply_add_element(ply, "vertex", num_vertices),
137 "Add element failed");
138 assert_success(ply_add_scalar_property(ply, "x", m_scalar),
139 "Add X coordinate failed");
140 assert_success(ply_add_scalar_property(ply, "y", m_scalar),
141 "Add Y coordinate failed");
142 if (dim == 3) {
143 assert_success(ply_add_scalar_property(ply, "z", m_scalar),
144 "Add Z coordinate failed");
145 }
146
147 for (NameArray::const_iterator itr = m_vertex_attr_names.begin();
148 itr != m_vertex_attr_names.end(); itr++) {
149 const std::string name = strip_prefix(*itr, "vertex_");
150 const VectorF attr = mesh.get_attribute(*itr);
151 const size_t per_vertex_size = attr.size() / num_vertices;
152 e_ply_type ply_type = m_scalar;
153 if (name == "red" || name == "green" || name == "blue") {
154 ply_type = PLY_UCHAR;
155 }
156 if (per_vertex_size == 1) {
157 assert_success(ply_add_scalar_property(ply, name.c_str(), ply_type),
158 "Add scalar property failed");
159 } else {
160 assert_success(ply_add_list_property(ply, name.c_str(), PLY_UCHAR,
161 ply_type), "Add list proerty failed");
162 }
163 }
164}
165
166void PLYWriter::add_face_elements_header(Mesh& mesh, p_ply& ply) {
167 const size_t num_faces = mesh.get_num_faces();

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected