a
    d=ic                     @   sf   d Z ddlZddlmZ ddlmZ eddZdZdZ	dd	 Z
d
d Zdd ZdddZdd ZdS )z+Internal information about the mesh plugin.    N)summary_pb2)plugin_data_pb2
MeshTensor)datacontent_type	data_typeZmeshc                 C   s2   d}| D ]$}|t jjkr td|d|> B }q|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   MeshPluginData	UNDEFINED
ValueError)Zcontent_types
componentsr    r   r/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/tensorboard/plugins/mesh/metadata.pyget_components_bitmask!   s    r   c                   C   s   t S )z%Returns current verions of the proto.)_PROTO_VERSIONr   r   r   r   get_current_version1   s    r   c                 C   s   d| t jj|f S )zKReturns a unique instance name for a given summary related to the
    mesh.z%s_%s)r   r	   ZContentTypeName)namer   r   r   r   get_instance_name6   s    r   c           	      C   sX   t |dkrtdt| tjt | ||||d}| }tj||tjj	t
|dd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)Zplugin_namecontent)display_nameZsummary_descriptionZplugin_data)lenr   strr   r	   r   ZSerializeToStringr   ZSummaryMetadataZ
PluginDataPLUGIN_NAME)	r   r   r   r   r   descriptionr   Zmesh_plugin_datar   r   r   r   create_summary_metadata?   s(    
r   c                 C   sH   t | tstdtj| }|jdkrDt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	   Z
FromStringr   r   ZVERTEXZFACEZCOLOR)r   resultr   r   r   parse_plugin_metadatap   s    

r$   )NN)__doc__collectionsZtensorboard.compat.protor   Ztensorboard.plugins.meshr   
namedtupler   r   r   r   r   r   r   r$   r   r   r   r   <module>   s     
1