| 284 | } |
| 285 | |
| 286 | void PLYWriter::write_voxel_elements(Mesh& mesh, p_ply& ply) { |
| 287 | const size_t num_voxels = mesh.get_num_voxels(); |
| 288 | if (num_voxels == 0) return; |
| 289 | const size_t num_vertex_per_voxel = mesh.get_vertex_per_voxel(); |
| 290 | const VectorI& voxels = mesh.get_voxels(); |
| 291 | |
| 292 | std::vector<const VectorF*> attributes; |
| 293 | std::vector<size_t> per_voxel_sizes; |
| 294 | for (NameArray::const_iterator itr = m_voxel_attr_names.begin(); |
| 295 | itr != m_voxel_attr_names.end(); itr++) { |
| 296 | const std::string& name = *itr; |
| 297 | const VectorF& attr = mesh.get_attribute(name); |
| 298 | attributes.push_back(&attr); |
| 299 | assert(attr.size() % num_voxels == 0); |
| 300 | per_voxel_sizes.push_back(attr.size() / num_voxels); |
| 301 | } |
| 302 | |
| 303 | const size_t num_attributes = attributes.size(); |
| 304 | for (size_t i=0; i<num_voxels; i++) { |
| 305 | ply_write(ply, num_vertex_per_voxel); |
| 306 | for (size_t j=0; j<num_vertex_per_voxel; j++) { |
| 307 | ply_write(ply, voxels[i*num_vertex_per_voxel + j]); |
| 308 | } |
| 309 | for (size_t j=0; j<num_attributes; j++) { |
| 310 | const size_t per_voxel_size = per_voxel_sizes[j]; |
| 311 | if (per_voxel_size != 1) { |
| 312 | ply_write(ply, per_voxel_size); |
| 313 | } |
| 314 | for (size_t k=0; k<per_voxel_size; k++) { |
| 315 | ply_write(ply, attributes[j]->coeff(i*per_voxel_size + k)); |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 |
nothing calls this directly
no test coverage detected