| 216 | } |
| 217 | |
| 218 | VectorF AttributeUtils::convert_to_voxel_attribute(Mesh& mesh, |
| 219 | const VectorF& attribute) { |
| 220 | const size_t dim = mesh.get_dim(); |
| 221 | const size_t num_vertices = mesh.get_num_vertices(); |
| 222 | const size_t num_faces = mesh.get_num_faces(); |
| 223 | const size_t num_voxels = mesh.get_num_voxels(); |
| 224 | |
| 225 | size_t attr_size = attribute.size(); |
| 226 | |
| 227 | if (attr_size == num_vertices || attr_size == dim*num_vertices) { |
| 228 | return convert_vertex_attribute_to_voxel_attribute(mesh, attribute); |
| 229 | } else if (attr_size == num_faces || attr_size == dim*num_faces) { |
| 230 | throw NotImplementedError( |
| 231 | "Converting face attribute to voxel attribute is not supported yet."); |
| 232 | } else if (attr_size == num_voxels || attr_size == dim*num_voxels) { |
| 233 | return attribute; |
| 234 | } else { |
| 235 | throw RuntimeError("Unknow attribute type."); |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | VectorF AttributeUtils::convert_to_voxel_attribute_from_name(Mesh& mesh, |
| 240 | const std::string& attribute_name) { |
no test coverage detected