
    tj                        d Z 	 ddlZddl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                  ej                  e        ej                  ej                  e        ej                  ej                   e        ej                  ej"                  e        ej                  ej$                  e        ej                  ej&                  e        ej                  ej(                  e        ej                  ej*                  e        ej                  ej,                  e        ej                  ej.                  e        ej                  ej0                  e        ej                  ej2                  e        ej                  ej4                  e        ej                  ej6                  e        ej                  ej8                  e        ej                  ej:                  e        ej                  ej<                  e        ej                  ej>                  e        ej                  ej@                  e        ej                  ejB                  e        ej                  ejD                  e        ej                  ejF                  e        ej                  ejH                  e       y# e$ r	  ed      w xY w)
a#  This module generates support for pickling vtkDataObjects from python.
It needs to be imported specifically in order to work:

>>> import vtkmodules.util.pickle_support

Once imported however, the pickling of data objects is very straighforward. Here is an
example using poly data:

>>> sphereSrc = vtkSphereSource()
>>> sphereSrc.Update()
>>> pickled = pickle.dumps(sphereSrc.GetOutput())
>>> unpickled = pickle.loads(pickled)
>>> print(unpickled)
*description of sphere data set*

The underlying serialization of the vtkDatObjects is based on the marshaling capabilities
found in vtkCommunicator. Importing this module adds entries for the most common data
objects in the global dispatch table used by pickle. NumPy is required as well since the
-serialized data object gets pickled as a numpy array.
    NznThis module depends on the pickle, copyreg, and numpy modules. Please make sure that it is installed properly.   )vtkCommunicator)vtkCharArray)vtkCommonDataModelc                    d| j                         vsd| j                         vrt        d      d}d}	 t        t        | d         }| d   } |       }t               }|j                  |t        |      j                  d       t        j                  ||      dk(  rt        d	      |S #  t	        dt
        z   dz         xY w)
zTakes a state dictionary with entries:
      - Type : a string with the class name for the data object
      - Serialized : a numpy array with the serialized data object

      and transforms it into a data object.
    Type
SerializedzNState dictionary passed to unpickle does not have Type and/or Serialized keys.NzCould not find type z in vtkCommonDataModel module   r   zMarshaling data object failed)keysRuntimeErrorgetattrr   	TypeErrortype_stringr   SetVoidArray
memoryviewnbytesr   UnMarshalDataObject)statenew_data_objectDataSetClassserialized_data
char_arrays        K/DATA/.local/lib/python3.12/site-packages/vtkmodules/util/pickle_support.pyunserialize_VTK_data_objectr       s     	ejjl"EJJL(H   	 OL`15=A L)O"nOJOZ-H-O-OQRS**:G1L:;;`.<?^^__s   B* *Cc                 0   | j                  d      st        d      | j                         }t               }t	        j
                  | |      dk(  rt        d      t        |t        j                  |t        j                  |j                               dffS )aB  Returns a tuple with a reference to the unpickling function and a state dictionary
    with entires:
      - Type : a string with the class name for the data object
      - Serialized : a numpy array with the serialized data object

      This is exactly the state dictionary that unserialize_VTK_data_object expects.
    vtkDataObjectz3Object passed to pickling should be a vtkDataObjectr   zUnMarshaling data object failed)r   r	   )IsAr   GetClassNamer   r   MarshalDataObjectr   r   numpy
frombufferint8GetNumberOfValues)data_objectdata_object_typer   s      r   serialize_VTK_data_objectr&   :   s     ???+MNN"//1J((jAQF<==&#))*ejj*B^B^B`a	d)f f f    )%__doc__copyregpickler    ImportErrorr   vtkParallelCorer   vtkCommonCorer    r   r   r&   
vtkDataSetvtkPolyDatavtkUnstructuredGridvtkImageDatavtkRectilinearGridvtkStructuredGridvtkExplicitStructuredGridvtkStructuredPointsvtkUniformGridAMRvtkOverlappingAMRvtkHierarchicalBoxDataSetvtkNonOverlappingAMRvtkTablevtkTreevtkCompositeDataSetvtkDataObjectTreevtkMultiBlockDataSetvtkPartitionedDataSetvtkPartitionedDataSetCollectionvtkMultiPieceDataSetvtkDirectedGraphvtkUndirectedGraphvtkMolecule r'   r   <module>rG      sy  *3!!
 . ( !4f* !,,.G H !--/H I !557P Q !..0I J !446O P !335N O !;;=V W !557P Q !335N O !335N O !;;=V W !668Q R !**,E F !))+D E !557P Q !335N O !668Q R !779R S !AAC\ ] !668Q R !224M N !446O P !--/H Ii  3
 2 3 33s   K K