| 218 | } |
| 219 | |
| 220 | void 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 | |
| 253 | void PLYWriter::write_face_elements(Mesh& mesh, p_ply& ply) { |
| 254 | const size_t num_faces = mesh.get_num_faces(); |
nothing calls this directly
no test coverage detected