VTK  9.3.1
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 
82  vtkIdType GetNumberOfDataObjects() const;
83  Json::ArrayIndex GetDataObjectId(vtkIdType) const;
84  vtkDataObject* GetDataObject(vtkIdType) const;
86 
88 
91  vtkIdType GetNumberOfDataArrays() const;
92  std::string GetDataArrayId(vtkIdType) const;
93  vtkDataArray* GetDataArray(vtkIdType) const;
95 
97 
100  virtual void Add(vtkViewNode*, vtkActor*);
101  virtual void Add(vtkViewNode*, vtkCompositePolyDataMapper*);
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:
110  ~vtkVtkJSSceneGraphSerializer() override;
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:40
abstract base class for most VTK objects
Definition: vtkObject.h:51
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
represent surface properties of a geometric object
Definition: vtkProperty.h:56
abstract class to specify dataset behavior
Definition: vtkDataSet.h:52
map scalar values into colors via a lookup table
abstract specification for renderers
Definition: vtkRenderer.h:61
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
int vtkIdType
Definition: vtkType.h:315
vtkGlyph3D on the GPU.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:51
a simple class to control print indentation
Definition: vtkIndent.h:28
Converts elements of a VTK scene graph into vtk-js elements.
a virtual camera for 3D rendering
Definition: vtkCamera.h:40
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
a virtual light for 3D rendering
Definition: vtkLight.h:48
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
handles properties associated with a texture map
Definition: vtkTexture.h:57
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:76
create a window for renderers to draw into
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
general representation of visualization data
Definition: vtkDataObject.h:54
a node within a VTK scene graph
Definition: vtkViewNode.h:30
a class that renders hierarchical polygonal data