| 9 | using namespace PyMesh; |
| 10 | |
| 11 | GeoMeshPtr GeogramMeshUtils::mesh_to_geomesh(const Mesh::Ptr mesh) { |
| 12 | const size_t dim = mesh->get_dim(); |
| 13 | const size_t vertex_per_face = mesh->get_vertex_per_face(); |
| 14 | const size_t num_vertices = mesh->get_num_vertices(); |
| 15 | const size_t num_faces = mesh->get_num_faces(); |
| 16 | const auto& vertices = mesh->get_vertices(); |
| 17 | const auto& faces = mesh->get_faces(); |
| 18 | |
| 19 | if (vertex_per_face != 3) { |
| 20 | throw NotImplementedError("Converting non-triangle mesh to " |
| 21 | "Geogram mesh is not yet implemented"); |
| 22 | } |
| 23 | |
| 24 | auto geo_mesh = std::make_shared<GeoMesh>(dim, false); |
| 25 | geo_mesh->vertices.clear(); |
| 26 | geo_mesh->vertices.create_vertices(num_vertices); |
| 27 | geo_mesh->facets.clear(); |
| 28 | geo_mesh->facets.create_triangles(num_faces); |
| 29 | |
| 30 | for (size_t i=0; i<num_vertices; i++) { |
| 31 | auto& p = geo_mesh->vertices.point(i); |
| 32 | for (size_t j=0; j<dim; j++) { |
| 33 | p[j] = vertices[i*dim+j]; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | for (size_t i=0; i<num_faces; i++) { |
| 38 | geo_mesh->facets.set_vertex(i, 0, faces[i*3]); |
| 39 | geo_mesh->facets.set_vertex(i, 1, faces[i*3+1]); |
| 40 | geo_mesh->facets.set_vertex(i, 2, faces[i*3+2]); |
| 41 | } |
| 42 | |
| 43 | return geo_mesh; |
| 44 | } |
| 45 | |
| 46 | GeoMeshPtr GeogramMeshUtils::raw_to_geomesh( |
| 47 | const MatrixFr& vertices, const MatrixIr& faces) { |
nothing calls this directly
no test coverage detected