
    Ti                        U d Z ddlZddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZmZmZ 	 ddlmZmZ n(# e$ r Z ee          Z ee          ZY dZ[ndZ[ww xY w	 	 dd
ede
defdZ	 	 dd
ede
defdZ	 	 dd
ede
defdZ	 dd
ededefdZi Zeeef         ed<    eee          reed<   need<   ej        j        rej        j        ed<   n e e d                    ed<    e!d e"                                D              e e d                              ed<   d e#                                D             Z$dS )z]
boolean.py
-------------

Do boolean operations on meshes using either Blender or Manifold.
    N   )
interfaces)ExceptionWrapper)reduce_cascade)BooleanEngineTypeBooleanOperationTypeCallableDictSequence)ManifoldMeshTmeshesenginecheck_volumec                 .    t          |         | fd|d|S )a/  
    Compute the boolean difference between a mesh an n other meshes.

    Parameters
    ----------
    meshes : sequence of trimesh.Trimesh
      Meshes to be processed.
    engine
      Which backend to use, i.e. 'blender' or 'manifold'
    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
      A `Trimesh` that contains `meshes[0] - meshes[1:]`
    
difference	operationr   _enginesr   r   r   kwargss       I/DATA/AppData/hermes/venv/lib/python3.11/site-packages/trimesh/boolean.pyr   r      s5    8 F&\ EK      c                 .    t          |         | fd|d|S )a-  
    Compute the boolean union between a mesh an n other meshes.

    Parameters
    ----------
    meshes : list of trimesh.Trimesh
      Meshes to be processed
    engine : str
      Which backend to use, i.e. 'blender' or 'manifold'
    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
      A `Trimesh` that contains the union of all passed meshes.
    unionr   r   r   s       r   r   r   7   s5    6 F! @F  r   c                 .    t          |         | fd|d|S )a5  
    Compute the boolean intersection between a mesh and other meshes.

    Parameters
    ----------
    meshes : list of trimesh.Trimesh
      Meshes to be processed
    engine : str
      Which backend to use, i.e. 'blender' or 'manifold'
    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
      A `Trimesh` that contains the intersection geometry.
    intersectionr   r   r   s       r   r   r   W   s5    6 F(| GM  r   r   c                 b   |r(t          d | D                       st          d          d | D             }|dk    rt          |           dk     rt          d          t          |           dk    r|d         |d         z
  }n{t          |           dk    r$t          d	 |dd
                   }|d         |z
  }nC|dk    rt          d |          }n+|dk    rt          d |          }nt          d| d          ddlm} |                                } ||j        |j        d          S )a  
    Run an operation on a set of meshes using the Manifold engine.

    Parameters
    ----------
    meshes : list of trimesh.Trimesh
      Meshes to be processed
    operation
      Which boolean operation to do.
    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`.
    c              3   $   K   | ]}|j         V  d S N)	is_volume).0ms     r   	<genexpr>z#boolean_manifold.<locals>.<genexpr>   s$      <<<<<<<<r   zNot all meshes are volumes!c                     g | ]g}t          t          t          j        |j        t          j                   t          j        |j        t          j                                       hS ))dtype)vert_properties	tri_verts)mesh)r   r   nparrayverticesfloat32facesuint32)r#   r*   s     r   
<listcomp>z$boolean_manifold.<locals>.<listcomp>   sw         	 "bj I I I(4:RY???  	
 	
 	
  r   r      z(Difference only defined over two meshes.r   r   c                     | |z   S r!    abs     r   <lambda>z"boolean_manifold.<locals>.<lambda>   s
    !a% r   Nr   c                     | |z   S r!   r4   r5   s     r   r8   z"boolean_manifold.<locals>.<lambda>   
    a!e r   r   c                     | |z  S r!   r4   r5   s     r   r8   z"boolean_manifold.<locals>.<lambda>   r:   r   zInvalid boolean operation: '')TrimeshF)r-   r/   process)	all
ValueErrorlenr    r=   to_meshr(   r)   )	r   r   r   r   	manifoldsresult_manifoldunionedr=   result_meshs	            r   boolean_manifoldrH   w   s   ,  8C<<V<<<<< 86777    I L  v;;??GHHH[[A'lYq\9OO[[1__$%7%7122GGG'lW4O	g		(););YGG	n	$	$(););YGGD	DDDEEE !))++K7,K4ISX   r   r   manifoldblenderz`blender` is not in `PATH`c              #   D   K   | ]}t          |t                    |V  d S r!   
isinstancer   )r#   vs     r   r%   r%      s2      II1A7G)H)HIQIIIIIIr   zANo boolean backend: `pip install manifold3d` or install `blender`c                 B    h | ]\  }}t          |t                    |S r4   rL   )r#   krN   s      r   	<setcomp>rQ      s<       
!Q*Q8H*I*I  r   )NT)T)%__doc__numpyr+   rB   r   
exceptionsr   	iterationr   typedr   r   r	   r
   r   
manifold3dr   r   BaseExceptionEboolr   r   r   rH   r   str__annotations__rM   rJ   existsbooleanImportErrornextvaluesitemsengines_availabler4   r   r   <module>rd      s               ( ( ( ( ( ( % % % % % % T T T T T T T T T T T T T T#))))))))) # # #AD""HHHHHH# !%     F !%     D !%     F > >>#> > > > >D !#$sH}
 " " ":h()) ,#HZ ,HZ  V$,4HY +*;;7S+T+TUUHY II!!IIIWXX   ..""     s   2 AAA