VTK  9.3.0
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 
35 VTK_ABI_NAMESPACE_BEGIN
36 class vtkActor;
37 class vtkAlgorithm;
38 class vtkCamera;
40 class vtkDataArray;
41 class vtkDataObject;
42 class vtkDataSet;
43 class vtkGlyph3DMapper;
44 class vtkImageData;
45 class vtkLight;
46 class vtkLookupTable;
47 class vtkMapper;
48 class vtkPolyData;
49 class vtkProperty;
50 class vtkRenderer;
51 class vtkRenderWindow;
52 class vtkTexture;
53 class vtkTransform;
54 class vtkViewNode;
55 
56 class VTKRENDERINGVTKJS_EXPORT vtkVtkJSSceneGraphSerializer : public vtkObject
57 {
58 public:
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 
95 
97 
100  virtual void Add(vtkViewNode*, vtkActor*);
102  virtual void Add(vtkViewNode*, vtkGlyph3DMapper*);
103  virtual void Add(vtkViewNode*, vtkMapper*);
104  virtual void Add(vtkViewNode*, vtkRenderer*);
105  virtual void Add(vtkViewNode*, vtkRenderWindow*);
107 
108 protected:
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 
144 private:
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 
155 VTK_ABI_NAMESPACE_END
156 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:61
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
a class that renders hierarchical polygonal data
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
general representation of visualization data
Definition: vtkDataObject.h:64
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkGlyph3D on the GPU.
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
a simple class to control print indentation
Definition: vtkIndent.h:38
a virtual light for 3D rendering
Definition: vtkLight.h:58
map scalar values into colors via a lookup table
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:86
abstract base class for most VTK objects
Definition: vtkObject.h:61
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
represent surface properties of a geometric object
Definition: vtkProperty.h:66
create a window for renderers to draw into
abstract specification for renderers
Definition: vtkRenderer.h:71
handles properties associated with a texture map
Definition: vtkTexture.h:67
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
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.
const Json::Value & GetRoot() const
Access the Json description of 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.
vtkDataArray * GetDataArray(vtkIdType) const
Access the data arrays referenced in the constructed scene.
vtkIdType GetNumberOfDataArrays() const
Access the data arrays referenced in the constructed scene.
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.
vtkDataObject * GetDataObject(vtkIdType) const
Access the data objects referenced in the constructed scene.
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.
static vtkVtkJSSceneGraphSerializer * New()
virtual Json::Value ToJson(Json::Value &, vtkProperty *)
Translate from a VTK renderable to a vtk-js renderable.
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.
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:490
int vtkIdType
Definition: vtkType.h:315