VTK  9.2.6
vtkJSONSceneExporter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkJSONSceneExporter.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 =========================================================================*/
25 #ifndef vtkJSONSceneExporter_h
26 #define vtkJSONSceneExporter_h
27 
28 #include "vtkExporter.h"
29 #include "vtkIOExportModule.h" // For export macro
30 #include "vtkSmartPointer.h" // For vtkSmartPointer
31 
32 #include <map> // For member variables
33 #include <string> // For string parameter
34 #include <vector> // For member variables
35 
36 class vtkActor;
38 class vtkDataObject;
39 class vtkDataSet;
41 class vtkPolyData;
42 class vtkPropCollection;
43 class vtkScalarsToColors;
44 class vtkTexture;
45 class vtkVolume;
47 
48 class VTKIOEXPORT_EXPORT vtkJSONSceneExporter : public vtkExporter
49 {
50 public:
51  static vtkJSONSceneExporter* New();
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
56 
60  vtkSetFilePathMacro(FileName);
61  vtkGetFilePathMacro(FileName);
63 
65 
70  vtkSetMacro(WriteTextures, bool);
71  vtkGetMacro(WriteTextures, bool);
73 
75 
84  vtkSetMacro(WriteTextureLODs, bool);
85  vtkGetMacro(WriteTextureLODs, bool);
87 
89 
94  vtkSetMacro(TextureLODsBaseSize, size_t);
95  vtkGetMacro(TextureLODsBaseSize, size_t);
97 
99 
103  vtkSetStringMacro(TextureLODsBaseUrl);
104  vtkGetStringMacro(TextureLODsBaseUrl);
106 
108 
122  vtkSetMacro(WritePolyLODs, bool);
123  vtkGetMacro(WritePolyLODs, bool);
125 
127 
134  vtkSetMacro(PolyLODsBaseSize, size_t);
135  vtkGetMacro(PolyLODsBaseSize, size_t);
137 
139 
143  vtkSetStringMacro(PolyLODsBaseUrl);
144  vtkGetStringMacro(PolyLODsBaseUrl);
146 
147 protected:
149  ~vtkJSONSceneExporter() override;
150 
151  void WritePropCollection(vtkPropCollection* collection, std::ostream& sceneComponents);
152  void WriteVolumeCollection(vtkVolumeCollection* volumeCollection, std::ostream& sceneComponents);
153 
154  void WriteDataObject(ostream& os, vtkDataObject* dataObject, vtkActor* actor, vtkVolume* volume);
155  std::string ExtractPiecewiseFunctionSetup(vtkPiecewiseFunction* pwf);
156  std::string ExtractColorTransferFunctionSetup(vtkColorTransferFunction* volume);
157  std::string ExtractVolumeRenderingSetup(vtkVolume* volume);
158  std::string ExtractActorRenderingSetup(vtkActor* actor);
159  std::string WriteDataSet(vtkDataSet* dataset, const char* addOnMeta);
160  void WriteLookupTable(const char* name, vtkScalarsToColors* lookupTable);
161 
162  void WriteData() override;
163 
165 
169  std::string GetTemporaryPath() const;
171  std::string CurrentDataSetPath() const;
172 
173  std::string WriteTexture(vtkTexture* texture);
174  std::string WriteTextureLODSeries(vtkTexture* texture);
175 
176  // The returned pointer is the smallest poly LOD, intended to be
177  // written out in the vtkjs file.
178  vtkSmartPointer<vtkPolyData> WritePolyLODSeries(vtkPolyData* polys, std::string& config);
179 
180  char* FileName;
189  std::map<std::string, std::string> LookupTables;
190  std::map<vtkTexture*, std::string> TextureStrings;
191  std::map<vtkTexture*, std::string> TextureLODStrings;
192 
193  // Files that subclasses should zip
194  std::vector<std::string> FilesToZip;
195 
196 private:
198  void operator=(const vtkJSONSceneExporter&) = delete;
199 };
200 
201 #endif
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
abstract class to write a scene to a file
Definition: vtkExporter.h:47
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
virtual void WriteData()=0
std::map< vtkTexture *, std::string > TextureStrings
Defines a 1D piecewise function.
Export the content of a vtkRenderWindow into a directory with a JSON meta file describing the scene a...
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
an ordered list of Props
Superclass for mapping scalar values to colors.
a simple class to control print indentation
Definition: vtkIndent.h:39
an ordered list of volumes
std::vector< std::string > FilesToZip
handles properties associated with a texture map
Definition: vtkTexture.h:68
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::map< vtkTexture *, std::string > TextureLODStrings
void WriteDataSet(vtkUnstructuredGrid *grid, const std::string &file)
Defines a transfer function for mapping a property to an RGB color value.
std::map< std::string, std::string > LookupTables
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:65