
    1VhT                         d Z ddlZddlmZ ddlmZ ddlmZ dZdZ	 ej                  d       G d	 d
             Zd Zd Zd Z	 	 ddZd Zy)z+Internal information about the mesh plugin.    N)Any)summary_pb2)plugin_data_pb2meshT)frozenc                   X    e Zd ZU dZeed<   ej                  j                  ed<   eed<   y)
MeshTensora  A mesh tensor.

    Attributes:
      data: Tensor of shape `[dim_1, ..., dim_n, 3]` representing the mesh data
        of one of the following:
          - 3D coordinates of vertices
          - Indices of vertices within each triangle
          - Colors for each vertex
      content_type: Type of the mesh plugin data content.
      data_type: Data type of the elements in the tensor.
    datacontent_type	data_typeN)	__name__
__module____qualname____doc__r   __annotations__r   MeshPluginDataContentType     Q/home/dcms/DCMS/lib/python3.12/site-packages/tensorboard/plugins/mesh/metadata.pyr	   r	      s%    
 I!00<<<Nr   r	   c                 x    d}| D ]2  }|t         j                  j                  k(  rt        d      |d|z  z  }4 |S )zCreates bitmask for all existing components of the summary.

    Args:
      content_type: list of plugin_data_pb2.MeshPluginData.ContentType,
        representing all components related to the summary.
    Returns: bitmask based on passed tensors.
    r   z.Cannot include UNDEFINED content type in mask.   )r   r   	UNDEFINED
ValueError)content_types
componentsr   s      r   get_components_bitmaskr   2   sO     J% 6?99CCCMNN1#45
6 r   c                      t         S )z%Returns current verions of the proto.)_PROTO_VERSIONr   r   r   get_current_versionr    B   s    r   c                 ^    | dt         j                  j                  j                  |      S )zKReturns a unique instance name for a given summary related to the
    mesh._)r   r   r   Name)namer   s     r   get_instance_namer%   G   s+     	&&2277E r   c                 (   t        |      dk7  rt        dt        |      z        t        j                  t               | ||||      }|j                         }t        j                  ||t        j                  j                  t        |            S )a  Creates summary metadata which defined at MeshPluginData proto.

    Arguments:
      name: Original merged (summaries of different types) summary name.
      display_name: The display name used in TensorBoard.
      content_type: Value from MeshPluginData.ContentType enum describing data.
      components: Bitmask representing present parts (vertices, colors, etc.) that
        belong to the summary.
      shape: list of dimensions sizes of the tensor.
      description: The description to show in TensorBoard.
      json_config: A string, JSON-serialized dictionary of ThreeJS classes
        configuration.

    Returns:
      A `summary_pb2.SummaryMetadata` protobuf object.
       z2Tensor shape should be of shape BxNx3, but got %s.)versionr$   r   r   shapejson_config)plugin_namecontent)display_namesummary_descriptionplugin_data)lenr   strr   r   r    SerializeToStringr   SummaryMetadata
PluginDataPLUGIN_NAME)	r$   r-   r   r   r)   descriptionr*   mesh_plugin_datar,   s	            r   create_summary_metadatar8   P   s    6 5zQ@3u:M
 	
 '55#%! 002G&&!'//::#W ; 
 r   c                 N   t        | t              st        d      t        j                  j                  |       }|j                  dk(  r[t        t        j                  j                  t        j                  j                  t        j                  j                  g      |_        |S )a"  Parse summary metadata to a Python object.

    Arguments:
      content: The `content` field of a `SummaryMetadata` proto
        corresponding to the mesh plugin.

    Returns:
      A `MeshPluginData` protobuf object.
    Raises: Error if the version of the plugin is not supported.
    zContent type must be bytes.r   )
isinstancebytes	TypeErrorr   r   
FromStringr   r   VERTEXFACECOLOR)r,   results     r   parse_plugin_metadatarB      s     gu%566++66w?FA2..55..33..44
 Mr   )NN)r   dataclassestypingr   tensorboard.compat.protor   tensorboard.plugins.meshr   r5   r   	dataclassr	   r   r    r%   r8   rB   r   r   r   <module>rH      sj    2   0 4  d#  $$ 
 .br   