
    Ti                     H   d dl Z d dlmZ ddlmZ ddlmZ d ZdefdZ	eed	Z
i Z
	 d dlZd
 ej                                        D             Ze
                    e           n# e$ r i ZY nw xY w	 d dlZej        e
d<   dS # e$ rZ ee          e
d<   Y dZ[dS dZ[ww xY w)    N)NamedTemporaryFile   )util)ExceptionWrapperc           	      N   | t          d          t          j        | d          r| S t          | t                    r;d| vrt          d          t          j        |                     d                    } n(t          j        |           rt          j	        |           } ddddddd	}t          | t                    s t          d
t          |            d          i }t          j        | d          } |                                D ]x\  }}|| v rot          j        | |                   ||<   t          j        ||         |          s7t          d|t	          ||         j                  t	          |                    yt#          |          dk    rt          d          |S )a   
    Load multiple input types into kwargs for a Trimesh constructor.
    Tries to extract keys:
    'faces'
    'vertices'
    'face_normals'
    'vertex_normals'

    Parameters
    ----------
    file_obj : dict
    accepts multiple forms
          -dict: has keys for vertices and faces as (n,3) numpy arrays
          -dict: has keys for vertices/faces (n,3) arrays encoded as dicts/base64
                 with trimesh.util.array_to_encoded/trimesh.util.encoded_to_array
          -str:  json blob as dict with either straight array or base64 values
          -file object: json blob of dict
    file_type: not used

    Returns
    -----------
    loaded: dict with keys
            -vertices: (n,3) float
            -faces:    (n,3) int
            -face_normals: (n,3) float (optional)
    Nz&file_obj passed to load_dict was None!Trimesh{z(Object is not a JSON encoded dictionary!zutf-8)   )r
   )r      )verticesfacesface_normalsface_colorsvertex_normalsvertex_colors`z` object passed to dict loader!zShape of %s is %s, not %s!r   z'Unable to extract a mesh from the dict!)
ValueErrorr   is_instance_named
isinstancestrjsonloadsdecodeis_fileloaddicttypedecode_keysitemsencoded_to_arrayis_shapeshapelen)file_objkwargsmesh_file_objloadedkeyr#   s         O/DATA/AppData/hermes/venv/lib/python3.11/site-packages/trimesh/exchange/misc.py	load_dictr+      s   6 ABBBh	22 (C   'hGHHH:hoog6677	h		 '9X&& #!% M h%% NLT(^^LLLMMMF'22H#))++ 	 	
U(??/>>F3K=e44  0s)**JJ	   6{{aBCCCM    	file_typec                    t           j        d|z            }d}g }t          d|           5 }|                    |                                            |                                 |D ]X}	 t          j        |j        |          } n9# t          $ r,}|                    t          |                     Y d}~Qd}~ww xY wddd           n# 1 swxY w Y   |%t          dd                    |          z             i }	|	                    |           |j        |	d<   	 |                    d          |	d	<   n6# t          $ r) t          j                            d
d           g |	d	<   Y nw xY w|	S )a4  
    Load a meshio-supported file into the kwargs for a Trimesh
    constructor.


    Parameters
    ----------
    file_obj : file object
      Contains a meshio file
    file_type : str
      File extension, aka 'vtk'

    Returns
    ----------
    loaded : dict
      kwargs for Trimesh constructor
    .N)suffix)file_formatzFailed to load file:
r   triangler   zunable to get facesT)exc_info)meshioextension_to_filetypesr   writereadflushnameBaseExceptionappendr   r   joinupdatepointsget_cells_typer   logwarning)
r%   r-   r&   file_formatsmesh
exceptionstempr1   Eresults
             r*   load_meshiorI   O   s   ( 0yALDJ 
?y??	3	3	3 	*t

8==??###

' 	* 	*K*{49+FFF  * * *!!#a&&))))))))*	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* |/$))J2G2GGHHH F
MM&F:--j99w   .>>>w MsN   A C.B	C
C"B<7C<CCCC$D= =0E0/E0)r   dict64c                 .    i | ]}|d d         t           S )   N)rI   ).0ks     r*   
<dictcomp>rO      s"    XXXaqukXXXr,   ctm)r   tempfiler    r   rE   r   r+   r   rI   _misc_loadersr5   r6   keys_meshio_loadersr>   r;   openctmload_ctmrG    r,   r*   <module>rY      s\    ' ' ' ' ' '       ) ) ) ) ) )D D DN5S 5 5 5 5p #i88MMM YX63P3U3U3W3WXXXO))))   OOO/NNN"+M% / / /++A..M%/s)   <A% %A/.A/3B B!BB!