| 44 | } |
| 45 | |
| 46 | GeoMeshPtr GeogramMeshUtils::raw_to_geomesh( |
| 47 | const MatrixFr& vertices, const MatrixIr& faces) { |
| 48 | const size_t dim = vertices.cols(); |
| 49 | const size_t vertex_per_face = faces.cols(); |
| 50 | const size_t num_vertices = vertices.rows(); |
| 51 | const size_t num_faces = faces.rows(); |
| 52 | |
| 53 | if (vertex_per_face != 3) { |
| 54 | throw NotImplementedError("Converting non-triangle mesh to " |
| 55 | "Geogram mesh is not yet implemented"); |
| 56 | } |
| 57 | |
| 58 | auto geo_mesh = std::make_shared<GeoMesh>(dim, false); |
| 59 | geo_mesh->vertices.clear(); |
| 60 | geo_mesh->vertices.create_vertices(num_vertices); |
| 61 | geo_mesh->facets.clear(); |
| 62 | geo_mesh->facets.create_triangles(num_faces); |
| 63 | |
| 64 | for (size_t i=0; i<num_vertices; i++) { |
| 65 | auto& p = geo_mesh->vertices.point(i); |
| 66 | for (size_t j=0; j<dim; j++) { |
| 67 | p[j] = vertices(i,j); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | for (size_t i=0; i<num_faces; i++) { |
| 72 | geo_mesh->facets.set_vertex(i, 0, faces(i,0)); |
| 73 | geo_mesh->facets.set_vertex(i, 1, faces(i,1)); |
| 74 | geo_mesh->facets.set_vertex(i, 2, faces(i,2)); |
| 75 | } |
| 76 | |
| 77 | return geo_mesh; |
| 78 | } |
| 79 | |
| 80 | GeoMeshPtr GeogramMeshUtils::wire_network_to_geomesh( |
| 81 | const MatrixFr& vertices, const Matrix2Ir& edges) { |
nothing calls this directly
no test coverage detected