VTK  9.1.0
vtkVtkJSSceneGraphSerializer.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkVtkJSSceneGraphSerializer.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
39#ifndef vtkVtkJSSceneGraphSerializer_h
40#define vtkVtkJSSceneGraphSerializer_h
41
42#include "vtkRenderingVtkJSModule.h" // For export macro
43
44#include "vtkObject.h"
45#include <vtk_jsoncpp.h> // For Json::Value
46
47class vtkActor;
48class vtkAlgorithm;
49class vtkCamera;
52class vtkDataArray;
53class vtkDataObject;
54class vtkDataSet;
56class vtkImageData;
57class vtkLight;
58class vtkLookupTable;
59class vtkMapper;
60class vtkPolyData;
61class vtkProperty;
62class vtkRenderer;
63class vtkRenderWindow;
64class vtkTexture;
65class vtkTransform;
66class vtkViewNode;
67
68class VTKRENDERINGVTKJS_EXPORT vtkVtkJSSceneGraphSerializer : public vtkObject
69{
70public:
73 void PrintSelf(ostream& os, vtkIndent indent) override;
74
76
79 void Reset();
81
83
87 const Json::Value& GetRoot() const;
89
91
95 Json::ArrayIndex GetDataObjectId(vtkIdType) const;
98
100
107
109
112 virtual void Add(vtkViewNode*, vtkActor*);
116 virtual void Add(vtkViewNode*, vtkMapper*);
117 virtual void Add(vtkViewNode*, vtkRenderer*);
120
121protected:
124
126
129 virtual Json::Value ToJson(vtkDataArray*);
130 virtual Json::Value ToJson(Json::Value&, vtkAlgorithm*, vtkDataObject*);
131 virtual Json::Value ToJson(Json::Value&, vtkActor*, bool newPropertyId = false);
132 virtual Json::Value ToJson(Json::Value&, Json::ArrayIndex, vtkGlyph3DMapper*);
133 virtual Json::Value ToJson(Json::Value&, vtkCamera*);
134 virtual Json::Value ToJson(Json::Value&, vtkAlgorithm*, vtkImageData*);
135 virtual Json::Value ToJson(Json::Value&, vtkLight*);
136 virtual Json::Value ToJson(Json::Value&, vtkLookupTable*);
137 virtual Json::Value ToJson(Json::Value&, Json::ArrayIndex, vtkMapper*, bool newLUTId = false);
138 virtual Json::Value ToJson(Json::Value&, vtkRenderer*);
139 virtual Json::Value ToJson(Json::Value&, vtkAlgorithm*, vtkPolyData*);
140 virtual Json::Value ToJson(Json::Value&, vtkProperty*);
141 virtual Json::Value ToJson(Json::Value&, vtkTexture*);
142 virtual Json::Value ToJson(Json::Value&, vtkTransform*);
143 virtual Json::Value ToJson(vtkRenderWindow*);
145
147
151 Json::ArrayIndex UniqueId(void* ptr = nullptr);
153
154 struct Internal;
155 Internal* Internals;
156
157private:
159 void operator=(const vtkVtkJSSceneGraphSerializer&) = delete;
160
161 virtual void Add(Json::Value*, vtkAlgorithm*);
162
163 template <typename CompositeMapper>
164 void Add(vtkViewNode* node, vtkDataObject* dataObject, CompositeMapper* mapper);
165
166 void extractRequiredFields(Json::Value& extractedFields, vtkMapper* mapper, vtkDataSet* dataSet);
167};
168
169#endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:114
a virtual camera for 3D rendering
Definition: vtkCamera.h:155
mapper for composite dataset consisting of polygonal data.
a class that renders hierarchical polygonal data
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
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
Definition: vtkImageData.h:157
a simple class to control print indentation
Definition: vtkIndent.h:113
a virtual light for 3D rendering
Definition: vtkLight.h:166
map scalar values into colors via a lookup table
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:171
abstract base class for most VTK objects
Definition: vtkObject.h:73
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
represent surface properties of a geometric object
Definition: vtkProperty.h:171
create a window for renderers to draw into
abstract specification for renderers
Definition: vtkRenderer.h:173
handles properties associated with a texture map
Definition: vtkTexture.h:175
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
a node within a VTK scene graph
Definition: vtkViewNode.h:39
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.
virtual void Add(vtkViewNode *, vtkCompositePolyDataMapper2 *)
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.
@ string
Definition: vtkX3D.h:496
int vtkIdType
Definition: vtkType.h:332