| 192 | } |
| 193 | |
| 194 | void PLYWriter::add_voxel_elements_header(Mesh& mesh, p_ply& ply) { |
| 195 | const size_t num_voxels = mesh.get_num_voxels(); |
| 196 | if (num_voxels == 0) return; |
| 197 | assert_success(ply_add_element(ply, "voxel", num_voxels), "Add voxel failed"); |
| 198 | assert_success(ply_add_list_property(ply, "vertex_indices", PLY_UCHAR, |
| 199 | PLY_INT), "Add voxel vertex indices failed"); |
| 200 | |
| 201 | for (NameArray::const_iterator itr = m_voxel_attr_names.begin(); |
| 202 | itr != m_voxel_attr_names.end(); itr++) { |
| 203 | const std::string name = strip_prefix(*itr, "voxel_"); |
| 204 | const VectorF& attr = mesh.get_attribute(*itr); |
| 205 | const size_t per_voxel_size = attr.size() / num_voxels; |
| 206 | e_ply_type ply_type = m_scalar; |
| 207 | if (name == "red" || name == "green" || name == "blue") { |
| 208 | ply_type = PLY_UCHAR; |
| 209 | } |
| 210 | if (per_voxel_size == 1) { |
| 211 | assert_success(ply_add_scalar_property(ply, name.c_str(), ply_type), |
| 212 | "Add per voxel scalar attribute failed"); |
| 213 | } else { |
| 214 | assert_success(ply_add_list_property(ply, name.c_str(), PLY_UCHAR, |
| 215 | ply_type), "Add per voxel vector attribute failed"); |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | void PLYWriter::write_vertex_elements(Mesh& mesh, p_ply& ply) { |
| 221 | const size_t dim = mesh.get_dim(); |
nothing calls this directly
no test coverage detected