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 
47 class vtkActor;
48 class vtkAlgorithm;
49 class vtkCamera;
52 class vtkDataArray;
53 class vtkDataObject;
54 class vtkDataSet;
55 class vtkGlyph3DMapper;
56 class vtkImageData;
57 class vtkLight;
58 class vtkLookupTable;
59 class vtkMapper;
60 class vtkPolyData;
61 class vtkProperty;
62 class vtkRenderer;
63 class vtkRenderWindow;
64 class vtkTexture;
65 class vtkTransform;
66 class vtkViewNode;
67 
68 class VTKRENDERINGVTKJS_EXPORT vtkVtkJSSceneGraphSerializer : public vtkObject
69 {
70 public:
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*);
115  virtual void Add(vtkViewNode*, vtkGlyph3DMapper*);
116  virtual void Add(vtkViewNode*, vtkMapper*);
117  virtual void Add(vtkViewNode*, vtkRenderer*);
118  virtual void Add(vtkViewNode*, vtkRenderWindow*);
120 
121 protected:
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 
157 private:
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:46
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:64
a virtual camera for 3D rendering
Definition: vtkCamera.h:46
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:50
general representation of visualization data
Definition: vtkDataObject.h:60
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
vtkGlyph3D on the GPU.
topologically and geometrically regular array of data
Definition: vtkImageData.h:48
a simple class to control print indentation
Definition: vtkIndent.h:34
a virtual light for 3D rendering
Definition: vtkLight.h:57
map scalar values into colors via a lookup table
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:82
abstract base class for most VTK objects
Definition: vtkObject.h:63
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
represent surface properties of a geometric object
Definition: vtkProperty.h:62
create a window for renderers to draw into
abstract specification for renderers
Definition: vtkRenderer.h:73
handles properties associated with a texture map
Definition: vtkTexture.h:66
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
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.
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.
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.
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:496
int vtkIdType
Definition: vtkType.h:332