Triangulated Face Selection and Mesh Segmentation via Closed Curves
When segmenting a mesh using a closed curve, the initial step typically involves projecting the user-drawn 2D closed line onto the 3D surface of the mesh to obtain the corresponding three-dimensional edge path (EdgePath
). The specific implementation generally entails projecting each 2D line segment along the line of sight onto the mesh, calculating intersection points, and connecting them to form a closed path on the mesh. Subsequently, the region extraction tools within MeshTopology
can be employed; for instance, MR::fillContourLeft(topology, contourEdges)
can compute all the triangles located to the left (or right) of the edge path, effectively yielding the set of faces encompassed by the closed line.
The final stage involves segmenting the mesh according to this boundary: one approach is to segment the original triangles at the edge path to insert new edges and then distinguish between the faces on either side of the path. For example, one may utilize mesh.topology.deleteFaces(outsideFaces)
to remove the triangles located outside the path, thereby retaining only the selected portion of the mesh, or vice versa. It is essential to invoke mesh.invalidateCaches()
following any topological modifications to refresh the cache. In summary, by leveraging the projected EdgePath
in conjunction with fillContourLeft
(along with subsequent delete/copy operations), one can effectively achieve mesh segmentation based on user-specified closed curves.