VTK  9.0.1
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 
94  vtkIdType GetNumberOfDataObjects() const;
95  Json::ArrayIndex GetDataObjectId(vtkIdType) const;
96  vtkDataObject* GetDataObject(vtkIdType) const;
98 
100 
103  vtkIdType GetNumberOfDataArrays() const;
104  std::string GetDataArrayId(vtkIdType) const;
105  vtkDataArray* GetDataArray(vtkIdType) const;
107 
109 
112  virtual void Add(vtkViewNode*, vtkActor*);
113  virtual void Add(vtkViewNode*, vtkCompositePolyDataMapper*);
114  virtual void Add(vtkViewNode*, vtkCompositePolyDataMapper2*);
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:
123  ~vtkVtkJSSceneGraphSerializer() override;
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
vtkLight
a virtual light for 3D rendering
Definition: vtkLight.h:56
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkAlgorithm
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:62
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkCompositePolyDataMapper
a class that renders hierarchical polygonal data
Definition: vtkCompositePolyDataMapper.h:40
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkCompositePolyDataMapper2
mapper for composite dataset consisting of polygonal data.
Definition: vtkCompositePolyDataMapper2.h:47
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkTexture
handles properties associated with a texture map
Definition: vtkTexture.h:65
vtkMapper
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:80
vtkGlyph3DMapper
vtkGlyph3D on the GPU.
Definition: vtkGlyph3DMapper.h:39
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:45
vtkVtkJSSceneGraphSerializer::Internals
Internal * Internals
Definition: vtkVtkJSSceneGraphSerializer.h:154
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkViewNode
a node within a VTK scene graph
Definition: vtkViewNode.h:37
vtkObject.h
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkLookupTable
map scalar values into colors via a lookup table
Definition: vtkLookupTable.h:68
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:67
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:61
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:93
vtkVtkJSSceneGraphSerializer
Converts elements of a VTK scene graph into vtk-js elements.
Definition: vtkVtkJSSceneGraphSerializer.h:68
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59