
    j                     Z   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ej                  j                         D  ci c]  } | d
d e	
 c} Ze
j                  e       	 d dlZej$                  e
d<   yc c} w # e$ r i ZY #w xY w# e$ rZ ee      e
d<   Y dZ[ydZ[ww xY w)    N)NamedTemporaryFile   )util)ExceptionWrapperc           	         | t        d      t        j                  | d      r| S t        | t              r4d| vrt        d      t        j                  | 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      } |j                         D ]k  \  }}|| v st        j                  | |         ||<   t        j                  ||   |      r@t        d|t	        ||   j                         t	        |             t#        |      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)
    z&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         B/DATA/.local/lib/python3.12/site-packages/trimesh/exchange/misc.py	load_dictr+      se   6 ABBh	2(C hGHH::hoog67	h	99X& #!%M h%1T(^,,KLMMF'2H#))+
U(?//>F3K==e4 0s))*J	 	 , 6{aBCCM    	file_typec                    t         j                  d|z      }d}g }t        d|       5 }|j                  | j	                                |j                          |D ]%  }	 t        j                  |j                  |      } n ddd       |t        ddj                  |      z         i }	|	j                  |       |j                  |	d<   	 |j                  d      |	d	<   |	S # t        $ r$}|j                  t        |             Y d}~d}~ww xY w# 1 sw Y   xY w# t        $ r* t        j                   j#                  d
d       g |	d	<   Y |	S w xY w)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   sB   ( 00yALDJ 
Qyk?	3t

8==?#

'K*{{499+F (	 
4 |/$))J2GGHH F
MM&F:--j9w
 M' ! *!!#a&))* 
4	3.  .>wM	sG   5D !C$DD  $	D-DDDDD /EE)r   dict64   ctm)r   tempfiler    r   rE   r   r+   r   rI   _misc_loadersr5   r6   keys_meshio_loadersr>   r;   openctmload_ctmrG   )ks   0r*   <module>rU      s     '  )DN5S 5p #i8 4:3P3P3U3U3WX3Waquk)3WXO)/"++M% Y O  /+A.M%/s;    B A>B *B >B BBB*B%%B*