| 22 | } |
| 23 | |
| 24 | static 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 | |
| 71 | static void Deserialize_vtkAlgorithm( |
| 72 | const nlohmann::json& state, vtkObjectBase* object, vtkDeserializer* deserializer) |
nothing calls this directly
no test coverage detected