
    j`                     b   d dl 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
 ddlmZ  ej                         d	k(  re j                  j                  d
d      j!                  d      D  cg c]  }  e|       d kD  s|  c} ZdD ]  Ze j(                  j+                  ed      Ze j(                  j-                  e      s; e j.                  e      D ]2  Zdev sej3                  e j(                  j+                  ee             4  dj+                   ee            Z ej6                  de       n ej                         dk(  re j                  j                  d
d      j!                  d      D  cg c]  }  e|       d kD  s|  c} Zej9                  g d       dj+                   ee            Z ej6                  de       ne j                  j                  d
d      Z ej:                  de      ZeduZddddZ	 	 	 	 	 d$de
de	de de de de fd Z!	 d%d!e"d"e"de fd#Z#yc c} w c c} w )&    N   )util)log)
get_string)BooleanOperationTypeIterable   )
MeshScriptWindowsPATH ;)zC:\Program FileszC:\Program Files (x86)zBlender FoundationBlenderzsearching for blender in: %sDarwin:)z(/Applications/blender.app/Contents/MacOSz(/Applications/Blender.app/Contents/MacOSz0/Applications/Blender/blender.app/Contents/MacOSblender)pathUNION
DIFFERENCE	INTERSECT)union
differenceintersectionmeshes	operation	use_exactuse_selfdebugcheck_volumec                 t   t         st        d      |rt        d | D              st        d      |j                         j	                         }|t
        vr$t        d| dt
        j                          d      |rd}nd}t        d      }|j                  d	t
        |         j                  d
|      j                  d|       }	t        | |	|      5 }
|
j                  t        dz         }ddd       t        j                        }|D ]	  }d|_         t        j                  |      S # 1 sw Y   AxY w)a  
    Run a boolean operation with multiple meshes using Blender.

    Parameters
    -----------
    meshes
      List of mesh objects to be operated on
    operation
      Type of boolean operation ("difference", "union", "intersect").
    use_exact
      Use the "exact" mode as opposed to the "fast" mode.
    use_self
      Whether to consider self-intersections.
    debug
      Provide additional output for troubleshooting.
    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.

    Returns
    ----------
    result
      The result of the boolean operation on the provided meshes.
    No blender available!c              3   4   K   | ]  }|j                     y w)N)	is_volume).0ms     G/DATA/.local/lib/python3.12/site-packages/trimesh/interfaces/blender.py	<genexpr>zboolean.<locals>.<genexpr>T   s     <VVs   zNot all meshes are volumes!`z` is not a valid boolean: `EXACTFASTz!templates/blender_boolean.py.tmplz
$OPERATIONz$SOLVER_OPTIONSz	$USE_SELF)r   scriptr    --background --python $SCRIPTN)exists
ValueErroralllowerstrip_blender_boolkeysr   replacer
   run_blender_executabler   make_sequenceface_normalsconcatenate)r   r   r   r   r   r   keysolver_optionstemplater+   blendresultr%   s                r&   booleanr?   1   s5   B 011C<V<<677 //

!
!
#C
-	{5m6H6H6J5K1M
 	
   =>H
 	}S'9:	"N	3	
	, 
 
6&	>%.1QQR 
? 'F  F## 
?	>s   D..D7angle_limitisland_marginc                 F   t         st        d      t        d      }|j                  d|d      j                  d|d      }t	        | g|d|      5 }|j                  t        dz         }d	d	d	       t        j                        D ]	  }d	|_	         |S # 1 sw Y   ,xY w)
z0
    Run an unwrap operation using blender.
    r!   z$templates/blender_unwrap.py.templatez$ANGLE_LIMITz.6fz$ISLAND_MARGINobj)r   r+   exchanger   r,   N)
r-   r.   r   r4   r
   r5   r6   r   r7   r8   )	meshr@   rA   r   r<   r+   r=   r>   r%   s	            r&   unwraprF   x   s     011 @AHnS0ACKK]3/F 
D6&5	NRW.1QQR 
O ' ( M 
O	Ns   BB )r   TFFT)g     P@g        F)$osplatformr   r   	constantsr   	resourcesr   typedr   r   genericr
   systemenvirongetsplitlen_search_pathpfr   joinr-   listdirpappendsetr   extendwhichr6   r2   boolr?   floatrF   )is   0r&   <module>r^      sD   	    " 2 8??	!  "zz~~fb9??DSD!AQR
ADSL>WW\\"2377>>"RZZ^> ''R(;< $ ? 88C-.LCII,l;X__("!zz~~fb9??DSD!AQR
ADSL	
 88C-.LCII,l;::>>&"-L djj> 	D	(
  '3D$D$#D$ D$ 	D$
 D$ D$P PU49HLW T Ts   *H';H'4H,H,