
    j                        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 	 	 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jE                         D         e e d                  ed<   ejG                         D  ch c]  \  } } e|e      r|  c}} Z$y# e$ rZ ee      Z ee      ZY dZ[
dZ[ww xY wc c}} w )z]
boolean.py
-------------

Do boolean operations on meshes using either Blender or Manifold.
    N   )
interfaces)ExceptionWrapper)reduce_cascade)BooleanEngineTypeBooleanOperationTypeCallableDictSequence)ManifoldMesh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       </DATA/.local/lib/python3.12/site-packages/trimesh/boolean.pyr   r      s+    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   s+    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   s+    6 F(|GM r   r   c                    |rt        d | D              st        d      | D cg c]s  }t        t        t	        j
                  |j                  t        j                        t	        j
                  |j                  t        j                                    u }}|dk(  rZt        |       dk  rt        d      t        |       dk(  r|d	   |d
   z
  }n\t        |       dkD  rNt        d |d
d       }|d	   |z
  }n5|dk(  rt        d |      }n"|dk(  rt        d |      }nt        d| d      d
dlm} j                         }	 ||	j                  |	j                   d      S c c}w )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   4   K   | ]  }|j                     y wN)	is_volume).0ms     r   	<genexpr>z#boolean_manifold.<locals>.<genexpr>   s     <VVs   zNot all meshes are volumes!)dtype)vert_properties	tri_verts)meshr      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!   r,   r-   s     r   r0   z"boolean_manifold.<locals>.<lambda>       a!er   r   c                     | |z  S r!   r,   r-   s     r   r0   z"boolean_manifold.<locals>.<lambda>   r2   r   zInvalid boolean operation: '')TrimeshF)verticesfacesprocess)all
ValueErrorr   r   nparrayr6   float32r7   uint32lenr    r5   to_meshr'   r(   )
r   r   r   r   r)   	manifoldsresult_manifoldunionedr5   result_meshs
             r   boolean_manifoldrF   w   sc   , C<V<<677  D 	 "bjj I((4::RYY?	
    L v;?GHH[A'lYq\9O[1_$%712GG'lW4O	g	();YG	n	$();YG7	{!DEE !))+K,,K4I4ISX Es   A8E'r   manifoldblenderz`blender` is not in `PATH`c              #   B   K   | ]  }t        |t              r|  y wr!   )
isinstancer   )r#   vs     r   r%   r%      s     I!1A7G)HQ!s   zANo boolean backend: `pip install manifold3d` or install `blender`)NT)T)%__doc__numpyr;   r@   r   
exceptionsr   	iterationr   typedr   r   r	   r
   r   
manifold3dr   r   BaseExceptionEboolr   r   r   rF   r   str__annotations__rJ   rH   existsbooleanImportErrornextvaluesitemsengines_available)krK   s   00r   <module>r_      s     ( % T T#) !% F !% D !% F >>#> >D !#$sH}
 "h()#HZ ,HZ $,,44HY +;7S+TUHY I!IWX ..""$!Q*Q8H*IA" C  #AD"H#Bs#   D  EE E %D;;E 