77
88import copy
99import warnings
10- from typing import Any , Dict , List , Optional , Tuple , Union
1110
1211import numpy as np
1312from numpy import float64 , int64 , ndarray
4342from .parent import Geometry3D
4443from .scene import Scene
4544from .triangles import MassProperties
46- from .typed import ArrayLike , NDArray
45+ from .typed import Any , ArrayLike , Dict , List , NDArray , Optional , Tuple , Union
4746from .visual import ColorVisuals , TextureVisuals , create_visual
4847
4948try :
7271class Trimesh (Geometry3D ):
7372 def __init__ (
7473 self ,
75- vertices : Optional [NDArray [ float64 ] ] = None ,
76- faces : Optional [NDArray [ int64 ] ] = None ,
74+ vertices : Optional [ArrayLike ] = None ,
75+ faces : Optional [ArrayLike ] = None ,
7776 face_normals : Optional [NDArray [float64 ]] = None ,
7877 vertex_normals : Optional [NDArray [float64 ]] = None ,
7978 face_colors : Optional [NDArray [float64 ]] = None ,
@@ -451,7 +450,7 @@ def vertices(self) -> NDArray[float64]:
451450 return self ._data .get ("vertices" , np .empty (shape = (0 , 3 ), dtype = float64 ))
452451
453452 @vertices .setter
454- def vertices (self , values : NDArray [ float64 ] ):
453+ def vertices (self , values : ArrayLike ):
455454 """
456455 Assign vertex values to the mesh.
457456
@@ -491,7 +490,7 @@ def vertex_normals(self) -> NDArray[float64]:
491490 return vertex_normals
492491
493492 @vertex_normals .setter
494- def vertex_normals (self , values : NDArray [ float64 ] ) -> None :
493+ def vertex_normals (self , values : ArrayLike ) -> None :
495494 """
496495 Assign values to vertex normals.
497496
@@ -1156,8 +1155,8 @@ def merge_vertices(
11561155
11571156 def update_vertices (
11581157 self ,
1159- mask : NDArray [ bool ] ,
1160- inverse : Optional [NDArray ] = None ,
1158+ mask : ArrayLike ,
1159+ inverse : Optional [ArrayLike ] = None ,
11611160 ) -> None :
11621161 """
11631162 Update vertices with a mask.
@@ -1222,7 +1221,7 @@ def update_vertices(
12221221 except BaseException :
12231222 pass
12241223
1225- def update_faces (self , mask : NDArray [ bool ] ) -> None :
1224+ def update_faces (self , mask : ArrayLike ) -> None :
12261225 """
12271226 In many cases, we will want to remove specific faces.
12281227 However, there is additional bookkeeping to do this cleanly.
@@ -1551,8 +1550,7 @@ def vertex_adjacency_graph(self) -> Graph:
15511550 > [1, 2, 3, 4]
15521551 """
15531552
1554- adjacency_g = graph .vertex_adjacency_graph (mesh = self )
1555- return adjacency_g
1553+ return graph .vertex_adjacency_graph (mesh = self )
15561554
15571555 @caching .cache_decorator
15581556 def vertex_neighbors (self ) -> List [List [int64 ]]:
@@ -2170,23 +2168,23 @@ def visual(self, value):
21702168 self ._visual = value
21712169
21722170 def section (
2173- self , plane_normal : List [ int ] , plane_origin : List [ int ] , ** kwargs
2174- ) -> Path3D :
2171+ self , plane_normal : ArrayLike , plane_origin : ArrayLike , ** kwargs
2172+ ) -> Optional [ Path3D ] :
21752173 """
21762174 Returns a 3D cross section of the current mesh and a plane
21772175 defined by origin and normal.
21782176
21792177 Parameters
21802178 ------------
2181- plane_normal: (3) vector for plane normal
2182- Normal vector of section plane
2179+ plane_normal : (3,) float
2180+ Normal vector of section plane.
21832181 plane_origin : (3, ) float
2184- Point on the cross section plane
2182+ Point on the cross section plane.
21852183
21862184 Returns
21872185 ---------
2188- intersections: Path3D or None
2189- Curve of intersection
2186+ intersections
2187+ Curve of intersection or None if it was not hit by plane.
21902188 """
21912189 # turn line segments into Path2D/Path3D objects
21922190 from .exchange .load import load_path
@@ -2214,10 +2212,10 @@ def section(
22142212
22152213 def section_multiplane (
22162214 self ,
2217- plane_origin : NDArray [ float64 ] ,
2218- plane_normal : NDArray [ float64 ] ,
2219- heights : NDArray [ float64 ] ,
2220- ):
2215+ plane_origin : ArrayLike ,
2216+ plane_normal : ArrayLike ,
2217+ heights : ArrayLike ,
2218+ ) -> List [ Optional [ Path2D ]] :
22212219 """
22222220 Return multiple parallel cross sections of the current
22232221 mesh in 2D.
@@ -2226,7 +2224,7 @@ def section_multiplane(
22262224 ------------
22272225 plane_origin : (3, ) float
22282226 Point on the cross section plane
2229- plane_normal: (3) vector for plane normal
2227+ plane_normal : (3) float
22302228 Normal vector of section plane
22312229 heights : (n, ) float
22322230 Each section is offset by height along
@@ -2367,8 +2365,7 @@ def convex_hull(self) -> "Trimesh":
23672365 convex : trimesh.Trimesh
23682366 Mesh of convex hull of current mesh
23692367 """
2370- hull = convex .convex_hull (self )
2371- return hull
2368+ return convex .convex_hull (self )
23722369
23732370 def sample (
23742371 self ,
0 commit comments