
    Mi                       S r SSKJr  SSKrSSKJrJrJr  SSKJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJr  SSK J!r!J"r"J#r#J$r$  SSK%J&r&J'r'  SS	K(J)r)  SS
K*J+r+  SSK,J-r-  SSK.J/r/  SSKJ0r0  SSK1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?J@r@JArA  SSKJBrBJCrCJDrD   SSKEJFrF  SSKGJHrH   SSKKJLrL   SSKMJNrN   SSKOJPrP   SSKQJRrRJSrS  \R                  " S\R
                  S9rUS\UR                  lW        \R                  " S\R
                  S9rXS\XR                  lW         " S S\-5      rYg! \I a  rJ\)" \J5      rH\)" \J5      rF SrJCJNSrJCJff = f! \I a  rJ\)" \J5      rL SrJCJNSrJCJff = f! \I a  rJ\)" \J5      rN SrJCJNSrJCJff = f! \I a  rJ\)" \J5      rP SrJCJNSrJCJff = f! \I a  rJ\)" \J5      rR\)" \J5      rS SrJCJNSrJCJff = f)z
# trimesh

https://github.com/mikedh/trimesh
---------------------------------

Library for importing, exporting and doing simple operations on triangular meshes.
    )deepcopyN)float64int64ndarray   )boolean
comparisonconvex	curvaturedecompositiongeometrygraphgroupinginertiaintersections	permutateposes	proximityrayregistrationremeshrepairsampletransformations	trianglesunitsutilvisual)Cache	DataStoreTrackedArraycache_decorator)logtol)ExceptionWrapperexport_mesh)
Geometry3DScene)MassProperties)Any	ArrayLikeBooleanEngineTypeDictFloatingIntegerListLoadableNDArrayNumberOptionalSelfSequenceTupleUnion
ViewerType)ColorVisualsTextureVisualscreate_visual)
coo_matrix)cKDTree)Graph)Image)Index)Path2DPath3D   dtypeF   c            $       ,   \ rS rSr                SS\\   S\\   S\\   S\\   S\\   S\\   S	\\\\4      S
\\\\4      S\\\\4      S\	S\	S\\	   S\\	   S\	S\\\\
4      S\\\\4      SS4"S jjr   SS\	S\\	   S\\	   S\4S jjr\S\	4S j5       r\R&                  S\	SS4S j5       r\S\4S j5       r\R&                  S\\   SS4S j5       r\S\4S j5       r\S\\   4S j5       r\R&                  S\\   SS4S j5       r\S\4S j5       r\R&                  S\\   SS4S  j5       r\S\\   4S! j5       r\R&                  S\SS4S" j5       r\S\\   4S# j5       r\S\\\      4S$ j5       r \S\\\      4S% j5       r!\S\\   4S& j5       r"\S\\   4S' j5       r#\#R&                  S\SS4S( j5       r#\S\$4S) j5       r%\%R&                  S\&SS4S* j5       r%\S\4S+ j5       r'\S\4S, j5       r(\S\\   4S- j5       r)S.\S\\   4S/ jr*\S\\   4S0 j5       r+\S\\   4S1 j5       r,\S\\   4S2 j5       r-\S\\   4S3 j5       r.\S\\\      4S4 j5       r/\S\\\      4S5 j5       r0\S\\   4S6 j5       r1\S\24S7 j5       r3\S\\   4S8 j5       r4\S\\   4S9 j5       r5\S\\   4S: j5       r6\S\\   4S; j5       r7\S\\   4S< j5       r8\S\\   4S= j5       r9\S\\   4S> j5       r:\S\\   4S? j5       r;\S\<4S@ j5       r=\S\4SA j5       r>\S\?4SB j5       r@\S\\   4SC j5       rA\S\?4SD j5       rB\S\\CR                     4SE j5       rESSF\SG\	S\4SH jjrF     SS\\	   S\\	   SI\\G   SJ\\G   SK\\G   SS4SL jjrH SSM\SN\\   SS4SO jjrISM\SS4SP jrJSQ\4SR jrKSSS jrLS\\CR                     4ST jrMSSU jrNS\OS    4SV jrP\S\\   4SW j5       rQ\S\\   4SX j5       rR\S\\   4SY j5       rS\S\<4SZ j5       rT\S\\   4S[ j5       rU\S\\   4S\ j5       rV\S\\CR                     4S] j5       rW\S\\   4S^ j5       rX\S\\   4S_ j5       rY\S\\   4S` j5       rZ\S\4Sa j5       r[\S\\4Sb j5       r]\S\O\O\      4Sc j5       r^\S\	4Sd j5       r_\S\	4Se j5       r`\S\	4Sf j5       ra\S\	4Sg j5       rb\S\	4Sh j5       rc\S\<4Si j5       rd\eR                  4Sj\gS\\CR                     4Sk jjrh\S\O\\      4Sl j5       ri\S\\   4Sm j5       rj\S\\   4Sn j5       rk\S\\   4So j5       rl\S\O\\      4Sp j5       rm\S\\CR                     4Sq j5       rnSSr\\	   S\4Ss jjroS\	4St jrpSu\\q\4   S\r\\   \4   4Sv jrs    SSw\\\      Sx\gSy\GSz\gS\r\\   \\   4   4
S{ jjrt SS|\\   S}\\G   SS 4S~ jjru SS\&S\GS\	S\S \rS \\   4   4   4S jjrvSS}\\G   SS 4S jjrw\SS j5       rx\S\\\\4      4S j5       ry\yR&                  S\\\\4      SS4S j5       ryS\S\S\\z   4S jr{S\S\S\S\O\\|      4S jr}  SS\S\S\	S|\\   SS 4
S jjr~SS\SS 4S jjr\SS j5       r  SS\GS\	S\\\      4S jjrSS jrSS jrS\S\4S jrSS\\g   S\4S jjr   SS\\g   S\\G   S\\G   SS 4S jjrSS\\\      S\z4S jjrS\S\|4S jr\S\4S j5       r\S\\   4S j5       r\S\4S j5       rS\4S jrS\4S jr SS\S\4S jjr  SS\\   S\	S\	S\S \OS    4   4S jjr\S\\   4S j5       r\S\4S j5       r  SS\S\\   S\\\\4   4S jjrS\\\\\O\O\$      \O\O\?      4   4   4S jrS\OS    4S jr  SSu\S \S    4   S\S\	SS 4S jjr  SSu\S \S    4   S\S\	SS 4S jjr  SSu\S \S    4   S\S\	SS 4S jjrS\S\\CR                     4S jr\S\\   4S j5       r\S\4S j5       r\S\\   4S j5       r\S\\   4S j5       r\S\24S j5       rSS\	S\	SS 4S jjrSS jrSS jrS\S\4S jrSS jrSrg)Trimeshe   Nverticesfacesface_normalsvertex_normalsface_colorsvertex_colorsface_attributesvertex_attributesmetadataprocessvalidate	merge_tex
merge_norm
use_embreeinitial_cacher   returnc                    [        5       U l        [        U R                  R                  SS9U l        Ub  U R                  R                  U5        Xl        X l        0 U l        0 U l	        Uc  [        XVU S9U l        O)UU l        Ub  X`R                  S'   Ub  XPR                  S'   Ub  X0l        Ub  X@l        [        R                  (       a,  U(       a%  [        R                   R#                  U 5      U l        O$[        R$                  R#                  U 5      U l        [&        R(                  " U 5      U l        [*        R,                  " U 5      U l        0 U l        [3        U	[4        5      (       a  U R0                  R                  U	5        OU	b  [7        SU	< 35      eUb  U R                  R                  U5        Ub  U R                  R                  U5        U
(       d  U(       a  U R9                  XUS9  gg)a  
A Trimesh object contains a triangular 3D mesh.

Parameters
------------
vertices : (n, 3) float
  Array of vertex locations
faces : (m, 3) or (m, 4) int
  Array of triangular or quad faces (triangulated on load)
face_normals : (m, 3) float
  Array of normal vectors corresponding to faces
vertex_normals : (n, 3) float
  Array of normal vectors for vertices
face_colors : (n, 3|4) uint8
  Array of colors for faces
vertex_colors : (n, 3|4) uint8
  Array of colors for vertices
face_attributes : dict
  Attributes corresponding to faces
vertex_attributes : dict
  Attributes corresponding to vertices
metadata : dict
  Any metadata about the mesh
process : bool
  if True, Nan and Inf values will be removed
  immediately and vertices will be merged
validate : bool
  If True, degenerate and duplicate faces will be
  removed immediately, and some functions will alter
  the mesh to ensure consistent results.
merge_tex : bool
  If True textured meshes with UV coordinates will
  have vertices merged regardless of UV coordinates
merge_norm : bool
  If True, meshes with vertex normals will have
  vertices merged ignoring different normals
use_embree : bool
  If True try to use pyembree raytracer.
  If pyembree is not available it will automatically fall
  back to a much slower rtree/numpy implementation
initial_cache : dict
  A way to pass things to the cache in case expensive
  things were calculated before creating the mesh object.
visual : ColorVisuals or TextureVisuals
  Assigned to self.visual
T)id_functionforce_immutableN)rQ   rR   meshcolorz'metadata should be a dict or None, got )rW   rX   rY   )r    _datar   __hash___cacheupdaterM   rN   rS   rT   r>   r   rO   rP   r   
has_embreeray_pyembreeRayMeshIntersectorray_triangler   
Permutatorr   ProximityQuerynearestrU   
isinstancedict
ValueErrorrV   )selfrM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r   kwargss                     f/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/trimesh/base.py__init__Trimesh.__init__f   s   T [
 

(;(;TR$KK}-
 ! 
  "!# >''4DK !DK (2?&&w/&0;$$W-
 # , %"0
 >>j''::4@DH ''::4@DH #--d3 !//5 h%%MM  *!FxlSTT &  ''8(""))*;< hLL(JLW     c                    U R                   (       a  U $ U(       aB  U R                  5       U R                  5       -  nU R                  U5        U R	                  5         U R
                     U R                  5         U R                  X#S9  U R
                  R                  SS1S9  SSS5        SU R                  S'   U $ ! , (       d  f       N= f)a  
Do processing to make a mesh useful.

Does this by:
    1) removing NaN and Inf values
    2) merging duplicate vertices
If validate:
    3) Remove triangles which have one edge
       of their 2D oriented bounding box
       shorter than tol.merge
    4) remove duplicated triangles
    5) Attempt to ensure triangles are consistently wound
       and normals face outwards.

Parameters
------------
validate : bool
  Remove degenerate and duplicate faces.
merge_tex : bool
  If True textured meshes with UV coordinates will
  have vertices merged regardless of UV coordinates
merge_norm : bool
  If True, meshes with vertex normals will have
  vertices merged ignoring different normals

Returns
------------
self: trimesh.Trimesh
  Current mesh
)rX   rY   rO   rP   excludeNT	processed)
is_emptyunique_facesnondegenerate_facesupdate_facesfix_normalsrd   remove_infinite_valuesmerge_verticesclearrU   )rp   rW   rX   rY   masks        rr   rV   Trimesh.process  s    J ==K $$&)A)A)CCDd# [[''))KKK~7G&HI 
 &*k" [s   );B==
Cc                 .    U R                   R                  $ )z
Is the current mesh allowed to be altered in-place?

Returns
-------------
mutable
  If data is allowed to be set for the mesh.
rb   mutablerp   s    rr   r   Trimesh.mutable?  s     zz!!!ru   valuec                 $    XR                   l        g)z
Set the mutability of the current mesh.

Parameters
----------
value
  Change whether the current mesh is allowed to be altered in-place.
Nr   rp   r   s     rr   r   r   K  s     #

ru   c                      U R                   S   $ )a5  
The faces of the mesh.

This is regarded as core information which cannot be
regenerated from cache and as such is stored in
`self._data` which tracks the array for changes and
clears cached values of the mesh altered.

Returns
----------
faces : (n, 3) int64
  References for `self.vertices` for triangles.
rN   rb   r   s    rr   rN   Trimesh.facesW  s     zz'""ru   valuesc                 <   Uc  [         R                  " S[        S9nO[         R                  " U[        S9n[	        UR
                  5      S:X  a?  UR
                  S   S:w  a,  [        R                  " S5        [        R                  " U5      nXR                  S	'   g)
z
Set the vertex indexes that make up triangular faces.

Parameters
--------------
values : (n, 3) int64
  Indexes of self.vertices
Nr   rF   shaperH   rG      r   rF   ztriangulating facesrN   )npzerosr   
asanyarraylenr   r#   infor   triangulate_quadsrb   rp   r   s     rr   rN   r   h  st     >XXF%8F]]67F v||!fll1o&:HH*+//7F$

7ru   c                 f    [         R                  " [        U R                  5      U R                  S9$ )z
A sparse matrix representation of the faces.

Returns
----------
sparse : scipy.sparse.coo_matrix
  Has properties:
  dtype : bool
  shape : (len(self.vertices), len(self.faces))
)columnsindices)r   index_sparser   rM   rN   r   s    rr   faces_sparseTrimesh.faces_sparse  s$     $$S-?TTru   c                 p   U R                   S   nSU R                  ;   a  U R                  R                  S   nOSnUb  [        U5      S:X  a(  [        R
                  " / [        S9R                  S5      $ [        R                  " U5      [        R                  " U5      :X  a  U$ [        R                  " U R                  U R                  S9u  p4UR                  5       (       a  X0R                   S'   U$ [        R                  " [        U R                  5      S4[        S9nX5U'   XPR                   S'   U$ )	z
Return the unit normal vector for each face.

If a face is degenerate and a normal can't be generated
a zero magnitude unit vector will be returned for that face.

Returns
-----------
normals : (len(self.faces), 3) float64
  Normal vectors of each face
rO   rN   Nr   rG   r   )r   crossesrF   )rd   rb   datar   r   arrayr   reshaper   r   normalstriangles_crossallr   )rp   cachedrN   r   validpaddeds         rr   rO   Trimesh.face_normals  s     ^,djj JJOOG,EE =CJ!O88Bg.66v>> 88Frxx.M #**nnd.B.B

 99;;*1KK'N 3t~~.2'Bu '-N#ru   c                 (   Uc  g[         R                  " US[        S9n[        U5      S:X  d$  UR                  U R
                  R                  :w  a  [        R                  " S5        g[         R                  " U5      n[         R                  " U5      (       d  [        R                  " S5        gU[        R                  :  a  [        R                  " S5        g[        R                  " U R                  R                  [         R                   5      U R
                  SS    5      u  p4[         R"                  " [        U5      S	45      nX5U'   [         R$                  " XQSS 5      (       d  [        R                  " S
5        gXR&                  S'   g)z
Assign values to face normals.

Parameters
-------------
values : (len(self.faces), 3) float
  Unit face normals. If None will clear existing normals.
NCorderrH   r   z'face_normals incorrect shape, ignoring!z#face_normals contain NaN, ignoring!z face_normals all zero, ignoring!   rF   z.face_normals didn't match triangles, ignoring!rO   )r   r   r   r   r   rN   r#   debugptpisfiniter$   merger   r   rM   viewr   r   allcloserd   )rp   r   r   checkr   compares         rr   rO   r     s     >vS@v;!v||tzz/?/??II?@ ffVn{{3II;<?II89 !((););BJJ)G

SVTV)XY((CJ?+{{73BK00IIFG '-N#ru   c                      U R                   S   $ )aG  
The vertices of the mesh.

This is regarded as core information which cannot be
generated from cache and as such is stored in self._data
which tracks the array for changes and clears cached
values of the mesh if this is altered.

Returns
----------
vertices : (n, 3) float
  Points in cartesian space referenced by self.faces
rM   r   r   s    rr   rM   Trimesh.vertices  s      zz*%%ru   c                     Uc  [         R                  " S[        S9n[         R                  " US[        S9U R                  S'   g)zf
Assign vertex values to the mesh.

Parameters
--------------
values : (n, 3) float
  Points in space
Nr   r   r   r   rM   )r   r   r   r   rb   r   s     rr   rM   r     s4     >XXF':F!#vS!P

:ru   c                     [         R                  " [        U R                  5      U R                  U R
                  U R                  S9$ )a  
The vertex normals of the mesh. If the normals were loaded
we check to make sure we have the same number of vertex
normals and vertices before returning them. If there are
no vertex normals defined or a shape mismatch we  calculate
the vertex normals from the mean normals of the faces the
vertex is used in.

Returns
----------
vertex_normals : (n, 3) float
  Represents the surface normal at each vertex.
  Where n == len(self.vertices)
)vertex_countrN   rO   face_angles)r   weighted_vertex_normalsr   rM   rN   rO   r   r   s    rr   rP   Trimesh.vertex_normals
  s<    " //T]]+****((	
 	
ru   c                 "   Ub  [         R                  " US[        S9nUR                  U R                  R                  :X  aM  [         R
                  " U5      [        R                  :  a  [        R                  " S5        XR                  S'   ggg)z
Assign values to vertex normals.

Parameters
-------------
values : (len(self.vertices), 3) float
  Unit normal vectors for each vertex
Nr   r   zvertex_normals are all zero!rP   )r   r   r   r   rM   r   r$   r   r#   r   rd   r   s     rr   rP   r   "  sj     ]]6GDF||t}}22266&>CII-II<=06,-	 3 ru   c                     [         R                  " [        U R                  5      U R                  U R
                  S9nU$ )aZ  
A representation of the face indices that correspond to each vertex.

Returns
----------
vertex_faces : (n,m) int
  Each row contains the face indices that correspond to the given vertex,
  padded with -1 up to the max number of faces corresponding to any one vertex
  Where n == len(self.vertices), m == max number of faces for a single vertex
)r   rN   r   )r   vertex_face_indicesr   rM   rN   r   )rp   vertex_facess     rr   r   Trimesh.vertex_faces4  s8      33T]]+****

 ru   c                     U R                   U R                     n[        U5      S:X  a  g[        R                  " UR                  SS9UR                  SS9/5      $ )z
The axis aligned bounds of the faces of the mesh.

Returns
-----------
bounds : (2, 3) float or None
  Bounding box with [min, max] coordinates
  If mesh is empty will return None
r   Naxis)rM   referenced_verticesr   r   r   minmax)rp   in_meshs     rr   boundsTrimesh.boundsG  sQ     -- 8 89w<1xx!,gkkqk.ABCCru   c                 `    U R                   c  g[        R                  " U R                   SS9nU$ )z
The length, width, and height of the axis aligned
bounding box of the mesh.

Returns
-----------
extents : (3, ) float or None
  Array containing axis aligned [length, width, height]
  If mesh is empty returns None
Nr   r   )r   r   r   )rp   extentss     rr   r   Trimesh.extentsZ  s*     ;;&&1-ru   c                      [         R                  " U R                  U R                  SS9nU$ ! [         a    U R                  R                  SS9n U$ f = f)a  
The point in space which is the average of the triangle
centroids weighted by the area of each triangle.

This will be valid even for non-watertight meshes,
unlike self.center_mass

Returns
----------
centroid : (3, ) float
  The average vertex weighted by face area
r   )weightsr   r   )r   averagetriangles_center
area_facesBaseExceptionmean)rp   centroids     rr   r   Trimesh.centroidm  sZ    "	:zz$"7"7WXYH   	:,,11q19H	:s   *. #AAc                 .    U R                   R                  $ )z
The point in space which is the center of mass/volume.

Returns
-----------
center_mass : (3, ) float
   Volumetric center of mass of the mesh.
)mass_propertiescenter_massr   s    rr   r   Trimesh.center_mass  s     ##///ru   c                     [         R                  " U[        S9nUR                  S:w  a  [	        S5      eXR
                  S'   U R                  R                  S5        g)z
Override the point in space which is the center of mass and volume.

Parameters
-----------
center_mass : (3, ) float
   Volumetric center of mass of the mesh.
rG   )rF   zshape must be (3,) float!r   r   N)r   r   r   r   ro   rb   rd   deleter   s     rr   r   r     sK     g.;;$899$)

=!,-ru   c                 @    [        U R                  R                  5      $ )zt
The density of the mesh used in inertia calculations.

Returns
-----------
density
  The density of the primitive.
)floatr   densityr   s    rr   r   Trimesh.density  s     T))1122ru   c                 j    [        U5      U R                  S'   U R                  R                  S5        g)z
Set the density of the primitive.

Parameters
-------------
density
  Specify the density of the primitive to be
  used in inertia calculations.
r   r   N)r   rb   rd   r   r   s     rr   r   r     s)     !&e

9,-ru   c                 .    U R                   R                  $ )z
Volume of the current mesh calculated using a surface
integral. If the current mesh isn't watertight this is
garbage.

Returns
---------
volume : float
  Volume of the current mesh
)r   volumer   s    rr   r   Trimesh.volume  s     ##***ru   c                 .    U R                   R                  $ )z
Mass of the current mesh, based on specified density and
volume. If the current mesh isn't watertight this is garbage.

Returns
---------
mass : float
  Mass of the current mesh
)r   massr   s    rr   r   Trimesh.mass  s     ##(((ru   c                 .    U R                   R                  $ )a  
Return the moment of inertia matrix of the current mesh.
If mesh isn't watertight this is garbage. The returned
moment of inertia is *axis aligned* at the mesh's center
of mass `mesh.center_mass`. If you want the moment at any
other frame including the origin call:
`mesh.moment_inertia_frame`

Returns
---------
inertia : (3, 3) float
  Moment of inertia of the current mesh at the center of
  mass and aligned with the cartesian axis.
)r   r   r   s    rr   moment_inertiaTrimesh.moment_inertia  s      ##+++ru   	transformc                     U R                   n[        R                  " S5      nUS   * USS2S4'   [        R                  " US   [        R
                  " X15      US   SS9$ )	a  
Get the moment of inertia of this mesh with respect to
an arbitrary frame, versus with respect to the center
of mass as returned by `mesh.moment_inertia`.

For example if `transform` is an identity matrix `np.eye(4)`
this will give the moment at the origin.

Uses the parallel axis theorum to move the center mass
tensor to this arbitrary frame.

Parameters
------------
transform : (4, 4) float
  Homogeneous transformation matrix.

Returns
-------------
inertia : (3, 3)
  Moment of inertia in the requested frame.
rI   r   NrF   r   r   T)inertia_tensorr   r   parallel_axis)r   r   eyer   transform_inertiadot)rp   r   propsoffsets       rr   moment_inertia_frameTrimesh.moment_inertia_frame  sj    . $$ }--rr1u (( +ffV/v	
 	
ru   c                 f    [         R                  " U R                  5      u  pX R                  S'   U$ )z
Return the principal components of inertia

Ordering corresponds to mesh.principal_inertia_vectors

Returns
----------
components : (3, ) float
  Principal components of inertia
principal_inertia_vectors)r   principal_axisr   rd   )rp   
componentsvectorss      rr   principal_inertia_components$Trimesh.principal_inertia_components  s0     &44T5H5HI
3:/0ru   c                 8    U R                   nU R                  S   $ )z
Return the principal axis of inertia as unit vectors.
The order corresponds to `mesh.principal_inertia_components`.

Returns
----------
vectors : (3, 3) float
  Three vectors pointing along the
  principal axis of inertia directions
r   )r  rd   rp   _s     rr   r   !Trimesh.principal_inertia_vectors!  s     --{{677ru   c                 z   [         R                  " U R                  5      SS SSS2   nU R                  U   n[         R                  " U[         R
                  " U6 45      n[         R                  " S5      nX#SS2SS24'   [        R                  " X0R                  S9nUSS2S4==   U R                  -  ss'   U$ )z
A transform which moves the current mesh so the principal
inertia vectors are on the X,Y, and Z axis, and the centroid is
at the origin.

Returns
----------
transform : (4, 4) float
  Homogeneous transformation matrix
r   NrI   rF   )matrixpoint)
r   argsortr  r   vstackcrossr   r   transform_aroundr   )rp   r   r   r   s       rr   principal_inertia_transform#Trimesh.principal_inertia_transform0  s     

4<<=abA$B$G007))Wbhh&89:FF1I	#"1"bqb&#44MM
	 	"1"a%DMM)ru   c                 p    [         R                  " U 5      u  pnX R                  S'   X0R                  S'   U$ )z
Check whether a mesh has rotational symmetry around
an axis (radial) or point (spherical).

Returns
-----------
symmetry : None, 'radial', 'spherical'
  What kind of symmetry does the mesh have.
symmetry_axissymmetry_section)r   radial_symmetryrd   )rp   symmetryr   sections       rr   r  Trimesh.symmetryI  s7     #*"9"9$"?'+O$*1&'ru   c                 <    U R                   c  gU R                  S   $ )z
If a mesh has rotational symmetry, return the axis.

Returns
------------
axis : (3, ) float
  Axis around which a 2D profile was revolved to create this mesh.
Nr  r  rd   r   s    rr   r  Trimesh.symmetry_axisY  s      == {{?++ru   c                 <    U R                   c  gU R                  S   $ )z
If a mesh has rotational symmetry return the two
vectors which make up a section coordinate frame.

Returns
----------
section : (2, 3) float
  Vectors to take a section along
Nr  r  r   s    rr   r  Trimesh.symmetry_sectiong  s!     == {{-..ru   c                 n    U R                   R                  [        R                  5      U R                     $ )z
Actual triangles of the mesh (points, not indexes)

Returns
---------
triangles : (n, 3, 3) float
  Points of triangle vertices
)rM   r   r   r   rN   r   s    rr   r   Trimesh.trianglesv  s&     }}!!"**-djj99ru   c                 B    [         R                  " U R                   5      $ )z
An R-tree containing each face of the mesh.

Returns
----------
tree : rtree.index
  Each triangle in self.faces has a rectangular cell
)r   bounds_treer   s    rr   triangles_treeTrimesh.triangles_tree  s     $$T^^44ru   c                 4    U R                   R                  SS9$ )z
The center of each triangle (barycentric [1/3, 1/3, 1/3])

Returns
---------
triangles_center : (len(self.faces), 3) float
  Center of each triangular face
r   r   )r   r   r   s    rr   r   Trimesh.triangles_center  s     ~~"""**ru   c                 F    [         R                  " U R                   5      nU$ )z}
The cross product of two edges of each triangle.

Returns
---------
crosses : (n, 3) float
  Cross product of each triangle
)r   r  )rp   r   s     rr   r   Trimesh.triangles_cross  s     //$..1ru   c                     [         R                  " U R                  R                  [        R
                  5      SS9u  pX R                  S'   U$ )zx
Edges of the mesh (derived from faces).

Returns
---------
edges : (n, 2) int
  List of vertex indices making up edges
T)return_index
edges_face)r   faces_to_edgesrN   r   r   r   rd   )rp   edgesindexs      rr   r+  Trimesh.edges  s?      ..JJOOBJJ'd
 %*L!ru   c                 8    U R                   nU R                  S   $ )zf
Which face does each edge belong to.

Returns
---------
edges_face : (n, ) int
  Index of self.faces
r)  )r+  rd   r  s     rr   r)  Trimesh.edges_face  s     JJ{{<((ru   c                     [         R                  " U R                  5      u  pU R                  U   nXR                  S'   X R                  S'   U$ )zo
The unique edges of the mesh.

Returns
----------
edges_unique : (n, 2) int
  Vertex indices for unique edges
edges_unique_idxedges_unique_inverse)r   unique_rowsedges_sortedrd   )rp   uniqueinverseedges_uniques       rr   r7  Trimesh.edges_unique  sN     #..t/@/@A((0 +1&'.5*+ru   c                     [         R                  " U R                  U R                  R                     6 n[
        R                  " U5      nU$ )zz
How long is each unique edge.

Returns
----------
length : (len(self.edges_unique), ) float
  Length of each unique edge
)r   subtractrM   r7  Tr   row_norm)rp   vectorlengths      rr   edges_unique_lengthTrimesh.edges_unique_length  s:     dmmD,=,=,?,?@Av&ru   c                 8    U R                   nU R                  S   $ )a  
Return the inverse required to reproduce
self.edges_sorted from self.edges_unique.

Useful for referencing edge properties:
mesh.edges_unique[mesh.edges_unique_inverse] == m.edges_sorted

Returns
----------
inverse : (len(self.edges), ) int
  Indexes of self.edges_unique
r2  )r7  rd   r  s     rr   r2  Trimesh.edges_unique_inverse  s     {{122ru   c                 D    [         R                  " U R                  SS9nU$ )zr
Edges sorted along axis 1

Returns
----------
edges_sorted : (n, 2)
  Same as self.edges but sorted along axis 1
r   r   )r   sortr+  )rp   r4  s     rr   r4  Trimesh.edges_sorted  s     wwtzz2ru   c                 ,    [        U R                  5      $ )z
A KDTree for mapping edges back to edge index.

Returns
------------
tree : scipy.spatial.cKDTree
  Tree when queried with edges will return
  their index in mesh.edges_sorted
)r@   r4  r   s    rr   edges_sorted_treeTrimesh.edges_sorted_tree  s     t(())ru   c                 j    [         R                  " U R                  [        U R                  5      S9nU$ )z
Edges in sparse bool COO graph format where connected
vertices are True.

Returns
----------
sparse: (len(self.vertices), len(self.vertices)) bool
  Sparse graph in COO format
)count)r   edges_to_coor+  r   rM   )rp   sparses     rr   edges_sparseTrimesh.edges_sparse  s(     ##DJJc$--6HIru   c                 x    [         R                  R                  U R                  SSS9u  pX R                  S'   U$ )z
How many connected groups of vertices exist in this mesh.
Note that this number may differ from result in mesh.split,
which is calculated from FACE rather than vertex adjacency.

Returns
-----------
count : int
  Number of connected vertex groups
FT)directedreturn_labelsvertices_component_label)r   csgraphconnected_componentsrM  rd   )rp   rJ  labelss      rr   
body_countTrimesh.body_count   s@     ::T ; 
 39./ru   c                 Z    U R                   nU R                  S   R                  S5      nU$ )a  
For each face return which indexes in mesh.unique_edges constructs
that face.

Returns
---------
faces_unique_edges : (len(self.faces), 3) int
  Indexes of self.edges_unique that
  construct self.faces

Examples
---------
In [0]: mesh.faces[:2]
Out[0]:
TrackedArray([[    1,  6946, 24224],
              [ 6946,  1727, 24225]])

In [1]: mesh.edges_unique[mesh.faces_unique_edges[:2]]
Out[1]:
array([[[    1,  6946],
        [ 6946, 24224],
        [    1, 24224]],
       [[ 1727,  6946],
        [ 1727, 24225],
        [ 6946, 24225]]])
r2  r  rF   )r7  rd   r   )rp   r  results      rr   faces_unique_edgesTrimesh.faces_unique_edges3  s.    : 34<<WEru   c                     [        U R                  R                  5       [        U R                  5      -
  [        U R
                  5      -   5      $ )z
Return the Euler characteristic (a topological invariant) for the mesh
In order to guarantee correctness, this should be called after
remove_unreferenced_vertices

Returns
----------
euler_number : int
  Topological invariant
)intr   sumr   r7  rN   r   s    rr   euler_numberTrimesh.euler_numberU  s@     $$((*S1B1B-CCc$**oU
 	
ru   c                 z    [         R                  " [        U R                  5      [        S9nSXR
                  '   U$ )z
Which vertices in the current mesh are referenced by a face.

Returns
-------------
referenced : (len(self.vertices), ) bool
  Which vertices are referenced by a face
rG   T)r   r   r   rM   boolrN   )rp   
referenceds     rr   r   Trimesh.referenced_verticese  s/     XXc$--0=
!%
::ru   desiredguessc                 4    [         R                  " XU5        U $ )a5  
Convert the units of the mesh into a specified unit.

Parameters
------------
desired : string
  Units to convert to (eg 'inches')
guess : boolean
  If self.units are not defined should we
  guess the current units of the document and then convert?

Returns
------------
self: trimesh.Trimesh
  Current mesh
)r   _convert_units)rp   rf  rg  s      rr   convert_unitsTrimesh.convert_unitss  s    " 	TE2ru   digits_vertexdigits_norm	digits_uvc           	      6    [         R                  " U UUUUUS9  g)a2  
Removes duplicate vertices grouped by position and
optionally texture coordinate and normal.

Parameters
-------------
merge_tex : bool
  If True textured meshes with UV coordinates will
  have vertices merged regardless of UV coordinates
merge_norm : bool
  If True, meshes with vertex normals will have
  vertices merged ignoring different normals
digits_vertex : None or int
  Number of digits to consider for vertex position
digits_norm : int
  Number of digits to consider for unit normals
digits_uv : int
  Number of digits to consider for UV coordinates
)r`   rX   rY   rl  rm  rn  N)r   r   )rp   rX   rY   rl  rm  rn  s         rr   r   Trimesh.merge_vertices  s$    6 	!'#	
ru   r   r6  c                    U R                   (       a  g[        R                  " U5      nUR                  R                  S:X  a  UR                  5       (       d   [        U5      S:X  d  U R                   (       a  gUc  [        R                  " [        U R                  5      [        S9nUR                  R                  S:X  a'  [        R                  " UR                  5       5      X!'   O>UR                  R                  S:X  a"  [        R                  " [        U5      5      X!'   OSnUbW  [        R                  " U R                  S5      (       a1  X R                  R!                  S5         R!                  S5      U l        U R"                  R%                  U5        U R&                  S	   n[        U R                  5      nU R(                  R+                  5        H1  u  pV [        U5      U:w  a
  [-        5       e Xa   U R(                  U'   M3     U R                  U   U l        [        R                  " US5      (       a   X1   U l        gg! [,         a     M~  f = f! [0         a     gf = f)
z
Update vertices with a mask.

Parameters
------------
mask : (len(self.vertices)) bool
  Array of which vertices to keep
inverse : (len(self.vertices)) int
  Array to reconstruct vertex references
  such as output by np.unique
Nrc  r   rG   birY  r  rP   )rz   r   r   rH   namer   r   r   rM   r   kindaranger_  r   is_shaperN   r   r   update_verticesrd   rT   items	TypeErrorrP   r   )rp   r   r6  cached_normalsrJ  keyr   s          rr   rx  Trimesh.update_vertices  s   " == }}T"JJOOv%$((**Ta4== ?hhs4==1?Gzz#% "		$((* 5C' "		#d) 4 4==W#E#E !3!3B!78@@IDJ 	##D)%56 DMM"00668JCu:&#+% '
 +0+D""3' 9 d+ ==11&4&:# 2   ! s$    I 	I 
II
I)(I)c                    U R                   (       a  g[        R                  " U5      nUR                  R                  S:X  a  UR                  5       (       a  gU R                  S   nU R                  S   n[        R                  " US5      (       d  U R                  S   n[        U R                  5      nU R                  R                  5        H1  u  pV [        U5      U:w  a
  [        5       e Xa   U R                  U'   M3     X1   U l        U R                  R!                  U5        [        R                  " US5      (       a
  X!   U l        gg! [         a     M  f = f)a:  
In many cases, we will want to remove specific faces.
However, there is additional bookkeeping to do this cleanly.
This function updates the set of faces with a validity mask,
as well as keeping track of normals and colors.

Parameters
------------
mask : (m) int or (len(self.faces)) bool
  Mask to remove faces
Nrc  rO   rN   rY  )rz   r   r   rH   rt  r   rd   rb   r   rw  r   rN   rS   ry  rz  r   r}   rO   )rp   r   r{  rN   rJ  r|  r   s          rr   r}   Trimesh.update_faces  s*    ==}}T"::??f$ ^4

7# }}UG,,KK(E DJJ..446JCu:&#+% '
 ).D  % 7 [
 	  & ==11 . 4D 2  s   E
EE	new_facesc           	      "   [         R                  " U[         R                  S9n[        UR                  5      S:w  d  UR                  S   S:w  a  [        SUR                   S35      e[        U5      S:X  a  gU R                  R                  5         S	u  p#[        R                  " U R                  U   5      u  pEX   n[        U5      S:X  a  gS
U R                  R                  ;   a?  U R                  R                  S
   n[        U5      S:  a  [        R                  " Xd45      nU R                  R                  (       at  U R                  R                   S:X  aZ  [        R                  " U R                  R"                  [         R$                  " [        R&                  [        U5      S45      45      n[        U R(                  S   5      n[        R                  " U R(                  S   U45      U l        U R                  R                  5         Ub  X R                  S
'   Ub  X0R                  l        0 nU R,                  R/                  5        H  u  p[         R                  " U
5      n[        U5      S:X  d	  US   U:w  a  M5  U
R0                  R                   S:X  a  SOSn[        U5      4USS -   n[         R2                  " XU
R0                  S9n[         R4                  " X45      X'   M     U R,                  R7                  U5        g)a;  
Extend `mesh.faces` in-place with new triangles.

This does substantial bookkeeping: padding face colors
and face attributes with default values, and preserving cached
face normals to avoid recomputing every normal.

Parameters
------------
new_faces : (n, 3) integer
  The new faces as indexes of `self.vertices`
rG   r   r   rF   zFaces must be triangular, not `z`!r   NNNrO   facerN   rs  r  )r   r   r   r   r   ro   rd   verifyr   r   rM   cacher   vstack_emptyr   definedru  rQ   tileDEFAULT_COLORrb   rN   rS   ry  rH   fullconcatenatere   )rp   r  extend_normalsextend_colorsnew_normalsr   r{  original_lengthnew_attribsrt  attribr   fill	pad_shapepads                  rr   extend_facesTrimesh.extend_faces#  st    MM)288<	y1$	(:a(?>y>OrRSSy>Q 	 )3% '..t}}Y/GH$	y>Q T[[...![[..~>N>"Q&!%!2!2N3P!Q;;4;;#3#3v#= --KK++GGF003y>12EFM djj12&&

7(;Y'GH
%*8KK'$&3KK#  00668LDHHV$E5zQ%(o"=**c12qDY)E!"I5I'')>C "} =K 9 	##K0ru   c                    [         R                  " U R                  S5      (       a>  [        R                  " U R                  5      R                  SS9nU R                  U5        [         R                  " U R                  S5      (       a?  [        R                  " U R                  5      R                  SS9nU R                  U5        gg)z
Ensure that every vertex and face consists of finite numbers.
This will remove vertices or faces containing np.nan and np.inf

Alters `self.faces` and `self.vertices`
rY  r   r   N)	r   rw  rN   r   r   r   r}   rM   rx  )rp   	face_maskvertex_masks      rr   r   Trimesh.remove_infinite_valuesl  s     ==W--DJJ/333;Ii(==00++dmm488a8@K  - 1ru   c           	          [         R                  " [        U R                  5      [        S9nSU[
        R                  " [         R                  " U R                  SS95      S   '   U$ )z
On the current mesh find which faces are unique.

Returns
--------
unique : (len(faces),) bool
  A mask where the first occurrence of a unique face is true.
rG   Tr   r   r   )r   r   r   rN   rc  r   r3  rD  )rp   r   s     rr   r{   Trimesh.unique_faces}  sJ     xxDJJt4EIX!!"''$**1"=>qABru   c                 F    U R                  U R                  S   S-  5        g)z
Translate the mesh so that all vertex vertices are positive
and the lower bound of `self.bounds` will be exactly zero.

Alters `self.vertices`.
r         N)apply_translationr   r   s    rr   rezeroTrimesh.rezero  s     	t{{1~45ru   c                 0    [         R                  " U 40 UD6$ )a  
Split a mesh into multiple meshes from face
connectivity.

If only_watertight is true it will only return
watertight meshes and will attempt to repair
single triangle or quad holes.

Parameters
----------
mesh : trimesh.Trimesh
  The source multibody mesh to split
only_watertight
  Only return watertight components and discard
  any connected component that isn't fully watertight.
repair
  If set try to fill small holes in a mesh, before the
  discard step in `only_watertight.
adjacency : (n, 2) int
  If passed will be used instead of `mesh.face_adjacency`
engine
  Which graph engine to use for the connected components.
kwargs
  Will be passed to `mesh.submesh`

Returns
----------
meshes : (m,) trimesh.Trimesh
  Results of splitting based on parameters.
)r   splitrp   rq   s     rr   r  Trimesh.split  s    > {{4*6**ru   c                 P    [         R                  " U SS9u  pX R                  S'   U$ )a  
Find faces that share an edge i.e. 'adjacent' faces.

Returns
----------
adjacency : (n, 2) int
  Pairs of faces which share an edge

Examples
---------

In [1]: mesh = trimesh.load('models/featuretype.STL')

In [2]: mesh.face_adjacency
Out[2]:
array([[   0,    1],
       [   2,    3],
       [   0,    3],
       ...,
       [1112,  949],
       [3467, 3475],
       [1113, 3475]])

In [3]: mesh.faces[mesh.face_adjacency[0]]
Out[3]:
TrackedArray([[   1,    0,  408],
              [1239,    0,    1]], dtype=int64)

In [4]: import networkx as nx

In [5]: graph = nx.from_edgelist(mesh.face_adjacency)

In [6]: groups = nx.connected_components(graph)
T)r`   return_edgesface_adjacency_edges)r   face_adjacencyrd   )rp   	adjacencyr+  s      rr   r  Trimesh.face_adjacency  s-    H !//TM	.3*+ru   c                 .    [         R                  " U 5      $ )z
Find faces that share a vertex i.e. 'neighbors' faces.

Returns
----------
neighborhood : (n, 2) int
  Pairs of faces which share a vertex
)r   face_neighborhoodr   s    rr   r  Trimesh.face_neighborhood  s     &&t,,ru   c                 8    U R                   nU R                  S   $ )z
Returns the edges that are shared by the adjacent faces.

Returns
--------
edges : (n, 2) int
   Vertex indices which correspond to face_adjacency
r  )r  rd   r  s     rr   r  Trimesh.face_adjacency_edges  s     {{122ru   c                 ,    [        U R                  5      $ )z
A KDTree for mapping edges back face adjacency index.

Returns
------------
tree : scipy.spatial.cKDTree
  Tree when queried with SORTED edges will return
  their index in mesh.face_adjacency
)r@   r  r   s    rr   face_adjacency_edges_tree!Trimesh.face_adjacency_edges_tree  s     t0011ru   c                 d    U R                   U R                     n[        R                  " U5      nU$ )aJ  
Return the unsigned angle between adjacent faces
in radians.

Note that if you want a signed angle you can easily
use the `face_adjacency_convex` attribute to get a
signed angle with advanced indexing:

```
# get a sign per face_adacency pair from the "is it convex" boolean
signs = np.array([-1.0, 1.0])[mesh.face_adjacency_convex.astype(np.int64)]

# apply the signs to the angles
angles = mesh.face_adjacency_angles * signs
```

Returns
--------
adjacency_angle : (len(self.face_adjacency), ) float
  Unsigned angle between adjacent faces
  corresponding with `self.face_adjacency`
)rO   r  r   vector_angle)rp   pairsangless      rr   face_adjacency_anglesTrimesh.face_adjacency_angles  s/    2 !!$"5"56&&u-ru   c                 2    [         R                  " U 5      nU$ )z
The projection of the non-shared vertex of a triangle onto
its adjacent face

Returns
----------
projections : (len(self.face_adjacency), ) float
  Dot product of vertex
  onto plane of adjacent triangle.
)r
   adjacency_projections)rp   projectionss     rr   face_adjacency_projections"Trimesh.face_adjacency_projections!  s     2248ru   c                 <    U R                   [        R                  :  $ )aC  
Return faces which are adjacent and locally convex.

What this means is that given faces A and B, the one vertex
in B that is not shared with A, projected onto the plane of A
has a projection that is zero or negative.

Returns
----------
are_convex : (len(self.face_adjacency), ) bool
  Face pairs that are locally convex
)r  r$   r   r   s    rr   face_adjacency_convexTrimesh.face_adjacency_convex0  s     ..::ru   c                 .    [         R                  " U 5      $ )z
Return the vertex index of the two vertices not in the shared
edge between two adjacent faces

Returns
-----------
vid_unshared : (len(mesh.face_adjacency), 2) int
  Indexes of mesh.vertices
)r   face_adjacency_unsharedr   s    rr   r  Trimesh.face_adjacency_unshared@  s     ,,T22ru   c                 L    [         R                  " U S9u  oR                  S'   U$ )z
The approximate radius of a cylinder that fits inside adjacent faces.

Returns
------------
radii : (len(self.face_adjacency), ) float
  Approximate radius formed by triangle pair
r`   face_adjacency_span)r   face_adjacency_radiusrd   )rp   radiis     rr   r  Trimesh.face_adjacency_radiusM  s'     5:4O4OUY4Z1{{01ru   c                 8    U R                   nU R                  S   $ )z
The approximate perpendicular projection of the non-shared
vertices in a pair of adjacent faces onto the shared edge of
the two faces.

Returns
------------
span : (len(self.face_adjacency), ) float
  Approximate span between the non-shared vertices
r  )r  rd   r  s     rr   r  Trimesh.face_adjacency_spanZ  s     &&{{011ru   c                 n   [         R                  R                  [         R                  " U R                  U R
                  R                     6 SS9n[         R                  " SS/5      U R                  R                  [         R                  5         nU R                  U-  nX1-  R                  5       S-  $ )z
The integral mean curvature, or the surface integral of the mean curvature.

Returns
---------
area : float
  Integral mean curvature of mesh
r   r   r  g      ?g      ?)r   linalgnormr:  rM   r  r;  r   r  astyper   r  r_  )rp   edges_lengthsignsr  s       rr   integral_mean_curvatureTrimesh.integral_mean_curvaturei  s     yy~~KKt'@'@'B'BCD1 & 
 $%d&@&@&G&G&QR++e3%**,s22ru   c                 *    [         R                  " U S9$ )a  
Returns a networkx graph representing the vertices and their connections
in the mesh.

Returns
---------
graph: networkx.Graph
  Graph representing vertices and edges between
  them where vertices are nodes and edges are edges

Examples
----------
This is useful for getting nearby vertices for a given vertex,
potentially for some simple smoothing techniques.

mesh = trimesh.primitives.Box()
graph = mesh.vertex_adjacency_graph
graph.neighbors(0)
> [1, 2, 3, 4]
r  )r   vertex_adjacency_graphr   s    rr   r  Trimesh.vertex_adjacency_graph|  s    . ++66ru   c                 f    [         R                  " U R                  [        U R                  5      S9$ )a  
The vertex neighbors of each vertex of the mesh, determined from
the cached vertex_adjacency_graph, if already existent.

Returns
----------
vertex_neighbors : (len(self.vertices), ) int
  Represents immediate neighbors of each vertex along
  the edge of a triangle

Examples
----------
This is useful for getting nearby vertices for a given vertex,
potentially for some simple smoothing techniques.

>>> mesh = trimesh.primitives.Box()
>>> mesh.vertex_neighbors[0]
[1, 2, 3, 4]
)r+  	max_index)r   	neighborsr7  r   rM   r   s    rr   vertex_neighborsTrimesh.vertex_neighbors  s$    * T%6%6#dmmBTUUru   c                 \    U R                   (       a  gU R                  nU R                  S   $ )z
Does the mesh have consistent winding or not.
A mesh with consistent winding has each shared edge
going in an opposite direction from the other in the pair.

Returns
--------
consistent : bool
  Is winding is consistent or not
Fis_winding_consistent)rz   is_watertightrd   r  s     rr   r  Trimesh.is_winding_consistent  s)     =={{233ru   c                     U R                   (       a  g[        R                  " U R                  U R                  S9u  pX R
                  S'   U$ )z
Check if a mesh is watertight by making sure every edge is
included in two faces.

Returns
----------
is_watertight : bool
  Is mesh watertight or not
F)r+  r4  r  )rz   r   r  r+  r4  rd   )rp   
watertightwindings      rr   r  Trimesh.is_watertight  sE     ==#11**4+<+<

 07+,ru   c                     [        U R                  =(       aW    U R                  =(       aD    [        R                  " U R
                  5      R                  5       =(       a    U R                  S:  5      $ )a  
Check if a mesh has all the properties required to represent
a valid volume, rather than just a surface.

These properties include being watertight, having consistent
winding and outward facing normals.

Returns
---------
valid
  Does the mesh represent a volume
        )rc  r  r  r   r   r   r   r   r   s    rr   	is_volumeTrimesh.is_volume  s[      "**"D,,-113" c!	
 	
ru   c                 6    U R                   R                  5       $ )zw
Does the current mesh have data defined.

Returns
--------
empty : bool
  If True, no data is set on the current mesh
)rb   rz   r   s    rr   rz   Trimesh.is_empty  s     zz""$$ru   c                 h    U R                   (       a  g[        [        R                  " U 5      5      nU$ )z_
Check if a mesh is convex or not.

Returns
----------
is_convex: bool
  Is mesh convex or not
F)rz   rc  r
   	is_convex)rp   r  s     rr   r  Trimesh.is_convex  s)     ==))$/0	ru   c                 f    [        U R                  R                  [        R                  5      5      $ )z
Return a scipy.spatial.cKDTree of the vertices of the mesh.
Not cached as this lead to observed memory issues and segfaults.

Returns
---------
tree : scipy.spatial.cKDTree
  Contains mesh.vertices
)r@   rM   r   r   r   r   s    rr   kdtreeTrimesh.kdtree  s"     t}}))"**566ru   heightc                 V    [         R                  " U R                   U R                  US9$ )aW  
Identify degenerate faces (faces without 3 unique vertex indices)
in the current mesh.

Usage example for removing them:
`mesh.update_faces(mesh.nondegenerate_faces())`

If a height is specified, it will identify any face with a 2D oriented
bounding box with one edge shorter than that height.

If not specified, it will identify any face with a zero normal.

Parameters
------------
height : float
  If specified identifies faces with an oriented bounding
  box shorter than this on one side.

Returns
-------------
nondegenerate : (len(self.faces), ) bool
  Mask that can be used to remove faces
)areasr  )r   nondegenerater   )rp   r  s     rr   r|   Trimesh.nondegenerate_faces  s&    0 &&NN$//&
 	
ru   c                 2    [         R                  " U 5      nU$ )z
Return a list of face indices for coplanar adjacent faces.

Returns
---------
facets : (n, ) sequence of (m, ) int
  Groups of indexes of self.faces
)r   facets)rp   r  s     rr   r  Trimesh.facets+  s     d#ru   c           	          U R                   n[        R                  " U R                   Vs/ s H  n[	        X   5      PM     sn[
        S9nU$ s  snf )z
Return an array containing the area of each facet.

Returns
---------
area : (len(self.facets), ) float
  Total area of each facet (group of faces)
rG   )r   r   r   r  r_  r   )rp   r   rs  r  s       rr   facets_areaTrimesh.facets_area8  sD     __

 dkkBk#jm,kB'R Cs   Ac                    [        U R                  5      S:X  a  [        R                  " / 5      $ U R                  n[        R                  " U R                   Vs/ s H  o"X   R                  5          PM     sn5      nU R                  U   nU R                  U R                  SS2S4   U      nXPR                  S'   U$ s  snf )z
Return the normal of each facet

Returns
---------
normals: (len(self.facets), 3) float
  A unit normal vector for each facet
r   Nfacets_origin)
r   r  r   r   r   argmaxrO   rM   rN   rd   )rp   r   rs  r,  r   originss         rr   facets_normalTrimesh.facets_normalK  s     t{{q 88B<__
 T[[I[JM0023[IJ##E*--

1a4 0 78'.O$ Js   Cc                 8    U R                   nU R                  S   $ )z~
Return a point on the facet plane.

Returns
------------
origins : (len(self.facets), 3) float
  A point on each facet plane
r  )r   rd   r  s     rr   r  Trimesh.facets_origine  s     {{?++ru   c           	          U R                   R                  S5      nU R                   Vs/ s H  o!U   R                  S5      PM     nnU Vs/ s H  o"[        R                  " USS9   PM     nnU$ s  snf s  snf )z
Return the edges which represent the boundary of each facet

Returns
---------
edges_boundary : sequence of (n, 2) int
  Indices of self.vertices
)r     )r  r   r   )require_count)r4  r   r  r   
group_rows)rp   r+  rs  edges_facetedges_boundarys        rr   facets_boundaryTrimesh.facets_boundaryr  sr     !!))'2:>++F+QQx''0+FNYZkH//CDkZ GZs   A2!A7c                 P   [        U R                  5      S:X  a  [        R                  " / [        S9$ U R
                  nU R                  nU R                  R                  R                  [        R                  5      R                  5       n[        R                  " [        U R                  5      [        S9n[        [        [        U5      5      X5       HL  u  pVn[        R                  " XcU-
  R                   5      nU["        R$                  :  R'                  5       XE'   MN     U$ )z
Find which facets of the mesh are on the convex hull.

Returns
---------
on_hull : (len(mesh.facets), ) bool
  is A facet on the meshes convex hull or not
r   rG   )r   r  r   r   rc  r   r  convex_hullrM   r   r   copyr   zipranger   r;  r$   r   r   )	rp   r   r  r
   on_hullrs  normaloriginr   s	            rr   facets_on_hullTrimesh.facets_on_hull  s     t{{q 88Bd++ $$$$ !!**//

;@@B ((3t{{+48!$U3w<%8'!KAv &&6/!4!45C		/..0GJ "L ru   	multibodyc                 R    Uc  U R                   S:  n[        R                  " XS9  U $ )a  
Find and fix problems with self.face_normals and self.faces
winding direction.

For face normals ensure that vectors are consistently pointed
outwards, and that self.faces is wound in the correct direction
for all connected components.

Parameters
-------------
multibody : None or bool
  Fix normals across multiple bodies or if unspecified
  check the current `Trimesh.body_count`.
r   )r  )rV  r   r~   )rp   r  s     rr   r~   Trimesh.fix_normals  s+     !+I45ru   c                 .    [         R                  " U 5      $ )z
Fill single triangle and single quad holes in the current mesh.

Returns
----------
watertight : bool
  Is the mesh watertight after the function completes
)r   
fill_holesr   s    rr   r  Trimesh.fill_holes  s       &&ru   otherc                 <    [         R                  " SXS.UD6u  p4X44$ )aj  
Align a mesh with another mesh or a PointCloud using
the principal axes of inertia as a starting point which
is refined by iterative closest point.

Parameters
------------
other : trimesh.Trimesh or (n, 3) float
  Mesh or points in space
samples : int
  Number of samples from mesh surface to align
icp_first : int
  How many ICP iterations for the 9 possible
  combinations of
icp_final : int
  How many ICP itertations for the closest
  candidate from the wider search

Returns
-----------
mesh_to_other : (4, 4) float
  Transform to align mesh to the other object
cost : float
  Average square distance per point
)r`   r   )r   
mesh_other)rp   r  rq   mesh_to_othercosts        rr   registerTrimesh.register  s)    8 +55W4WPVW""ru   r   sigma	n_samples	thresholdc                 2    [         R                  " U UUUUS9$ )a  
Computes stable orientations of a mesh and their quasi-static probabilities.

This method samples the location of the center of mass from a multivariate
gaussian (mean at com, cov equal to identity times sigma) over n_samples.
For each sample, it computes the stable resting poses of the mesh on a
a planar workspace and evaluates the probabilities of landing in
each pose if the object is dropped onto the table randomly.

This method returns the 4x4 homogeneous transform matrices that place
the shape against the planar surface with the z-axis pointing upwards
and a list of the probabilities for each pose.
The transforms and probabilities that are returned are sorted, with the
most probable pose first.

Parameters
------------
center_mass : (3, ) float
  The object center of mass (if None, this method
  assumes uniform density and watertightness and
  computes a center of mass explicitly)
sigma : float
  The covariance for the multivariate gaussian used
  to sample center of mass locations
n_samples : int
  The number of samples of the center of mass location
threshold : float
  The probability value at which to threshold
  returned stable poses

Returns
-------
transforms : (n, 4, 4) float
  The homogeneous matrices that transform the
  object to rest in a stable pose, with the
  new z-axis pointing upwards from the table
  and the object just touching the table.

probs : (n, ) float
  A probability ranging from 0.0 to 1.0 for each pose
)r`   r   r$  r%  r&  )r   compute_stable_poses)rp   r   r$  r%  r&  s        rr   r(  Trimesh.compute_stable_poses  s'    ` ))#
 	
ru   
face_index
iterationsc                    Ub  Ub  [        S5      eUS-
  nUS::  a  SnSn[        U R                  S5      (       a  [        R                  " U R                  R
                  5      [        U R                  5      S4:X  a  [        R                  " [        R                  " U R                  U R                  R
                  45      U R                  UU R                  S9u  pVnU R                  R                  5       nUSS2SS24   USS2SS24   soTl        O8[        R                  " U R                  U R                  UU R                  S9u  pVn[        UUUUS	S
9nUb  UR                  WS9$ U$ )aX  
Subdivide a mesh with each subdivided face replaced
with four smaller faces. Will return a copy of current
mesh with subdivided faces.

Parameters
------------
face_index : (m, ) int or None
  If None all faces of mesh will be subdivided
  If (m, ) int array of indices: only specified faces will be
  subdivided. Note that in this case the mesh will generally
  no longer be manifold, as the additional vertex on the midpoint
  will not be used by the adjacent faces to the faces specified,
  and an additional postprocessing step will be required to
  make resulting mesh watertight
iterations : int
  If passed will run subdivisions multiple times recursively.
  NOT COMPATIBLE with `face_index` and will raise a `ValueError`
  if both arguments are passed.

Returns
------------
mesh: trimesh.Trimesh
  The copy of current mesh with subdivided faces.
Nz6Unable to subdivide a subset with multiple iterations!r   r   uvr   )rM   rN   r*  rT   rF   F)rM   rN   r   rT   rV   )r+  )ro   hasattrr   r   r   r-  r   rM   r   	subdividehstackrN   rT   r  rK   )	rp   r*  r+  next_iterationr   rM   rN   attrrZ  s	            rr   r/  Trimesh.subdivide  sa   8 !% !YZZ'!^N"!%4;;%%"((4;;>>*BG
 +

 %+$4$4DMM4;;>>#BCjj%"&"8"8	%!HT [[%%'F #+1bqb5/8AqrE?Hi %+$4$4jj%"&"8"8	%!HT "
 !##~#>>ru   max_edgemax_iterr(  c                    Sn[        U R                  S5      (       a  [        R                  " U R                  R                  5      [        U R                  5      S4:X  a  [        R                  " [        R                  " U R                  U R                  R                  45      U R                  UUUS9nU(       a  Uu  pgnOUu  pgU R                  R                  5       nUSS2SS24   USS2SS24   sodl        O=[        R                  " U R                  U R                  UUUS9nU(       a  Uu  pgnOUu  pg[        XgUSS9n	U(       a  U	W4$ U	$ )a  
Subdivide a mesh until every edge is shorter than a
specified length.

Will return a triangle soup, not a nicely structured mesh.

Parameters
------------
max_edge
    Maximum length of any edge in the result
max_iter : int
    The maximum number of times to run subdivision
return_index : bool
    If True, return index of original face for new faces

Returns
------------
mesh: trimesh.Trimesh
  The copy of current mesh with subdivided faces.
Nr-  r   )rM   rN   r4  r5  r(  rF   FrM   rN   r   rV   )r.  r   r   r   r-  r   rM   r   subdivide_to_sizer0  rN   r  rK   )
rp   r4  r5  r(  r   vertices_facesrM   rN   final_indexrZ  s
             rr   r8  Trimesh.subdivide_to_sizej  s7   0 4;;%%"((4;;>>*BG
 +

 $55DMM4;;>>#BCjj!!)N /=,"0 [[%%'F #+1bqb5/8AqrE?Hi $55jj!!)N /=,"0 (PUV;&&ru   c                 n    [         R                  " U R                  U R                  US9u  p#[	        X#SS9$ )a  
Subdivide a mesh by dividing each triangle into four
triangles and approximating their smoothed surface
using loop subdivision. Loop subdivision often looks
better on triangular meshes than catmul-clark, which
operates primarily on quads.

Parameters
------------
iterations : int
  Number of iterations to run subdivision.
multibody : bool
  If True will try to subdivide for each submesh

Returns
------------
mesh: trimesh.Trimesh
  The copy of current mesh with subdivided faces.
)rM   rN   r+  F)rM   rN   rV   )r   subdivide_looprM   rN   rK   )rp   r+  new_verticesr  s       rr   r=  Trimesh.subdivide_loop  s5    * #)"7"7]]$**#
 uMMru   c                     U R                   R                  5         U R                   R                  nS[        U R                   5       S[        U 5       3nX!;   a  X   $ [        R
                  " U 5      nX1U'   U$ )a  
Smooth shading in OpenGL relies on which vertices are shared,
this function will disconnect regions above an angle threshold
and return a non-watertight version which will look better
in an OpenGL rendering context.

If you would like to use non-default arguments see `graph.smooth_shade`.

Returns
---------
smooth_shaded : trimesh.Trimesh
  Non watertight version of current mesh.
smooth_shaded_r  )r   _verify_hashrd   hashr   smooth_shade)rp   r  r|  smooths       rr   smooth_shadedTrimesh.smooth_shaded  sl    " 	  """tDKK014:,?<:##D)c
ru   c                 >    [        U S5      (       a  U R                  $ g)z
Get the stored visuals for the current mesh.

Returns
-------------
visual : ColorVisuals or TextureVisuals
  Contains visual information about the mesh
_visualN)r.  rI  r   s    rr   r   Trimesh.visual  s     4##<<ru   c                 6    Uc
  [        5       nXl        Xl        g)z
When setting a visual object, always make sure
that `visual.mesh` points back to the source mesh.

Parameters
--------------
visual : ColorVisuals or TextureVisuals
  Contains visual information about the mesh
N)r<   r`   rI  r   s     rr   r   rJ    s     = NE
ru   plane_normalplane_originc                     SSK Jn  SSKJn  [        R
                  " SU UUSS.UD6u  pg[        U5      S:X  a  gU" U5      nU" S0 UD6$ )	aK  
Returns a 3D cross section of the current mesh and a plane
defined by origin and normal.

Parameters
------------
plane_normal : (3,) float
  Normal vector of section plane.
plane_origin : (3, ) float
  Point on the cross section plane.

Returns
---------
intersections
  Curve of intersection or None if it was not hit by plane.
r   )lines_to_path)rE   T)r`   rL  rM  return_facesr   Nr  )path.exchange.miscrO  	path.pathrE   r   
mesh_planer   )	rp   rL  rM  rq   rO  rE   lines_face_indexpaths	            rr   r  Trimesh.section	  sd    ( 	6% +55 
%%	

 
 u:? U#
 ~~ru   heightsc                     SSK Jn  [        R                  " U UUUS9u  pVnS/[	        U5      -  n[        [        [	        U5      5      XuU5       H"  u  pp[	        U5      S:  d  M  U" XU
S.S9X'   M$     U$ )a  
Return multiple parallel cross sections of the current
mesh in 2D.

Parameters
------------
plane_origin : (3, ) float
  Point on the cross section plane
plane_normal : (3) float
  Normal vector of section plane
heights : (n, ) float
  Each section is offset by height along
  the plane normal.

Returns
---------
paths : (n, ) Path2D or None
  2D cross sections at specified heights.
  path.metadata['to_3D'] contains transform
  to return 2D section back into 3D space.
r   	load_path)r`   rL  rM  rX  Nr   )to_3Dr*  )rU   )exchange.loadr[  r   mesh_multiplaner   r  r  )rp   rM  rL  rX  r[  rT  
transformsrN   pathsrs  fsegmentsr;  s                rr   section_multiplaneTrimesh.section_multiplane3	  s    8 	- $1#@#@%%	$
 5 U#!$U3u:%6j!QA(8}q $XST8UV "R ru   capc           	      >    [         R                  " SU UUUUS.UD6nU$ )ah  
Slice the mesh with a plane, returning a new mesh that is the
portion of the original mesh to the positive normal side of the plane

plane_origin : (3,) float
  Point on plane to intersect with mesh
plane_normal : (3,) float
  Normal vector of plane to intersect with mesh
cap : bool
  If True, cap the result with a triangulated polygon
face_index : ((m,) int)
    Indexes of mesh.faces to slice. When no mask is
    provided, the default is to slice all faces.

Returns
---------
new_mesh: trimesh.Trimesh or None
  Subset of current mesh that intersects the half plane
  to the positive normal side of the plane
)r`   rL  rM  re  r*  r  )r   slice_mesh_plane)rp   rM  rL  re  r*  rq   new_meshs          rr   slice_planeTrimesh.slice_plane`	  s9    < !11 
%%!
 
 ru   imagec           	      >   SSK nUR                  U R                  U R                  5      u  p4n[	        U R                  U   U[        XQS9SS9n[        R                  (       Ga  [        R                  " UR                  R                  U5      (       d   e[        R                  " UR                  U5      (       d   e[        R                  " UR                  U R                  U   5      (       d   eUR                  SS9n[        R                  " [        R                  U5       Vs/ s H-  oR!                  S5      (       d  M  US	S R#                  5       PM/     sn[$        S
9n	[        R                  " X5      (       d   e[        R                  " [        R                  U5       Vs/ s H-  oR!                  S5      (       d  M  USS R#                  5       PM/     sn[$        S
9n
[        R                  " XR                  U   5      (       d   eU$ s  snf s  snf )a  
Returns a Trimesh object equivalent to the current mesh where
the vertices have been assigned uv texture coordinates. Vertices
may be split into as many as necessary by the unwrapping
algorithm, depending on how many uv maps they appear in.

Requires `pip install xatlas`

Parameters
------------
image : None or PIL.Image
  Image to assign to the material

Returns
--------
unwrapped : trimesh.Trimesh
  Mesh with unwrapped uv coordinates
r   N)r-  rk  Fr7  obj)	file_typezvt rF   rG   zv r   )xatlasparametrizerM   rN   rK   r=   r$   strictr   r   r   r-  exportr   str
splitlines
startswithr  r   )rp   rk  ro  vmaprN   r-  rZ  rr  Luv_reconv_recons              rr   unwrapTrimesh.unwrap	  s   & 	 ,,T]]DJJGR]]4(!R5	
 ::: ;;v}}//4444;;v||U3333;;vd0CDDDD ]]U]3Fxx(+v(>V(>1,,uBU12(>VH ;;x,,,,hh(+v(>U(>1,,tBT12(>UG ;;wd(;<<<< W
 Vs   )HH+HHc                 .    [         R                  " U 5      $ )z
Returns a Trimesh object representing the convex hull of
the current mesh.

Returns
--------
convex : trimesh.Trimesh
  Mesh of convex hull of current mesh
)r
   r  r   s    rr   r  Trimesh.convex_hull	  s     !!$''ru   rJ  face_weightc                 H    [         R                  " XUS9u  pEU(       a  XE4$ U$ )a  
Return random samples distributed across the
surface of the mesh

Parameters
------------
count : int
  Number of points to sample
return_index : bool
  If True will also return the index of which face each
  sample was taken from.
face_weight : None or len(mesh.faces) float
  Weight faces by a factor other than face area.
  If None will be the same as face_weight=mesh.area

Returns
---------
samples : (count, 3) float
  Points on surface of mesh
face_index : (count, ) int
  Index of self.faces
)r`   rJ  r~  )r   sample_surface)rp   rJ  r(  r~  samplesr,  s         rr   r   Trimesh.sample	  s-    8  ..
 >!ru   c                 :   [         R                  " [        U R                  5      [        S9nSXR
                  '   [         R                  " [        U R                  5      [        S9n[         R                  " UR                  5       5      X!'   U R                  XS9  g)zM
Remove all vertices in the current mesh which are not
referenced by a face.
rG   T)r   r6  N)
r   r   r   rM   rc  rN   r   rv  r_  rx  )rp   rd  r6  s      rr   remove_unreferenced_vertices$Trimesh.remove_unreferenced_vertices	  sk    
 XXc$--0=
!%
::((3t}}-U; ii
(89*>ru   c                    [         R                  " [        U R                  5      S-  [        S9R                  S5      nU R                  U R                  R                  S5      5        Xl        U R                  R                  S/S9  g)zp
Removes all face references so that every face contains
three unique vertex indices and no faces are adjacent.
rF   rG   rY  r  rO   rw   N)	r   rv  r   rN   r   r   rx  rd   r   )rp   rN   s     rr   unmerge_verticesTrimesh.unmerge_vertices	  sh     		#djj/A-U;CCGL 	TZZ//34
>"23ru   r	  c                    [         R                  " US[        S9nUR                  S:w  a  [	        S5      e[
        R                  " U[        S5      (       a  U $ [        R                  " U R                  US9n[
        R                  " USS2SS24   [        S	S
9(       + nSU R                  ;   a/  U R                  S   /n[        R                  " UU5      S   U l        U(       a[  SU R                  ;   aK  [
        R                  " [        R                  " U R                   USS95      U R                  R"                  S'   U(       a[  SU R                  ;   aK  [
        R                  " [        R                  " U R$                  USS95      U R                  R"                  S'   U(       aj  [        R&                  " U5      (       aO  [(        R*                  " S5        [         R,                  " [         R.                  " U R0                  5      5      U l        X l
        U R                  R3                  1 SkS9  U R                  R5                  5         U $ )a  
Transform mesh by a homogeneous transformation matrix.

Does the bookkeeping to avoid recomputing things so this function
should be used rather than directly modifying self.vertices
if possible.

Parameters
------------
matrix : (4, 4) float
  Homogeneous transformation matrix
r   r   )rI   rI   z%Transformation matrix must be (4, 4)!g:0yE>)r	  NrF   gư>)atolr   r   rO   F)r	  	translaterP   ztransform flips winding>   r+  rV  r)  r4  rM  r7  r`  rO   r  rP   r1  r[  r2  r  r  rw   )r   r   r   r   ro   r   r   
_IDENTITY4r   transform_pointsrM   
_IDENTITY3rb   r   rd   unitizerO   r  rP   flips_windingr#   r   ascontiguousarrayfliplrrN   r   id_set)rp   r	  r>  has_rotationr   s        rr   apply_transformTrimesh.apply_transform
  s    vS@ <<6!DEE ]]6:t44K '77fU  ==BQB$OO DJJ&::m45K.??   D Ndkk90400%%f1DKKn- ,;26,,00''%3DKK./ O99&AAII/0 --bii

.CDDJ % 	 	 	
( 	ru   pitchmethodc                 8    SSK Jn  UR                  " SXUS.UD6$ )a  
Return a VoxelGrid object representing the current mesh
discretized into voxels at the specified pitch

Parameters
------------
pitch : float
  The edge length of a single voxel
method: implementation key. See `trimesh.voxel.creation.voxelizers`
**kwargs: additional kwargs passed to the specified implementation.

Returns
----------
voxelized : VoxelGrid object
  Representing the current mesh
r   )creation)r`   r  r  r  )voxelr  voxelize)rp   r  r  rq   r  s        rr   	voxelizedTrimesh.voxelizedh
  s"    " 	$  QdQ&QQru   percent
face_count
aggressionc           
      >   SSK Jn  UUUS.nU" SU R                  R                  [        R
                  5      U R                  R                  [        R
                  5      S.UR                  5        VVs0 s H  u  pgUc  M
  Xg_M     snnD6u  p[        XS9$ s  snnf )a  
A thin wrapper around `pip install fast-simplification`.

Parameters
-----------
percent
  A number between 0.0 and 1.0 for how much
face_count
  Target number of faces desired in the resulting mesh.
aggression
  An integer between `0` and `10`, the scale being roughly
  `0` is "slow and good" and `10` being "fast and bad."

Returns
---------
simple : trimesh.Trimesh
  Simplified version of mesh.
r   )simplify)target_counttarget_reductionagg)pointsr   )rM   rN   r  )	fast_simplificationr  rM   r   r   r   rN   ry  rK   )
rp   r  r  r  r  rq   kvrM   rN   s
             rr   simplify_quadric_decimation#Trimesh.simplify_quadric_decimation}
  s    0 	1 ' '
 # 
==%%bjj1jjoobjj1
 !'@!tqt@
 66 As   5	BBface_idsc           	      2    SSK Jn  [        S0 U" X40 UD6D6$ )a   
Given a list of face indexes find the outline of those
faces and return it as a Path3D.

The outline is defined here as every edge which is only
included by a single triangle.

Note that this implies a non-watertight mesh as the
outline of a watertight mesh is an empty path.

Parameters
------------
face_ids : (n, ) int
  Indices to compute the outline of.
  If None, outline of full mesh will be computed.
**kwargs: passed to Path3D constructor

Returns
----------
path : Path3D
  Curve in 3D of the outline
r   )faces_to_pathr  )rQ  r  rE   )rp   r  rq   r  s       rr   outlineTrimesh.outline
  s    . 	6@d??@@ru   r  c                 ^    SSK Jn  SSKJn  SSKJn  U" SXS.UD6nUc  U" 5       $ U" U5      $ )a  
Project a mesh onto a plane and then extract the
polygon that outlines the mesh projection on that
plane.

Parameters
----------
normal : (3,) float
  Normal to extract flat pattern along
origin : None or (3,) float
  Origin of plane to project mesh onto
ignore_sign : bool
  Allow a projection from the normal vector in
  either direction: this provides a substantial speedup
  on watertight meshes where the direction is irrelevant
  but if you have a triangle soup and want to discard
  backfaces you should set this to False.
rpad : float
  Proportion to pad polygons by before unioning
  and then de-padding result by to avoid zero-width gaps.
apad : float
  Absolute padding to pad polygons by before unioning
  and then de-padding result by to avoid zero-width gaps.
tol_dot : float
  Tolerance for discarding on-edge triangles.
precise : bool
  Use the precise projection computation using shapely.
precise_eps : float
  Tolerance for precise triangle checks.

Returns
----------
projected : trimesh.path.Path2D
  Outline of source mesh
r   rZ  )rD   )	projected)r`   r  r  )r]  r[  rV  rD   path.polygonsr  )rp   r  rq   r[  rD   r  
projections          rr   r  Trimesh.projected
  s8    H 	- ,BDB6B
8O$$ru   c                 :    U R                   R                  5       nU$ )zj
Summed area of all triangles in the current mesh.

Returns
---------
area : float
  Surface area of mesh
)r   r_  )rp   areas     rr   r  Trimesh.area
  s     ""$ru   c                 >    [         R                  " U R                  S9$ )zd
The area of each face in the mesh.

Returns
---------
area_faces : (n, ) float
  Area of each face
)r   )r   r  r   r   s    rr   r   Trimesh.area_faces
  s     ~~d&:&:;;ru   c                     U R                   R                  R                  SS5      nU R                   R                  R                  SS5      n[        R                  " U R                  U R
                  UUSS9$ )a  
Returns the mass properties of the current mesh.

Assumes uniform density, and result is probably garbage if mesh
isn't watertight.

Returns
----------
properties : dict
  With keys:
  'volume'      : in global units^3
  'mass'        : From specified density
  'density'     : Included again for convenience (same as kwarg density)
  'inertia'     : Taken at the center of mass and aligned with global
                 coordinate system
  'center_mass' : Center of mass location, in global coordinate system
r   Nr   F)r   r   r   r   skip_inertia)rb   r   getr   r   r   )rp   r   r   s      rr   r   Trimesh.mass_properties  sd    ( **//%%i6jjoo))->((nn((#
 	
ru   c                    U R                      SU R                   ;   a  U R                   S   S-  U l        SU R                   ;   a  U R                   S   S-  U l        [        R                  " [        R
                  " U R                  5      5      U l        SSS5        U R                   R                  SS/S9  U $ ! , (       d  f       N+= f)z
Invert the mesh in-place by reversing the winding of every
face and negating normals without dumping the cache.

Alters `self.faces` by reversing columns, and negating
`self.face_normals` and `self.vertex_normals`.
rO   r  rP   Nrw   )rd   rO   rP   r   r  r  rN   r   r   s    rr   invertTrimesh.invert)  s     [[,$(KK$?$$F!4;;.&*kk2B&Cd&J#--bii

.CDDJ  	>3C"DE [s   BB::
Cc                     [        U 40 UD6$ )z
Returns a Scene object containing the current mesh.

Returns
---------
scene : trimesh.scene.scene.Scene
  Contains just the current mesh
r)   r  s     rr   sceneTrimesh.scene=  s     T$V$$ru   viewerc                 J    U R                  5       nUR                  " SSU0UD6$ )a  
Render the mesh in an opengl window. Requires pyglet.

Parameters
------------
viewer : ViewerType
  What kind of viewer to use, such as
  `gl` to open a pyglet window
  `jupyter` for a jupyter notebook
  `marimo'` for a marimo notebook
  None for a "best guess"
smooth : bool
  Run smooth shading on mesh or not,
  large meshes will be slow

Returns
-----------
scene : trimesh.scene.Scene
  Scene with current mesh in it
r  r  )r  show)rp   r  rq   r  s       rr   r  Trimesh.showH  s&    2 

zz22622ru   faces_sequenceonly_watertightr   c                 8    [         R                  " SU UUUS.UD6$ )a  
Return a subset of the mesh.

Parameters
------------
faces_sequence : sequence (m, ) int
  Face indices of mesh
only_watertight : bool
  Only return submeshes which are watertight
repair
  Try to repair the submesh if it is not watertight
append : bool
  Return a single mesh which has the faces appended.
  if this flag is set, only_watertight is ignored

Returns
---------
submesh : Trimesh or (n,) Trimesh
  Single mesh if `append` or list of submeshes
)r`   r  r  r   r  )r   submesh)rp   r  r  r   rq   s        rr   r  Trimesh.submeshd  s0    6 || 
)+	

 
 	
ru   c                 .    [         R                  " U 5      $ )z
Return a float vector which is unique to the mesh
and is robust to rotation and translation.

Returns
-----------
identifier : (7,) float
  Identifying properties of the current mesh
)r	   identifier_simpler   s    rr   
identifierTrimesh.identifier  s     ++D11ru   c                 B    [         R                  " U R                  5      $ )z
A hash of the rotation invariant identifier vector.

Returns
---------
hashed : str
  Hex string of the SHA256 hash from
  the identifier vector at hand-tuned sigfigs.
)r	   identifier_hashr  r   s    rr   r  Trimesh.identifier_hash  s     ))$//::ru   file_objrn  c                     [        SXUS.UD6$ )a  
Export the current mesh to a file object.
If file_obj is a filename, file will be written there.

Supported formats are stl, off, ply, collada, json,
dict, glb, dict64, msgpack.

Parameters
------------
file_obj : open writeable file object
  str, file name where to save the mesh
  None, return the export blob
file_type : str
  Which file type to export as, if `file_name`
  is passed this is not required.

Returns
----------
exported : bytes or str
  Result of exporter
)r`   r  rn  r  r&   )rp   r  rn  rq   s       rr   rr  Trimesh.export  s    6 W9WPVWWru   c                 n    SU R                   R                  5       U R                  R                  5       S.$ )a  
Return a dictionary representation of the current mesh
with keys that can be used as the kwargs for the
Trimesh constructor and matches the schema in:
`trimesh/resources/schema/primitive/trimesh.schema.json`

Returns
----------
result : dict
  Matches schema and Trimesh constructor.
trimesh)ru  rM   rN   )rM   tolistrN   r   s    rr   to_dictTrimesh.to_dict  s1     ,,.ZZ&&(
 	
ru   c                 n    [         R                  " U 40 UD6 Vs/ s H  n[        S0 UD6PM     sn$ s  snf )z
Compute an approximate convex decomposition of a mesh
using `pip install pyVHACD`.

Returns
-------
meshes
  List of convex meshes that approximate the original
**kwargs : VHACD keyword arguments
r  )r   convex_decompositionrK   r  s     rr   r  Trimesh.convex_decomposition  sA     (<<TLVL
L fL
 	
 
s   2enginecheck_volumec                 ^    [         R                  " S[        R                  " X5      UUS.UD6$ )a  
Boolean union between this mesh and other meshes.

Parameters
------------
other : Trimesh or (n, ) Trimesh
  Other meshes to union
engine
  Which backend to use, the default
  recommendation is: `pip install manifold3d`.
check_volume
  Raise an error if not all meshes are watertight
  positive volumes. Advanced users may want to ignore
  this check as it is expensive.
kwargs
  Passed through to the `engine`.

Returns
---------
union : trimesh.Trimesh
  Union of self and other Trimesh objects
meshesr  r  r  )r   unionr   chainrp   r  r  r  rq   s        rr   r  Trimesh.union  s6    : }} 
::d*%
 	
 	
ru   c                 ^    [         R                  " S[        R                  " X5      UUS.UD6$ )a  
Boolean difference between this mesh and other meshes.

Parameters
------------
other
  One or more meshes to difference with the current mesh.
engine
  Which backend to use, the default
  recommendation is: `pip install manifold3d`.
check_volume
  Raise an error if not all meshes are watertight
  positive volumes. Advanced users may want to ignore
  this check as it is expensive.
kwargs
  Passed through to the `engine`.

Returns
---------
difference : trimesh.Trimesh
  Difference between self and other Trimesh objects
r  r  )r   
differencer   r  r  s        rr   r  Trimesh.difference  s8    : !! 
::d*%
 	
 	
ru   c                 ^    [         R                  " S[        R                  " X5      UUS.UD6$ )a7  
Boolean intersection between this mesh and other meshes.

Parameters
------------
other : trimesh.Trimesh, or list of trimesh.Trimesh objects
  Meshes to calculate intersections with
engine
  Which backend to use, the default
  recommendation is: `pip install manifold3d`.
check_volume
  Raise an error if not all meshes are watertight
  positive volumes. Advanced users may want to ignore
  this check as it is expensive.
kwargs
  Passed through to the `engine`.

Returns
---------
intersection : trimesh.Trimesh
  Mesh of the volume contained by all passed meshes
r  r  )r   intersectionr   r  r  s        rr   r  Trimesh.intersection(  s8    : ## 
::d*%
 	
 	
ru   r  c                 8    U R                   R                  U5      $ )a)  
Given an array of points determine whether or not they
are inside the mesh. This raises an error if called on a
non-watertight mesh.

Parameters
------------
points : (n, 3) float
  Points in cartesian space

Returns
---------
contains : (n, ) bool
  Whether or not each point is inside the mesh
)r   contains_points)rp   r  s     rr   containsTrimesh.containsL  s      xx''//ru   c                 B    [         R                  " U R                   5      $ )z
Returns the angle at each vertex of a face.

Returns
--------
angles : (len(self.faces), 3) float
  Angle at each vertex of a face
)r   r  r   s    rr   r   Trimesh.face_angles^  s     //ru   c                 2    [         R                  " U 5      nU$ )z
A sparse matrix representation of the face angles.

Returns
----------
sparse : scipy.sparse.coo_matrix
  Float sparse matrix with with shape:
  (len(self.vertices), len(self.faces))
)r   face_angles_sparse)rp   r  s     rr   r  Trimesh.face_angles_sparsej  s     --d3ru   c                 2    [         R                  " U 5      nU$ )aQ  
Return the vertex defects, or (2*pi) minus the sum of the angles
of every face that includes that vertex.

If a vertex is only included by coplanar triangles, this
will be zero. For convex regions this is positive, and
concave negative.

Returns
--------
vertex_defect : (len(self.vertices), ) float
  Vertex defect at the every vertex
)r   vertex_defects)rp   defectss     rr   r  Trimesh.vertex_defectsx  s     **40ru   c                 |    [         R                  " U R                  R                  SS95      R	                  5       nU$ )z
Return the number of faces each vertex is included in.

Returns
----------
degree : (len(self.vertices), ) int
  Number of faces each vertex is included in
r   r   )r   r   r   r_  flatten)rp   degrees     rr   vertex_degreeTrimesh.vertex_degree  s4     $++//Q/78@@Bru   c           	          [         R                  " [        R                  " U R                  U R
                     R                  SS9U R                  U R
                     R                  SS945      5      $ )zy
An R-tree of face adjacencies.

Returns
--------
tree
  Where each edge in self.face_adjacency has a
  rectangular cell
r   r   )r   r   r   column_stackrM   r  r   r   r   s    rr   face_adjacency_treeTrimesh.face_adjacency_tree  sh     OOMM$";";<@@a@HMM$";";<@@a@H
 	
ru   include_cacheinclude_visualc           
      
   [        5       n[        U R                  R                  5      UR                  l        U(       a  U R                  R                  5       Ul        UR                  R                  U R                  R                  5        VVs0 s H  u  pEU[        U5      _M     snn5        UR                  R                  U R                  R                  5        VVs0 s H  u  pEU[        U5      _M     snn5        [        U R                  5      Ul
        UR                  R                  5         U(       a9  UR                  R                  R                  U R                  R                  5        U$ s  snnf s  snnf )a  
Safely return a copy of the current mesh.

By default, copied meshes will have emptied cache
to avoid memory issues and so may be slow on initial
operations until caches are regenerated.

Current object will *never* have its cache cleared.

Parameters
------------
include_cache : bool
  If True, will shallow copy cached data to new mesh
include_visual : bool
  If True, will copy visual information

Returns
---------
copied : trimesh.Trimesh
  Copy of current mesh
)rK   r   rb   r   r   r  rT   re   ry  rS   rU   rd   r  r  )rp   r  r  copiedr  r  s         rr   r  Trimesh.copy  s   . $TZZ__5 KK,,.FM$$++,0,B,B,H,H,JK,JDAHQK,JK "")),0,@,@,F,F,HI,HDAHQK,HI
 #4==1 	 MM&&t{{'8'89) L Js   E9
#E?
c                      U R                  SS9$ )NFr  r  rp   argss     rr   __deepcopy__Trimesh.__deepcopy__  s    yyuy--ru   c                      U R                  SS9$ )NTr  r  r  s     rr   __copy__Trimesh.__copy__  s    yyty,,ru   	statementc                     [        U5      /nUR                  S U 5       5        S[        [        U5      5       3nX@R                  ;   a  U R                  U   $ [	        U5      nXPR                  U'   U$ )a  
Evaluate a statement and cache the result before returning.

Statements are evaluated inside the Trimesh object, and

Parameters
------------
statement : str
  Statement of valid python code
*args : list
  Available inside statement as args[0], etc

Returns
-----------
result : result of running eval on statement with args

Examples
-----------
r = mesh.eval_cached('np.dot(self.vertices, args[0])', [0, 0, 1])
c              3   8   #    U  H  n[        U5      v   M     g 7fN)rC  ).0as     rr   	<genexpr>&Trimesh.eval_cached.<locals>.<genexpr>  s     .AQs   eval_cached_)rC  extendtuplerd   eval)rp   r  r  hashabler|  rZ  s         rr   eval_cachedTrimesh.eval_cached  sk    , O$...T%/234++;;s##i!Cru   c                 2    [         R                  " X5      nU$ )z
Concatenate the mesh with another mesh.

Parameters
------------
other : trimesh.Trimesh object
  Mesh to be concatenated with self

Returns
----------
concat : trimesh.Trimesh
  Mesh object of combined result
)r   r  )rp   r  concats      rr   __add__Trimesh.__add__  s     !!$.ru   )rd   rb   rI  r   rS   rO   rN   rU   rl   r   r   rT   rP   rM   r   )NNNNNNNNNTFNNTNN)FNN)F)NNNNNr  )r\   N)Nr  r   r  r  )
   F)r\   rK   )FN)r/  )NNN)FF)NT)FT)r  rK   r\   rK   )__name__
__module____qualname____firstlineno__r6   r-   r/   rs  r,   rc  r   r:   r<   r=   rs   r7   rV   propertyr   setterr!   rN   r"   r?   r   r4   r   rO   rM   rP   r   r   r   r   r   r   r   r   r5   r   r   r   r   r  r   r  r  r  r  r   rC   r!  r   r   r+  r)  r7  r?  r2  r4  r@   rG  rM  r^  rV  r[  r`  r   bool_r   rj  r1   r   rx  r}   r  r   r{   r  r2   r  r  r  r  r  r  r  r  r  r  r  r  rA   r  r  r  r  r  rz   r  r  r$   r   r0   r|   r  r  r   r  r
  r  r~   r  r(   r9   r"  r(  r/  r8  r=  rF  r   rE   r  rD   rc  ri  rB   rz  r  r   r  r  r  r  r  r  r  r  r   r+   r   r  r*   r  r;   r  r8   r  r  r  r3   bytesrr  r  r  r.   r  r  r  r  r   r  r  r   r  r  r  r  r"  r&  __static_attributes__r  ru   rr   rK   rK   e   sM    )-%),0.2+/-1:><@-1$(%)6:@D#[X9%[X 	"[X y)	[X
 !+[X i([X  	*[X "$sI~"67[X $Di$89[X 4S>*[X [X [X D>[X TN[X [X   S'\ 23![X" |^;<=#[X& 
'[X~ $(%)	:: D>: TN	:
 
:x 	" 	" 	" ^^	#T 	#d 	# 	# #| # #  \\%HY/ %D % %, Uj U U 1gg. 1 1f %-8I#6 %-4 %- %-N &, & &" __Qx	2 Qt Q Q 
 0 
 
. 7Y 74 7 7" gen  $ D!12 D D$ ''"23  $ ''*  . 	0WW- 	0 	0 . .t . . 	3 	3 	3 ^^.V . . . + + + 
)g 
) 
) , 0 , ,"$
i $
GG<L $
L gg.>  $ 877+; 8 8 WW-=  0 (3-   ,x(89 , , /(77+;"< / / :77+ : : 	5 	5 	5 	+''"2 	+ 	+ 
!1 
 
 wu~   
)GEN 
) 
) gen  " WW%5   3gen 3 3  
gen 
 
 
*7 
* 
* j   C  $ GEN  B 
c 
 
 WRXX%6  S  $ , %)%)+/)-'+"
D>"
 TN"
  (	"

 g&"
 G$"
 
"
N (,BB )$B 
	BH25 25t 25hG1i G1R."gbhh/ 6+i +B % % %N 	-75> 	- 	- 3gen 3 3 
27 
2 
2 ww'7  : GG,<   ;wrxx'8 ; ; 
3 
3 
3 
ww'7 
 
 2WW%5 2 2 3 3 3$ 7 7 70 V$tE{"3 V V, 4t 4 4" t  $ 
4 
 
( 	%$ 	% 	% 4   
7 
7 
7 69YY 
( 
7288CT 
8 
WU^, 
 
 WW-  $ ww/  2 
,ww/ 
, 
, gen!5     1  @Xd^ t (	'D 	'#:w./#	ww(	)#B 37!6
gg./6
 6
 	6

 6
 
ww!11	26
r W[N"9-NBJ7BSN	Nb NSFF*1FFJF	y%	75> 9::	;FPN'): Ni N4  6 |^'C!DE   ]]HU<+G%HI d  +%+5>+	&	+Z++  + 	+
 
hv	+b *.''  ' 	'
 Y'' 
'R3E 3Y 3j 
( 
( #26	!! ! gg./	!F?4 [i [D [zRx1 R3 R. '+(,(,	+7(#+7 W%+7 W%	+7
 
+7ZA 8 Af A6+%	 +% +%Z 
g 
 
 	<GG, 	< 	< 
 
 
: (	% 	% "33 
	3> !&	!
 +!
 !
 	!
 
y$y/)	*!
F 
2GG, 
2 
2 
; 
; 
; "#'XX C=X
 
tUC	 X:
c5d4;.?d3i)P#QQR 
$
Y 
& %)!	"
Y 334"
 ""
 	"
 
"
N %)!	"
Y 334"
 ""
 	"
 
"
N %)!	"
Y 334"
 ""
 	"
 
"
H0y 0WRXX-> 0$ 	0WW- 	0 	0 J    0  " wu~   
U 
 
(4$ 4 4PY 4l.- S  C  Dru   rK   )Z__doc__r  r   numpyr   r   r   r    r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   cachingr   r    r!   r"   	constantsr#   r$   
exceptionsr%   exchange.exportr'   parentr(   r  r*   r+   typedr,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   scipy.sparser?   scipy.spatialr@   r   EnetworkxrA   PILrB   rtree.indexrC   rV  rD   rE   r   r  flags	writeabler  rK   r  ru   rr   <module>rC     s     ) )      2 E D  ( (   %    $ @ ?%'%   !!$ VVARZZ(
"
   VVARZZ(
"
   w2j w2?  %q!G!!$J%
   QE 
   QE 
   QE 
  !a Fa F!sx   *D8 7E >E6 F F, 8E>EEE3!E..E36F<F		FF)F$$F),G2GG