
    Mi.                         S r SSKrSSKrSSKJr  SSK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JrJrJrJrJrJr  SSKJr  \ " S S5      5       r " S S\5      r " S S\5      rg)zT
parent.py
-------------

The base class for Trimesh, PointCloud, and Scene objects
    N)	dataclass   )boundscaching)transformations)cache_decorator)tol)ResolverLike)Any	ArrayLikeDictNDArrayOptionalfloat64)ABCc                       \ rS rSr% SrSr\\   \S'   Sr	\\
   \S'   Sr\\
   \S'   Sr\\S'   Sr\\   \S	'   \S
\\
   4S j5       rS
\4S jrS rSrg)
LoadSource   zC
Save information about where a particular object was loaded from.
Nfile_obj	file_type	file_pathF
was_openedresolverreturnc                 p    U R                   c  g[        R                  R                  U R                   5      $ )z
Get just the file name from the path if available.

Returns
---------
file_name
  Just the file name, i.e. for file_path="/a/b/c.stl" -> "c.stl"
N)r   ospathbasenameselfs    h/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/trimesh/parent.py	file_nameLoadSource.file_name-   s*     >>!ww//    c                 |    U R                   R                  5        VVs0 s H  u  pXS:w  a  UOS _M     snn$ s  snnf )Nr   )__dict__items)r    kvs      r!   __getstate__LoadSource.__getstate__;   s9     ?Cmm>Q>Q>ST>SdaZ1T1>STTTs   8c                 4    [        S0 U R                  5       D6$ )N )r   r*   )r    argss     r!   __deepcopy__LoadSource.__deepcopy__@   s    0D--/00r$   r-   )__name__
__module____qualname____firstlineno____doc__r   r   r   __annotations__r   strr   r   boolr   r
   propertyr"   r   r*   r/   __static_attributes__r-   r$   r!   r   r      s    
 #Hhsm"  $Ix}#  $Ix}# J (,Hh|$+08C= 0 0Ud U
1r$   r   c                      \ rS rSr% Sr\\S'   \S\4S j5       r	\\
R                  S\4S j5       5       r\\
R                  S\\R                      4S j5       5       r\\
R                  S\\R                      4S j5       5       r\
R                  S	\S\4S
 j5       r\\
R                  S\4S j5       5       rS r\
R                  S 5       r\
R                  S 5       r\
R                  S 5       r\
R                  SS j5       rS\4S jrS\4S jrS rS r \!S\"4S j5       r#\S\$\   4S j5       r%\%RL                  S\SS4S j5       r%Sr'g)GeometryD   z
`Geometry` is the parent class for all geometry.

By decorating a method with `abc.abstractmethod` it means
the objects that inherit from `Geometry` MUST implement
those methods.
metadatar   c                 \    [        U SS5      nUb  U$ [        5       U l        U R                  $ )z
Where and what was this current geometry loaded from?

Returns
--------
source
  If loaded from a file, has the path, type, etc.
_sourceN)getattrr   r@   )r    currents     r!   sourceGeometry.sourceP   s0     $	40N!|||r$   c                     g Nr-   r   s    r!   identifier_hashGeometry.identifier_hashc        	r$   c                     g rF   r-   r   s    r!   r   Geometry.boundsh   rI   r$   c                     g rF   r-   r   s    r!   extentsGeometry.extentsm   rI   r$   matrixc                     g rF   r-   )r    rO   s     r!   apply_transformGeometry.apply_transformr       r$   c                     g rF   r-   r   s    r!   is_emptyGeometry.is_emptyv   rI   r$   c                 6    U R                   R                  5       $ )zc
Get a hash of the current geometry.

Returns
---------
hash
  Hash of current graph and geometry.
)_data__hash__r   s    r!   rY   Geometry.__hash__{   s     zz""$$r$   c                     g rF   r-   r   s    r!   copyGeometry.copy   rS   r$   c                     g rF   r-   r   s    r!   showGeometry.show   rS   r$   c                     g rF   r-   r    others     r!   __add__Geometry.__add__   rS   r$   Nc                     g rF   r-   )r    r   r   s      r!   exportGeometry.export   rS   r$   c                    / n[        U S5      (       a(  UR                  SU R                  R                   35        [        U S5      (       a(  UR                  SU R                  R                   35        [        U S5      (       aF  [        U R                  [        5      (       a'  UR                  S[        U R                  5       35        S[        U 5      R                  ;   a'  UR                  [        U R                  5      SS	 5        S
U R                  ;   a$  U R                  S
   nUR                  SU S35        SR                  [        U 5      R                  SR                  U5      5      $ )z
Print quick summary of the current geometry without
computing properties.

Returns
-----------
repr : str
  Human readable quick look at the geometry.
verticeszvertices.shape=faceszfaces.shape=geometryzlen(geometry)=Voxelr   r"   zname=``z<trimesh.{}({})>z, )hasattrappendrj   shaperk   
isinstancerl   dictlentyper1   r7   r>   formatjoin)r    elementsdisplays      r!   __repr__Geometry.__repr__   s    4$$OOodmm.A.A-BCD4!!OOl4::+;+;*<=>4$$DMM4)H)HOOnS-?,@ABd4j)))OOC

OAb12$--'mmK0GOOfWIQ/0!((d)<)<dii>QRRr$   translationc                 B   [         R                  " U[         R                  S9nUR                  S:X  a#  U R	                  [
        R                  " US95      $ UR                  S:w  a  [        S5      e[         R                  " S5      nXSS2S4'   U R	                  U5      $ )	zb
Translate the current mesh.

Parameters
----------
translation : (3,) float
  Translation in XYZ
)dtype)   )offset)   z!Translation must be (3,) or (2,)!   Nr   )	np
asanyarrayr   rr   rQ   tfplanar_matrix
ValueErroreye)r    r}   rO   s      r!   apply_translationGeometry.apply_translation   s     mmKrzzB$''(8(8(LMM$&@AA #rr1u##F++r$   c                 L    [         R                  " US9nU R                  U5      $ )zj
Scale the mesh.

Parameters
----------
scaling : float or (3,) float
  Scale factor to apply to the mesh
)scale)r   scale_and_translaterQ   )r    scalingrO   s      r!   apply_scaleGeometry.apply_scale   s%     ''g6##F++r$   c                 R    US:X  a  U $ U R                  [        U 5      " U5      5      $ )z
Concatenate the geometry allowing concatenation with
built in `sum()` function:
  `sum(Iterable[trimesh.Trimesh])`

Parameters
------------
other : Geometry
  Geometry or 0

Returns
----------
concat : Geometry
  Geometry of combined result
r   )rd   rv   rb   s     r!   __radd__Geometry.__radd__   s(    " A:K||DJu-..r$   c                     U R                   c  g[        U R                   S-  R                  5       S-  5      nU[        R                  :  a  gU$ )ah  
A loosely specified "order of magnitude scale" for the
geometry which always returns a value and can be used
to make code more robust to large scaling differences.

It returns the diagonal of the axis aligned bounding box
or if anything is invalid or undefined, `1.0`.

Returns
----------
scale : float
  Approximate order of magnitude scale of the geometry.
g      ?r   g      ?)rM   floatsumr	   zero)r    r   s     r!   r   Geometry.scale   sG      << t||Q++-45388r$   c                 :    U R                   R                  SS5      $ )zt
Definition of units for the mesh.

Returns
----------
units : str
  Unit system mesh is in, or None if not defined
unitsN)r>   getr   s    r!   r   Geometry.units  s     }}  $//r$   valuec                 l    [        U5      R                  5       R                  5       U R                  S'   g)z'
Define the units of the current mesh.
r   N)r7   lowerstripr>   )r    r   s     r!   r   r     s(    
 "%U!1!1!3!9!9!;gr$   )r@   rF   )(r1   r2   r3   r4   r5   r   r6   r9   r   rC   abcabstractmethodr7   rG   r   r   r   r   rM   r   r   rQ   r8   rU   rY   r\   r_   rd   rg   r{   r   r   r   r   r   r   r   r   setterr:   r-   r$   r!   r<   r<   D   s    N
  $     

+    ,    	i C   $   	% 	  	  	  	 S# S8,Y ,*,/. u  2 	0x} 	0 	0 \\<3 <4 < <r$   r<   c                       \ rS rSrSr\R                  S 5       r\R                  S 5       r\R                  S 5       r	\R                  S 5       r
\R                  S 5       rS\\   4S	 jrS
rg)
Geometry3Di  z
The `Geometry3D` object is the parent object of geometry objects
which are three dimensional, including Trimesh, PointCloud,
and Scene objects.
c                     SSK Jn  [        R                  " S5      nU R                  R                  SS9USS2S4'   UR                  X R                  SS	9$ )
z
An axis aligned bounding box for the current mesh.

Returns
----------
aabb : trimesh.primitives.Box
  Box object with transform and extents defined
  representing the axis aligned bounding box of the mesh
r   )
primitivesr   r   )axisNr   F	transformrM   mutable) r   r   r   r   meanBoxrM   )r    r   r   s      r!   bounding_boxGeometry3D.bounding_box   sP     	!FF1I	;;+++3	"1"a%~~	<<QV~WWr$   c                     SSK JnJn  UR                  " U 5      u  p4UR	                  [
        R                  R                  U5      USS9$ )z
An oriented bounding box for the current mesh.

Returns
---------
obb : trimesh.primitives.Box
  Box object with transform and extents defined
  representing the minimum volume oriented
  bounding box of the mesh
r   r   r   Fr   )r   r   r   oriented_boundsr   r   linalginv)r    r   r   	to_originrM   s        r!   bounding_box_oriented Geometry3D.bounding_box_oriented3  sD     	)#33D9	~~iimmI.  
 	
r$   c                 X    SSK JnJn  UR                  U 5      u  p4UR	                  X4SS9$ )a  
A minimum volume bounding sphere for the current mesh.

Note that the Sphere primitive returned has an unpadded
exact `sphere_radius` so while the distance of every vertex
of the current mesh from sphere_center will be less than
sphere_radius, the faceted sphere primitive may not
contain every vertex.

Returns
--------
minball : trimesh.primitives.Sphere
  Sphere primitive containing current mesh
r   )nspherer   F)centerradiusr   )r   r   r   minimum_nsphereSphere)r    r   r   r   r   s        r!   bounding_sphereGeometry3D.bounding_sphereF  s/      	* 006  u MMr$   c                 ^    SSK JnJn  UR                  " U 5      nUR                  " SSS0UD6$ )z
A minimum volume bounding cylinder for the current mesh.

Returns
--------
mincyl : trimesh.primitives.Cylinder
  Cylinder primitive containing current mesh
r   r   r   Fr-   )r   r   r   minimum_cylinderCylinder)r    r   r   kwargss       r!   bounding_cylinderGeometry3D.bounding_cylinder[  s0     	)((."";5;F;;r$   c                     U R                   U R                  U R                  /n[        R                  " U Vs/ s H  o"R
                  PM     sn5      nX   $ s  snf )z
The minimum volume primitive (box, sphere, or cylinder) that
bounds the mesh.

Returns
---------
bounding_primitive : object
  Smallest primitive which bounds the mesh:
  trimesh.primitives.Sphere
  trimesh.primitives.Box
  trimesh.primitives.Cylinder
)r   r   r   r   argminvolume)r    optionsi
volume_mins       r!   bounding_primitiveGeometry3D.bounding_primitivej  sU     &&  ""

 YY':'Q':;
""  ;s   Ar   c                    [         R                  (       a  [        U S5      (       a  U R                  n[        R
                  " U 40 UD6u  p4U R                  U5        [         R                  (       as  [        U S5      (       a:  [        U SS5      (       a(  [        R                  " U R                  W5      (       d   e[        R                  " U R                  U5      (       d   eU$ )ah  
Apply the oriented bounding box transform to the current mesh.

This will result in a mesh with an AABB centered at the
origin and the same dimensions as the OBB.

Parameters
------------
kwargs
  Passed through to `bounds.oriented_bounds`

Returns
----------
matrix : (4, 4) float
  Transformation matrix that was applied
  to mesh to move it into OBB frame
r   is_watertightF)r	   strictrp   r   r   r   rQ   rA   r   iscloseallcloserM   )r    r   r   rO   rM   s        r!   	apply_obbGeometry3D.apply_obb  s    & ::'$11[[F !00@@V$::tX&&74%+P+Pzz$++v6666;;t||W5555r$   r-   N)r1   r2   r3   r4   r5   r   r   r   r   r   r   r   r   r   r   r:   r-   r$   r!   r   r     s     X X$ 
 
$ N N( < < # #*"WW%5 "r$   r   )r5   r   r   dataclassesr   numpyr   r   r   r   r   r   r   	constantsr	   	resolversr
   typedr   r   r   r   r   r   utilr   r   r<   r   r-   r$   r!   <module>r      sg     	 !   # $  # C C  )1 )1 )1XR<s R<jI Ir$   