vtkmodules.util.pickle_support
#
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 using the vtkmodules.util.numpy_support module.
Module Contents#
Functions#
Takes a state dictionary with entries: |
|
Returns a tuple with a reference to the unpickling function and a state dictionary with entires: |
API#
- vtkmodules.util.pickle_support.unserialize_VTK_data_object(state)#
Takes 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.
- vtkmodules.util.pickle_support.serialize_VTK_data_object(data_object)#
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.