
    &Vf{                     v    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	 ddl
mZ d Zd	 Z	 	 	 	 	 dd
Z	 ddZdS )zFMesh summaries and TensorFlow operations to create them.

V2 versions
    N)tf2)summary_pb2)metadata)plugin_data_pb2)tensor_utilc           	         t          j        |          }|j                                        }d |D             }t	          j        | d|||||          }t           j                            t	          j        | |          |||          S )a  Creates a tensor summary with summary metadata.

    Args:
      name: A name for this summary. The summary tag used for TensorBoard will
        be this name prefixed by any active name scopes.
      description: Optional long-form description for this summary, as a
        constant `str`. Markdown is supported. Defaults to empty.
      tensor: Tensor to display in summary.
      content_type: Type of content inside the Tensor.
      components: Bitmask representing present parts (vertices, colors, etc.) that
        belong to the summary.
      json_config: A string, JSON-serialized dictionary of ThreeJS classes
        configuration.
      step: Explicit `int64`-castable monotonic step value for this summary. If
        omitted, this defaults to `tf.summary.experimental.get_step()`, which must
        not be None.

    Returns:
      A boolean indicating if summary was saved successfully or not.
    )valuec                     g | ]}||nd	S N .0dims     `/var/www/html/software/conda/lib/python3.11/site-packages/tensorboard/plugins/mesh/summary_v2.py
<listcomp>z"_write_summary.<locals>.<listcomp>6   s     ===COSS===    Njson_config)tagtensorstepr   )	tfconvert_to_tensorshapeas_listr   create_summary_metadatasummarywriteget_instance_name)	namedescriptionr   content_type
componentsr   r   r   tensor_metadatas	            r   _write_summaryr&      s    . !///FL  ""E==u===E6  O :&t\:: 	    r   c                 :    d}| t          j        | d          }|S )z6Parses and returns JSON string from python dictionary.z{}NT)	sort_keys)jsondumps)config_dictr   s     r   _get_json_configr,   H   s'    Kj===r   c                    t          |          }t          j        |t          j        j        t          j                  t          j        |t          j        j        t          j	                  t          j        |t          j        j
        t          j                  g}d |D             }t          j        d |D                       }	t          t          j        j        dd          pt          j        j        }
d} |
| d|          5  |D ]#}|ot#          | ||j        |j        |	||          }$	 ddd           n# 1 swxY w Y   |S )a  Writes a TensorFlow mesh summary.

    Args:
      name: A name for this summary. The summary tag used for TensorBoard will
        be this name prefixed by any active name scopes.
      vertices: Tensor of shape `[dim_1, ..., dim_n, 3]` representing the 3D
        coordinates of vertices.
      faces: Tensor of shape `[dim_1, ..., dim_n, 3]` containing indices of
        vertices within each triangle.
      colors: Tensor of shape `[dim_1, ..., dim_n, 3]` containing colors for each
        vertex.
      config_dict: Dictionary with ThreeJS classes names and configuration.
      step: Explicit `int64`-castable monotonic step value for this summary. If
        omitted, this defaults to `tf.summary.experimental.get_step()`, which must
        not be None.
      description: Optional long-form description for this summary, as a
        constant `str`. Markdown is supported. Defaults to empty.

    Returns:
      True if all components of the mesh were saved successfully and False
        otherwise.
    c                      g | ]}|j         	|S Ndatar   r   s     r   r   zmesh.<locals>.<listcomp>       GGG&v{/Fv/F/F/Fr   c                     g | ]	}|j         
S r   r#   r2   s     r   r   zmesh.<locals>.<listcomp>       333	333r   summary_scopeNTmesh_summary)values)r,   r   
MeshTensorr   MeshPluginDataVERTEXr   float32FACEint32COLORuint8get_components_bitmaskgetattrr   experimentalr7   r&   r1   r#   )r!   verticesfacescolorsr+   r   r"   r   tensorsr$   r7   all_successr   s                r   meshrJ   P   s   > #;//K 	o4;RZ	
 	
 	?16	
 	
 	O28"(	
 	

G HGGGGGG0337333 J
 	
'$?? 	$:#  K	t^G	<	<	< 
 
 		 		F% .#+ +KK		
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 s   'D;;D?D?c           
      $   t          |          }g }t          j        |t          j        j        t          j                  t          j        |t          j        j        t          j	                  t          j        |t          j        j
        t          j                  g}d |D             }t          j        d |D                       }	|D ]}
|
j        j        }d |D             }t          j        |
j        |
j                  }t          j        | d|
j        |	|||          }t          j        | |
j                  }|                    |||f           t-          j                    }|D ]#\  }}}|j                            |||           $|S )a  Create a mesh summary to save in pb format.

    Args:
      tag: String tag for the summary.
      vertices: numpy array of shape `[dim_1, ..., dim_n, 3]` representing the 3D
        coordinates of vertices.
      faces: numpy array of shape `[dim_1, ..., dim_n, 3]` containing indices of
        vertices within each triangle.
      colors: numpy array of shape `[dim_1, ..., dim_n, 3]` containing colors for
        each vertex.
      config_dict: Dictionary with ThreeJS classes names and configuration.
      description: Optional long-form description for this summary, as a
        constant `str`. Markdown is supported. Defaults to empty.

    Returns:
      Instance of tf.Summary class.
    c                      g | ]}|j         	|S r/   r0   r2   s     r   r   zmesh_pb.<locals>.<listcomp>   r3   r   c                     g | ]	}|j         
S r   r5   r2   s     r   r   zmesh_pb.<locals>.<listcomp>   r6   r   c                     g | ]}||nd	S r   r   r   s     r   r   zmesh_pb.<locals>.<listcomp>   s     AAACRAAAr   )dtypeNr   )r   r   r   )r,   r   r:   r   r;   r<   r   r=   r>   r?   r@   rA   rB   r1   r   r   make_tensor_proto	data_typer   r#   r    appendr   Summaryr	   add)r   rE   rF   rG   r+   r"   r   	summariesrH   r$   r   r   tensor_protosummary_metadatainstance_tagr   s                   r   mesh_pbrY      s   ( #;//KIo4;RZ	
 	
 	?16	
 	
 	O28"(	
 	

G HGGGGGG0337333 J  I I!AA5AAA"4Kv/
 
 
 $;#
 
 
  1#v7JKK,(8,GHHHH!##G8A 
 
4&'7 	 	
 	
 	
 	
 Nr   )NNNNN)NNNN)__doc__r)   tensorboard.compatr   r   tensorboard.compat.protor   tensorboard.plugins.meshr   r   tensorboard.utilr   r&   r,   rJ   rY   r   r   r   <module>r_      s    
  ( ( ( ( ( ( 0 0 0 0 0 0 - - - - - - 4 4 4 4 4 4 ( ( ( ( ( (( ( (V   	F F F FT KO= = = = = =r   