MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / cut_to_manifold

Method cut_to_manifold

tools/MeshUtils/ManifoldCheck.cpp:77–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75
76
77Mesh::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

Callers 1

cut_to_manifoldFunction · 0.80

Calls 6

RuntimeErrorClass · 0.85
is_edge_manifoldFunction · 0.85
cut_along_edgesMethod · 0.80
get_num_facesMethod · 0.45
get_vertex_per_faceMethod · 0.45
get_facesMethod · 0.45

Tested by

no test coverage detected