77Library for importing, exporting and doing simple operations on triangular meshes.
88"""
99
10- import warnings
1110from copy import deepcopy
1211
1312import numpy as np
@@ -1343,44 +1342,45 @@ def unique_faces(self) -> NDArray[np.bool_]:
13431342 mask [grouping .unique_rows (np .sort (self .faces , axis = 1 ))[0 ]] = True
13441343 return mask
13451344
1346- def remove_duplicate_faces (self ) -> None :
1347- """
1348- DERECATED MARCH 2024 REPLACE WITH:
1349- `mesh.update_faces(mesh.unique_faces())`
1350- """
1351- warnings .warn (
1352- "`remove_duplicate_faces` is deprecated "
1353- + "and will be removed in March 2024: "
1354- + "replace with `mesh.update_faces(mesh.unique_faces())`" ,
1355- category = DeprecationWarning ,
1356- stacklevel = 2 ,
1357- )
1358- self .update_faces (self .unique_faces ())
1359-
13601345 def rezero (self ) -> None :
13611346 """
1362- Translate the mesh so that all vertex vertices are positive.
1347+ Translate the mesh so that all vertex vertices are positive
1348+ and the lower bound of `self.bounds` will be exactly zero.
13631349
13641350 Alters `self.vertices`.
13651351 """
13661352 self .apply_translation (self .bounds [0 ] * - 1.0 )
13671353
13681354 def split (self , ** kwargs ) -> List ["Trimesh" ]:
13691355 """
1370- Returns a list of Trimesh objects, based on face connectivity.
1371- Splits into individual components, sometimes referred to as 'bodies'
1356+ Split a mesh into multiple meshes from face
1357+ connectivity.
1358+
1359+ If only_watertight is true it will only return
1360+ watertight meshes and will attempt to repair
1361+ single triangle or quad holes.
13721362
13731363 Parameters
1374- ------------
1375- only_watertight : bool
1376- Only return watertight meshes and discard remainder
1377- adjacency : None or (n, 2) int
1378- Override face adjacency with custom values
1364+ ----------
1365+ mesh : trimesh.Trimesh
1366+ The source multibody mesh to split
1367+ only_watertight
1368+ Only return watertight components and discard
1369+ any connected component that isn't fully watertight.
1370+ repair
1371+ If set try to fill small holes in a mesh, before the
1372+ discard step in `only_watertight.
1373+ adjacency : (n, 2) int
1374+ If passed will be used instead of `mesh.face_adjacency`
1375+ engine
1376+ Which graph engine to use for the connected components.
1377+ kwargs
1378+ Will be passed to `mesh.submesh`
13791379
13801380 Returns
1381- ---------
1382- meshes : (n, ) trimesh.Trimesh
1383- Separate bodies from original mesh
1381+ ----------
1382+ meshes : (m, ) trimesh.Trimesh
1383+ Results of splitting based on parameters.
13841384 """
13851385 return graph .split (self , ** kwargs )
13861386
@@ -1731,20 +1731,6 @@ def kdtree(self) -> cKDTree:
17311731 """
17321732 return cKDTree (self .vertices .view (np .ndarray ))
17331733
1734- def remove_degenerate_faces (self , height : Floating = tol .merge ) -> None :
1735- """
1736- DERECATED MARCH 2024 REPLACE WITH:
1737- `self.update_faces(self.nondegenerate_faces(height=height))`
1738- """
1739- warnings .warn (
1740- "`remove_degenerate_faces` is deprecated "
1741- + "and will be removed in March 2024 replace with "
1742- + "`self.update_faces(self.nondegenerate_faces(height=height))`" ,
1743- category = DeprecationWarning ,
1744- stacklevel = 2 ,
1745- )
1746- self .update_faces (self .nondegenerate_faces (height = height ))
1747-
17481734 def nondegenerate_faces (self , height : Floating = tol .merge ) -> NDArray [np .bool_ ]:
17491735 """
17501736 Identify degenerate faces (faces without 3 unique vertex indices)
@@ -1894,7 +1880,7 @@ def facets_on_hull(self) -> NDArray[np.bool_]:
18941880
18951881 return on_hull
18961882
1897- def fix_normals (self , multibody : Optional [bool ] = None ) -> None :
1883+ def fix_normals (self , multibody : Optional [bool ] = None ) -> Self :
18981884 """
18991885 Find and fix problems with self.face_normals and self.faces
19001886 winding direction.
@@ -1906,12 +1892,13 @@ def fix_normals(self, multibody: Optional[bool] = None) -> None:
19061892 Parameters
19071893 -------------
19081894 multibody : None or bool
1909- Fix normals across multiple bodies
1910- if None automatically pick from body_count
1895+ Fix normals across multiple bodies or if unspecified
1896+ check the current `Trimesh. body_count`.
19111897 """
19121898 if multibody is None :
19131899 multibody = self .body_count > 1
19141900 repair .fix_normals (self , multibody = multibody )
1901+ return self
19151902
19161903 def fill_holes (self ) -> bool :
19171904 """
0 commit comments