VTK  9.4.20241218
vtkJSONSceneExporter.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
13#ifndef vtkJSONSceneExporter_h
14#define vtkJSONSceneExporter_h
15
16#include "vtkDataArraySelection.h" // Instantiated
17#include "vtkExporter.h"
18#include "vtkIOExportModule.h" // For export macro
19#include "vtkNew.h" // For vtkDataArraySelection
20#include "vtkSmartPointer.h" // For vtkSmartPointer
21
22#include <map> // For member variables
23#include <string> // For string parameter
24#include <vector> // For member variables
25
26VTK_ABI_NAMESPACE_BEGIN
27class vtkActor;
29class vtkDataObject;
30class vtkDataSet;
32class vtkPolyData;
35class vtkTexture;
36class vtkVolume;
38
39class VTKIOEXPORT_EXPORT vtkJSONSceneExporter : public vtkExporter
40{
41public:
44 void PrintSelf(ostream& os, vtkIndent indent) override;
45
47
54
56
61 vtkSetMacro(WriteTextures, bool);
62 vtkGetMacro(WriteTextures, bool);
64
66
75 vtkSetMacro(WriteTextureLODs, bool);
76 vtkGetMacro(WriteTextureLODs, bool);
78
80
85 vtkSetMacro(TextureLODsBaseSize, size_t);
86 vtkGetMacro(TextureLODsBaseSize, size_t);
88
90
94 vtkSetStringMacro(TextureLODsBaseUrl);
95 vtkGetStringMacro(TextureLODsBaseUrl);
97
99
113 vtkSetMacro(WritePolyLODs, bool);
114 vtkGetMacro(WritePolyLODs, bool);
116
118
125 vtkSetMacro(PolyLODsBaseSize, size_t);
126 vtkGetMacro(PolyLODsBaseSize, size_t);
128
130
134 vtkSetStringMacro(PolyLODsBaseUrl);
135 vtkGetStringMacro(PolyLODsBaseUrl);
137
139
146 vtkGetObjectMacro(PointArraySelection, vtkDataArraySelection);
147 vtkGetObjectMacro(CellArraySelection, vtkDataArraySelection);
149
151
159 void SetNamedActorsMap(std::map<std::string, vtkActor*>& map);
160 std::map<std::string, vtkActor*> GetNamedActorsMap();
162
163protected:
166
167 void WritePropCollection(vtkPropCollection* collection, std::ostream& sceneComponents);
168 void WriteVolumeCollection(vtkVolumeCollection* volumeCollection, std::ostream& sceneComponents);
169
174 void WriteLookupTable(const char* name, vtkScalarsToColors* lookupTable);
175
176 void WriteData() override;
177
179
183 std::string GetTemporaryPath() const;
185 std::string CurrentDataSetPath() const;
186
187 std::string WriteTexture(vtkTexture* texture);
188 std::string WriteTextureLODSeries(vtkTexture* texture);
189
190 // The returned pointer is the smallest poly LOD, intended to be
191 // written out in the vtkjs file.
193
194 char* FileName;
203 std::map<std::string, std::string> LookupTables;
204 std::map<vtkTexture*, std::string> TextureStrings;
205 std::map<vtkTexture*, std::string> TextureLODStrings;
206
207 // Files that subclasses should zip
208 std::vector<std::string> FilesToZip;
209
210private:
212 void operator=(const vtkJSONSceneExporter&) = delete;
213
217 void WriteNamedActors(std::map<std::string, vtkActor*>& actorMap, std::ostream& sceneComponents);
218
222 std::string WriteDataSet(vtkDataSet* dataset, const char* addOnMeta, const char* name);
223
231 void WriteDataObject(
232 ostream& os, vtkDataObject* dataObject, vtkActor* actor, vtkVolume* volume, const char* name);
233
234 // Map named sources with their data array selection
235 vtkNew<vtkDataArraySelection> PointArraySelection;
236 vtkNew<vtkDataArraySelection> CellArraySelection;
237 std::map<std::string, vtkActor*> NamedActorsMap;
238};
239
240VTK_ABI_NAMESPACE_END
241#endif
void WriteDataSet(vtkUnstructuredGrid *grid, const std::string &file)
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
Defines a transfer function for mapping a property to an RGB color value.
Store on/off settings for data arrays, etc.
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
abstract class to write a scene to a file
Definition vtkExporter.h:37
a simple class to control print indentation
Definition vtkIndent.h:108
Export the content of a vtkRenderWindow into a directory with a JSON meta file describing the scene a...
void WriteVolumeCollection(vtkVolumeCollection *volumeCollection, std::ostream &sceneComponents)
std::string CurrentDataSetPath() const
std::string WriteTexture(vtkTexture *texture)
vtkSmartPointer< vtkPolyData > WritePolyLODSeries(vtkPolyData *polys, std::string &config)
std::string ExtractActorRenderingSetup(vtkActor *actor)
std::string GetTemporaryPath() const
Path to temporary folder where files are written to before being renamed to this->FileName.
std::string ExtractVolumeRenderingSetup(vtkVolume *volume)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSetFilePathMacro(FileName)
Specify file name of vtk data file to write.
std::string ExtractPiecewiseFunctionSetup(vtkPiecewiseFunction *pwf)
std::string ExtractColorTransferFunctionSetup(vtkColorTransferFunction *volume)
~vtkJSONSceneExporter() override
void WritePropCollection(vtkPropCollection *collection, std::ostream &sceneComponents)
void SetNamedActorsMap(std::map< std::string, vtkActor * > &map)
Instead of using a render window that contains a scene to be written, use a map of named actors whose...
void WriteLookupTable(const char *name, vtkScalarsToColors *lookupTable)
void WriteData() override
std::map< std::string, vtkActor * > GetNamedActorsMap()
Instead of using a render window that contains a scene to be written, use a map of named actors whose...
std::vector< std::string > FilesToZip
static vtkJSONSceneExporter * New()
vtkGetFilePathMacro(FileName)
Specify file name of vtk data file to write.
std::string WriteTextureLODSeries(vtkTexture *texture)
std::map< std::string, std::string > LookupTables
std::map< vtkTexture *, std::string > TextureStrings
std::map< vtkTexture *, std::string > TextureLODStrings
Allocate and hold a VTK object.
Definition vtkNew.h:167
Defines a 1D piecewise function.
concrete dataset represents vertices, lines, polygons, and triangle strips
an ordered list of Props
Superclass for mapping scalar values to colors.
Hold a reference to a vtkObjectBase instance.
handles properties associated with a texture map
Definition vtkTexture.h:168
an ordered list of volumes
represents a volume (data & properties) in a rendered scene
Definition vtkVolume.h:130