
    Ti`                         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    rd
 e j                            dd                              d          D             ZdD ]|Ze j                            ed          Ze j                            e          rE e j        e          D ]4Zdev r.e                    e j                            ee                     5}d                     ee                    Z ej        de           n ej                    dk    rd e j                            dd                              d          D             Ze                    g d           d                     ee                    Z ej        de           ne 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"dS )-    N   )util)log)
get_string)BooleanOperationTypeIterable   )
MeshScriptWindowsc                 8    g | ]}t          |          d k    |S r   len.0is     T/DATA/AppData/hermes/venv/lib/python3.11/site-packages/trimesh/interfaces/blender.py
<listcomp>r      $    SSS!AQR

A


    PATH ;)zC:\Program FileszC:\Program Files (x86)zBlender FoundationBlenderzsearching for blender in: %sDarwinc                 8    g | ]}t          |          d k    |S r   r   r   s     r   r   r      r   r   :)z(/Applications/blender.app/Contents/MacOSz(/Applications/Blender.app/Contents/MacOSz0/Applications/Blender/blender.app/Contents/MacOSblender)pathUNION
DIFFERENCE	INTERSECT)union
differenceintersectionr$   TFmeshes	operation	use_exactuse_selfdebugcheck_volumec                    t           st          d          |r(t          d | D                       st          d          |                                                                }|t
          vr-t          d| dt
                                           d          |rd}nd}t          d          }|                    d	t
          |                                       d
|                              d|           }	t          | |	|          5 }
|

                    t          dz             }ddd           n# 1 swxY w Y   t          j        |          }|D ]	}d|_        
t          j        |          S )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   $   K   | ]}|j         V  d S )N)	is_volume)r   ms     r   	<genexpr>zboolean.<locals>.<genexpr>T   s$      <<<<<<<<r   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templater5   blendresultr0   s                r   booleanrI   1   s   B  20111 8C<<V<<<<< 86777 //


!
!
#
#C
-M	MMm6H6H6J6JMMM
 
 	
     =>>H
 	}S'9::	"N	3	3	m	,	, 
 
6&	>	>	> S%.1QQRRS S S S S S S S S S S S S S S ''F  F###s   D99D= D=     P@        angle_limitisland_marginc                 z   t           st          d          t          d          }|                    d|d                              d|d          }t	          | g|d|          5 }|                    t          dz             }d	d	d	           n# 1 swxY w Y   t          j        |          D ]	}d	|_	        
|S )
z0
    Run an unwrap operation using blender.
    r-   z$templates/blender_unwrap.py.templatez$ANGLE_LIMITz.6fz$ISLAND_MARGINobj)r&   r5   exchanger*   r6   N)
r7   r8   r   r>   r
   r?   r@   r   rA   rB   )	meshrL   rM   r*   rF   r5   rG   rH   r0   s	            r   unwraprR   x   s!     20111 @AAHn.B.BCCKK]00 F 
D6&5	N	N	N SRW.1QQRRS S S S S S S S S S S S S S S ''  Ms   (BBB)r$   TFFT)rJ   rK   F)#osplatformr   r   	constantsr   	resourcesr   typedr   r   genericr
   systemenvirongetsplit_search_pathpfr   joinr7   listdirpappendsetr*   extendwhichr@   r<   boolrI   floatrR    r   r   <module>ri      s   				              " " " " " " 2 2 2 2 2 2 2 2      8?	!! TSrz~~fb99??DDSSSL> = =W\\"2337>>" 	=RZ^^ = =>> ''R(;(;<<<88CC--..LCI,l;;;;X_(""SSrz~~fb99??DDSSSL	
 	
 	
   88CC--..LCI,l;;;;:>>&"--L dj>>> 	D	(
   '3D$ D$D$#D$ D$ 	D$
 D$ D$ D$ D$ D$P PU 49HL     r   