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

Function Deserialize_vtkAlgorithm

Common/ExecutionModel/vtkAlgorithmSerDesHelper.cxx:71–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71static void Deserialize_vtkAlgorithm(
72 const nlohmann::json& state, vtkObjectBase* object, vtkDeserializer* deserializer)
73{
74 using json = nlohmann::json;
75 auto* algorithm = vtkAlgorithm::SafeDownCast(object);
76 if (!algorithm)
77 {
78 return;
79 }
80 VTK_DESERIALIZE_VALUE_FROM_STATE(AbortExecute, int, state, algorithm);
81
82 VTK_DESERIALIZE_VTK_OBJECT_FROM_STATE(
83 Information, vtkInformation, state, algorithm, deserializer);
84
85 {
86 const auto* context = deserializer->GetContext();
87 const auto iter = state.find("InputDataObjects");
88 if ((iter != state.end()) && !iter->is_null())
89 {
90 auto statesOfInputDataObjects = iter->get<json::array_t>();
91 if (algorithm->GetNumberOfInputPorts() != static_cast<int>(statesOfInputDataObjects.size()))
92 {
93 vtkWarningWithObjectMacro(context,
94 << deserializer->GetObjectDescription()
95 << " failed because number of input ports in state (" << statesOfInputDataObjects.size()
96 << ") does not match for algorithm=" << algorithm->GetObjectDescription() << " ("
97 << algorithm->GetNumberOfInputPorts() << ")");
98 return;
99 }
100 for (int port = 0; port < algorithm->GetNumberOfInputPorts(); ++port)
101 {
102 std::vector<vtkSmartPointer<vtkDataObject>> inputDataObjects;
103 auto stateOfInputDataObjects = statesOfInputDataObjects[port].get<json::array_t>();
104 const bool hasMultipleConnections = stateOfInputDataObjects.size() > 1;
105 for (std::size_t index = 0; index < stateOfInputDataObjects.size(); ++index)
106 {
107 const auto identifier = stateOfInputDataObjects[index]["Id"].get<vtkTypeUInt32>();
108 auto subObject = context->GetObjectAtId(identifier);
109 deserializer->DeserializeJSON(identifier, subObject);
110 if (auto* dataObject = vtkDataObject::SafeDownCast(subObject))
111 {
112 if (hasMultipleConnections)
113 {
114 inputDataObjects.emplace_back(dataObject);
115 }
116 else
117 {
118 algorithm->SetInputDataObject(port, dataObject);
119 }
120 }
121 }
122 if (hasMultipleConnections)
123 {
124 algorithm->RemoveAllInputConnections(port);
125 for (auto& dataObject : inputDataObjects)
126 {
127 algorithm->AddInputDataObject(port, dataObject);
128 }

Callers

nothing calls this directly

Calls 12

DeserializeJSONMethod · 0.80
AddInputDataObjectMethod · 0.80
GetContextMethod · 0.45
findMethod · 0.45
endMethod · 0.45
GetNumberOfInputPortsMethod · 0.45
sizeMethod · 0.45
GetObjectDescriptionMethod · 0.45
GetObjectAtIdMethod · 0.45
emplace_backMethod · 0.45
SetInputDataObjectMethod · 0.45

Tested by

no test coverage detected