| 75 | |
| 76 | |
| 77 | Mesh::Ptr ManifoldCheck::cut_to_manifold(Mesh::Ptr mesh) { |
| 78 | const size_t num_faces = mesh->get_num_faces(); |
| 79 | const size_t vertex_per_face = mesh->get_vertex_per_face(); |
| 80 | if (vertex_per_face != 3) { |
| 81 | throw RuntimeError("Only triangle mesh is supported by cut_to_manifold."); |
| 82 | } |
| 83 | const MatrixIr& faces = MatrixUtils::reshape<MatrixIr>( |
| 84 | mesh->get_faces(), mesh->get_num_faces(), 3); |
| 85 | MatrixIr edge_manifold = is_edge_manifold(faces); |
| 86 | |
| 87 | std::vector<std::vector<int>> non_manifold_edges; |
| 88 | for (size_t i=0; i<num_faces; i++) { |
| 89 | if (edge_manifold(i, 0) < 0.5) { |
| 90 | non_manifold_edges.push_back({faces(i,0), faces(i,1)}); |
| 91 | } |
| 92 | if (edge_manifold(i, 1) < 0.5) { |
| 93 | non_manifold_edges.push_back({faces(i,1), faces(i,2)}); |
| 94 | } |
| 95 | if (edge_manifold(i, 2) < 0.5) { |
| 96 | non_manifold_edges.push_back({faces(i,2), faces(i,0)}); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | MeshCutter cutter(mesh); |
| 101 | return cutter.cut_along_edges(non_manifold_edges); |
| 102 | } |
| 103 |
no test coverage detected