@@ -65,3 +65,53 @@ def trimesh_remesh_along_isolines(M, scalars, isovalues):
6565 ISO = np .asarray (isovalues , dtype = np .float64 )
6666 V2 , F2 , S2 , G2 = _meshing .trimesh_remesh_along_isolines (V , F , S , ISO )
6767 return V2 .tolist (), F2 .tolist (), S2 .tolist (), G2 .tolist ()
68+
69+
70+ @plugin (category = "trimesh" )
71+ def trimesh_cut_mesh (M , cuts ):
72+ """Cut a mesh along specified edges.
73+
74+ Parameters
75+ ----------
76+ M : tuple[list[list[float]], list[list[int]]]
77+ A mesh represented by a tuple of (vertices, faces)
78+ where vertices are 3D points and faces are triangles
79+ cuts : list[list[int]]
80+ A matrix of shape (F, 3) with boolean flags indicating
81+ which edges to cut. For each face, the three values
82+ correspond to edges (v0,v1), (v1,v2), (v2,v0).
83+
84+ Returns
85+ -------
86+ tuple[list[list[float]], list[list[int]]]
87+ A tuple containing
88+ * the vertices of the cut mesh (with duplicated vertices along cuts),
89+ * the faces of the cut mesh.
90+ """
91+ V , F = M
92+ V = np .asarray (V , dtype = np .float64 )
93+ F = np .asarray (F , dtype = np .int32 )
94+ C = np .asarray (cuts , dtype = np .int32 )
95+ Vn , Fn = _meshing .trimesh_cut_mesh (V , F , C )
96+ return Vn .tolist (), Fn .tolist ()
97+
98+
99+ @plugin (category = "trimesh" )
100+ def trimesh_face_components (M ):
101+ """Compute connected components of mesh faces.
102+
103+ Parameters
104+ ----------
105+ M : tuple[list[list[float]], list[list[int]]]
106+ A mesh represented by a tuple of (vertices, faces)
107+ where vertices are 3D points and faces are triangles
108+
109+ Returns
110+ -------
111+ list[int]
112+ Component ID per face. Faces sharing edges belong to the same component.
113+ """
114+ V , F = M
115+ F = np .asarray (F , dtype = np .int32 )
116+ C = _meshing .trimesh_face_components (F )
117+ return C .tolist ()
0 commit comments