MCPcopy Create free account
hub / github.com/Kitware/VTK / serialize_VTK_data_object

Function serialize_VTK_data_object

Wrapping/Python/vtkmodules/util/pickle_support.py:58–75  ·  view source on GitHub ↗

Returns a tuple with a reference to the unpickling function and 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 This is exactly the state dictionary that unserialize_VTK_dat

(data_object)

Source from the content-addressed store, hash-verified

56 return new_data_object
57
58def serialize_VTK_data_object(data_object):
59 """Returns a tuple with a reference to the unpickling function and a state dictionary
60 with entries:
61 - Type : a string with the class name for the data object
62 - Serialized : a numpy array with the serialized data object
63
64 This is exactly the state dictionary that unserialize_VTK_data_object expects.
65 """
66
67 if not data_object.IsA("vtkDataObject"):
68 raise TypeError("Object passed to pickling should be a vtkDataObject")
69 data_object_type = data_object.GetClassName()
70 char_array = vtkCharArray()
71 if vtkCommunicator.MarshalDataObject(data_object, char_array) == 0:
72 raise RuntimeError("UnMarshaling data object failed")
73 return unserialize_VTK_data_object, (
74 { "Type" : data_object_type,
75 "Serialized" : numpy.frombuffer(char_array, numpy.int8, char_array.GetNumberOfValues()) },)
76
77
78# Fill in global dispatch table for most vtkDataObject types

Callers

nothing calls this directly

Calls 6

vtkCharArrayFunction · 0.90
RuntimeErrorClass · 0.85
IsAMethod · 0.80
MarshalDataObjectMethod · 0.80
GetClassNameMethod · 0.45
GetNumberOfValuesMethod · 0.45

Tested by

no test coverage detected