| 88 | } |
| 89 | |
| 90 | static void Deserialize_vtkGraph( |
| 91 | const nlohmann::json& state, vtkObjectBase* object, vtkDeserializer* deserializer) |
| 92 | { |
| 93 | auto* graph = vtkGraph::SafeDownCast(object); |
| 94 | if (!graph) |
| 95 | { |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | if (auto superDeserializer = deserializer->GetHandler(typeid(vtkGraph::Superclass))) |
| 100 | { |
| 101 | superDeserializer(state, object, deserializer); |
| 102 | } |
| 103 | |
| 104 | vtkGraphInternals* internals = graph->GetGraphInternals(true); |
| 105 | std::vector<vtkVertexAdjacencyList> adjacency; |
| 106 | for (const auto& adj : state["InternalAdjacency"]) |
| 107 | { |
| 108 | vtkVertexAdjacencyList adjList; |
| 109 | |
| 110 | for (const auto& edge : adj["InEdges"]) |
| 111 | { |
| 112 | adjList.InEdges.emplace_back(edge[1], edge[0]); |
| 113 | } |
| 114 | for (const auto& edge : adj["OutEdges"]) |
| 115 | { |
| 116 | adjList.OutEdges.emplace_back(edge[1], edge[0]); |
| 117 | } |
| 118 | adjacency.push_back(adjList); |
| 119 | } |
| 120 | internals->Adjacency = adjacency; |
| 121 | internals->NumberOfEdges = state["NumberOfEdges"]; |
| 122 | internals->UsingPedigreeIds = state["UsingPedigreeIds"]; |
| 123 | |
| 124 | { |
| 125 | auto iter = state.find("VertexData"); |
| 126 | if ((iter != state.end()) && !iter->is_null()) |
| 127 | { |
| 128 | auto* context = deserializer->GetContext(); |
| 129 | const auto identifier = iter->at("Id").get<vtkTypeUInt32>(); |
| 130 | vtkSmartPointer<vtkObjectBase> subObject = |
| 131 | reinterpret_cast<vtkObjectBase*>(graph->GetVertexData()); |
| 132 | if (subObject == nullptr) |
| 133 | { |
| 134 | vtkErrorWithObjectMacro(context, << "An internal collection object is null!"); |
| 135 | } |
| 136 | else |
| 137 | { |
| 138 | if (context->GetObjectAtId(identifier) != subObject) |
| 139 | { |
| 140 | auto registrationId = identifier; |
| 141 | context->RegisterObject(subObject, registrationId); |
| 142 | } |
| 143 | deserializer->DeserializeJSON(identifier, subObject); |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | { |
nothing calls this directly
no test coverage detected