VTK  9.3.20240907
Classes | Macros
vtkDeserializer.h File Reference
#include "vtkObject.h"
#include "vtkCommonCoreModule.h"
#include "vtkMarshalContext.h"
#include "vtkSmartPointer.h"
#include "vtk_nlohmannjson.h"
#include <VTK_NLOHMANN_JSON(json_fwd.hpp)>
#include <memory>
#include <typeinfo>
Include dependency graph for vtkDeserializer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  vtkDeserializer
 Deserialize VTK objects from JSON. More...
 

Macros

#define VTK_DESERIALIZE_VALUE_FROM_STATE(name, type, state, object)
 Convenient to get value for a property from the state and apply the value on a vtk object.
 
#define VTK_DESERIALIZE_VTK_OBJECT_FROM_STATE_DIFFERENT_NAMES( stateKey, propertyName, cls, state, object, deserializer)
 Convenient to get a vtkObject property from the state and set it on another vtk object.
 
#define VTK_DESERIALIZE_VTK_OBJECT_FROM_STATE(name, cls, state, object, deserializer)
 Similar to above, when the state and VTK class property have the same name.
 
#define VTK_DESERIALIZE_VECTOR_FROM_STATE(name, type, state, object)
 Convenient to get a vector of values for a property from the state and apply the values on a vtk object.
 

Macro Definition Documentation

◆ VTK_DESERIALIZE_VALUE_FROM_STATE

#define VTK_DESERIALIZE_VALUE_FROM_STATE (   name,
  type,
  state,
  object 
)
Value:
do \
{ \
const auto iter = state.find(#name); \
if ((iter != state.end()) && !iter->is_null()) \
{ \
object->Set##name(iter->get<type>()); \
} \
} while (0)

Convenient to get value for a property from the state and apply the value on a vtk object.

Definition at line 127 of file vtkDeserializer.h.

◆ VTK_DESERIALIZE_VTK_OBJECT_FROM_STATE_DIFFERENT_NAMES

#define VTK_DESERIALIZE_VTK_OBJECT_FROM_STATE_DIFFERENT_NAMES (   stateKey,
  propertyName,
  cls,
  state,
  object,
  deserializer 
)
Value:
do \
{ \
const auto iter = state.find(#stateKey); \
if ((iter != state.end()) && !iter->is_null()) \
{ \
const auto* context = deserializer->GetContext(); \
const auto identifier = iter->at("Id").get<vtkTypeUInt32>(); \
auto subObject = context->GetObjectAtId(identifier); \
deserializer->DeserializeJSON(identifier, subObject); \
if (auto* asVtkType = cls::SafeDownCast(subObject)) \
{ \
object->Set##propertyName(asVtkType); \
} \
} \
} while (0)

Convenient to get a vtkObject property from the state and set it on another vtk object.

stateKey is the name used in state. propertyName is the name used by the VTK class Set/Get macros or a SetSomething() function. This is a special case.

Definition at line 142 of file vtkDeserializer.h.

◆ VTK_DESERIALIZE_VTK_OBJECT_FROM_STATE

#define VTK_DESERIALIZE_VTK_OBJECT_FROM_STATE (   name,
  cls,
  state,
  object,
  deserializer 
)
Value:
name, name, cls, state, object, deserializer)
#define VTK_DESERIALIZE_VTK_OBJECT_FROM_STATE_DIFFERENT_NAMES( stateKey, propertyName, cls, state, object, deserializer)
Convenient to get a vtkObject property from the state and set it on another vtk object.

Similar to above, when the state and VTK class property have the same name.

This is common.

Definition at line 163 of file vtkDeserializer.h.

◆ VTK_DESERIALIZE_VECTOR_FROM_STATE

#define VTK_DESERIALIZE_VECTOR_FROM_STATE (   name,
  type,
  state,
  object 
)
Value:
do \
{ \
const auto iter = state.find(#name); \
if ((iter != state.end()) && !iter->is_null()) \
{ \
using namespace std; \
const auto elements = iter->get<vector<type>>(); \
object->Set##name(elements.data()); \
} \
} while (0)

Convenient to get a vector of values for a property from the state and apply the values on a vtk object.

Definition at line 171 of file vtkDeserializer.h.