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

Function Serialize_vtkAlgorithm

Common/ExecutionModel/vtkAlgorithmSerDesHelper.cxx:24–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24static nlohmann::json Serialize_vtkAlgorithm(vtkObjectBase* object, vtkSerializer* serializer)
25{
26 using json = nlohmann::json;
27 if (auto* algorithm = vtkAlgorithm::SafeDownCast(object))
28 {
29 json state;
30 if (auto superSerializer = serializer->GetHandler(typeid(vtkAlgorithm::Superclass)))
31 {
32 state = superSerializer(object, serializer);
33 }
34 state["SuperClassNames"].push_back("vtkObject");
35 if (algorithm->GetNumberOfOutputPorts() > 0)
36 {
37 if (auto outputDataObject = algorithm->GetOutputDataObject(0))
38 {
39 state["OutputDataObject"] =
40 serializer->SerializeJSON(reinterpret_cast<vtkObjectBase*>(outputDataObject));
41 }
42 }
43 state["AbortExecute"] = algorithm->GetAbortExecute();
44 // the pipeline is servered here by capturing only the input data objects
45 // in the state.
46 auto& statesOfInputDataObjects = state["InputDataObjects"] = json::array();
47 for (int port = 0; port < algorithm->GetNumberOfInputPorts(); ++port)
48 {
49 auto stateOfInputDataObjects = json::array();
50 for (int index = 0; index < algorithm->GetNumberOfInputConnections(port); ++index)
51 {
52 auto* inputAlgorithm = algorithm->GetInputAlgorithm(port, index);
53 inputAlgorithm->Update();
54 auto* inputDataObject = algorithm->GetInputDataObject(port, index);
55 stateOfInputDataObjects.push_back(serializer->SerializeJSON(inputDataObject));
56 }
57 statesOfInputDataObjects.push_back(stateOfInputDataObjects);
58 }
59
60 state["Information"] =
61 serializer->SerializeJSON(reinterpret_cast<vtkObjectBase*>(algorithm->GetInformation()));
62
63 return state;
64 }
65 else
66 {
67 return {};
68 }
69}
70
71static void Deserialize_vtkAlgorithm(
72 const nlohmann::json& state, vtkObjectBase* object, vtkDeserializer* deserializer)

Callers

nothing calls this directly

Calls 12

arrayClass · 0.85
SerializeJSONMethod · 0.80
GetInputDataObjectMethod · 0.80
GetHandlerMethod · 0.45
push_backMethod · 0.45
GetOutputDataObjectMethod · 0.45
GetNumberOfInputPortsMethod · 0.45
GetInputAlgorithmMethod · 0.45
UpdateMethod · 0.45
GetInformationMethod · 0.45

Tested by

no test coverage detected