VTK  9.3.20240426
vtkVtkJSSceneGraphSerializer.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
27#ifndef vtkVtkJSSceneGraphSerializer_h
28#define vtkVtkJSSceneGraphSerializer_h
29
30#include "vtkRenderingVtkJSModule.h" // For export macro
31
32#include "vtkObject.h"
33#include <vtk_jsoncpp.h> // For Json::Value
34
35VTK_ABI_NAMESPACE_BEGIN
36class vtkActor;
37class vtkAlgorithm;
38class vtkCamera;
40class vtkDataArray;
41class vtkDataObject;
42class vtkDataSet;
44class vtkImageData;
45class vtkLight;
46class vtkLookupTable;
47class vtkMapper;
48class vtkPolyData;
49class vtkProperty;
50class vtkRenderer;
51class vtkRenderWindow;
52class vtkTexture;
53class vtkTransform;
54class vtkViewNode;
55
56class VTKRENDERINGVTKJS_EXPORT vtkVtkJSSceneGraphSerializer : public vtkObject
57{
58public:
61 void PrintSelf(ostream& os, vtkIndent indent) override;
62
64
67 void Reset();
69
71
75 const Json::Value& GetRoot() const;
77
79
83 Json::ArrayIndex GetDataObjectId(vtkIdType) const;
86
88
92 std::string GetDataArrayId(vtkIdType) const;
95
97
100 virtual void Add(vtkViewNode*, vtkActor*);
103 virtual void Add(vtkViewNode*, vtkMapper*);
104 virtual void Add(vtkViewNode*, vtkRenderer*);
107
108protected:
111
113
116 virtual Json::Value ToJson(vtkDataArray*);
117 virtual Json::Value ToJson(Json::Value&, vtkAlgorithm*, vtkDataObject*);
118 virtual Json::Value ToJson(Json::Value&, vtkActor*, bool newPropertyId = false);
119 virtual Json::Value ToJson(Json::Value&, Json::ArrayIndex, vtkGlyph3DMapper*);
120 virtual Json::Value ToJson(Json::Value&, vtkCamera*);
121 virtual Json::Value ToJson(Json::Value&, vtkAlgorithm*, vtkImageData*);
122 virtual Json::Value ToJson(Json::Value&, vtkLight*);
123 virtual Json::Value ToJson(Json::Value&, vtkLookupTable*);
124 virtual Json::Value ToJson(Json::Value&, Json::ArrayIndex, vtkMapper*, bool newLUTId = false);
125 virtual Json::Value ToJson(Json::Value&, vtkRenderer*);
126 virtual Json::Value ToJson(Json::Value&, vtkAlgorithm*, vtkPolyData*);
127 virtual Json::Value ToJson(Json::Value&, vtkProperty*);
128 virtual Json::Value ToJson(Json::Value&, vtkTexture*);
129 virtual Json::Value ToJson(Json::Value&, vtkTransform*);
130 virtual Json::Value ToJson(vtkRenderWindow*);
132
134
138 Json::ArrayIndex UniqueId(void* ptr = nullptr);
140
141 struct Internal;
142 Internal* Internals;
143
144private:
146 void operator=(const vtkVtkJSSceneGraphSerializer&) = delete;
147
148 virtual void Add(Json::Value*, vtkAlgorithm*);
149
150 void Add(vtkViewNode* node, vtkDataObject* dataObject, vtkCompositePolyDataMapper* mapper);
151
152 void extractRequiredFields(Json::Value& extractedFields, vtkMapper* mapper, vtkDataSet* dataSet);
153};
154
155VTK_ABI_NAMESPACE_END
156#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
Superclass for all sources, filters, and sinks in VTK.
a virtual camera for 3D rendering
Definition vtkCamera.h:151
a class that renders hierarchical polygonal data
abstract superclass for arrays of numeric data
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:166
vtkGlyph3D on the GPU.
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:108
a virtual light for 3D rendering
Definition vtkLight.h:159
map scalar values into colors via a lookup table
abstract class specifies interface to map data to graphics primitives
Definition vtkMapper.h:137
abstract base class for most VTK objects
Definition vtkObject.h:162
concrete dataset represents vertices, lines, polygons, and triangle strips
represent surface properties of a geometric object
create a window for renderers to draw into
abstract specification for renderers
handles properties associated with a texture map
Definition vtkTexture.h:167
describes linear transformations via a 4x4 matrix
a node within a VTK scene graph
Definition vtkViewNode.h:31
Converts elements of a VTK scene graph into vtk-js elements.
virtual Json::Value ToJson(Json::Value &, Json::ArrayIndex, vtkGlyph3DMapper *)
Translate from a VTK renderable to a vtk-js renderable.
Json::ArrayIndex UniqueId(void *ptr=nullptr)
Associate a unique id with a given object.
virtual Json::Value ToJson(Json::Value &, vtkRenderer *)
Translate from a VTK renderable to a vtk-js renderable.
vtkDataObject * GetDataObject(vtkIdType) const
Access the data objects referenced in the constructed scene.
virtual void Add(vtkViewNode *, vtkCompositePolyDataMapper *)
Add a scene graph node and its corresponding renderable to the scene.
~vtkVtkJSSceneGraphSerializer() override
virtual void Add(vtkViewNode *, vtkGlyph3DMapper *)
Add a scene graph node and its corresponding renderable to the scene.
vtkIdType GetNumberOfDataArrays() const
Access the data arrays referenced in the constructed scene.
static vtkVtkJSSceneGraphSerializer * New()
virtual Json::Value ToJson(Json::Value &, vtkLight *)
Translate from a VTK renderable to a vtk-js renderable.
std::string GetDataArrayId(vtkIdType) const
Access the data arrays referenced in the constructed scene.
virtual Json::Value ToJson(vtkDataArray *)
Translate from a VTK renderable to a vtk-js renderable.
virtual void Add(vtkViewNode *, vtkRenderer *)
Add a scene graph node and its corresponding renderable to the scene.
vtkIdType GetNumberOfDataObjects() const
Access the data objects referenced in the constructed scene.
void Reset()
Empty the contents of the scene and the reset the unique id generator.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual Json::Value ToJson(Json::Value &, vtkTransform *)
Translate from a VTK renderable to a vtk-js renderable.
virtual Json::Value ToJson(Json::Value &, vtkTexture *)
Translate from a VTK renderable to a vtk-js renderable.
Json::ArrayIndex GetDataObjectId(vtkIdType) const
Access the data objects referenced in the constructed scene.
virtual Json::Value ToJson(Json::Value &, vtkAlgorithm *, vtkImageData *)
Translate from a VTK renderable to a vtk-js renderable.
virtual void Add(vtkViewNode *, vtkActor *)
Add a scene graph node and its corresponding renderable to the scene.
virtual Json::Value ToJson(Json::Value &, vtkProperty *)
Translate from a VTK renderable to a vtk-js renderable.
const Json::Value & GetRoot() const
Access the Json description of the constructed scene.
virtual Json::Value ToJson(Json::Value &, vtkLookupTable *)
Translate from a VTK renderable to a vtk-js renderable.
virtual Json::Value ToJson(Json::Value &, vtkAlgorithm *, vtkPolyData *)
Translate from a VTK renderable to a vtk-js renderable.
virtual void Add(vtkViewNode *, vtkRenderWindow *)
Add a scene graph node and its corresponding renderable to the scene.
virtual Json::Value ToJson(Json::Value &, vtkActor *, bool newPropertyId=false)
Translate from a VTK renderable to a vtk-js renderable.
virtual Json::Value ToJson(Json::Value &, vtkAlgorithm *, vtkDataObject *)
Translate from a VTK renderable to a vtk-js renderable.
vtkDataArray * GetDataArray(vtkIdType) const
Access the data arrays referenced in the constructed scene.
virtual Json::Value ToJson(vtkRenderWindow *)
Translate from a VTK renderable to a vtk-js renderable.
virtual void Add(vtkViewNode *, vtkMapper *)
Add a scene graph node and its corresponding renderable to the scene.
virtual Json::Value ToJson(Json::Value &, vtkCamera *)
Translate from a VTK renderable to a vtk-js renderable.
virtual Json::Value ToJson(Json::Value &, Json::ArrayIndex, vtkMapper *, bool newLUTId=false)
Translate from a VTK renderable to a vtk-js renderable.
int vtkIdType
Definition vtkType.h:315