VTK  9.0.1
vtkJSONDataSetWriter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkJSONDataSetWriter.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 =========================================================================*/
38 #ifndef vtkJSONDataSetWriter_h
39 #define vtkJSONDataSetWriter_h
40 
41 #include "vtkIOExportModule.h" // For export macro
42 
43 #include "vtkWriter.h"
44 
45 #include <string> // std::string used as parameters in a few methods
46 
47 class vtkDataSet;
48 class vtkDataArray;
50 class vtkArchiver;
51 
52 class VTKIOEXPORT_EXPORT vtkJSONDataSetWriter : public vtkWriter
53 {
54 public:
55  using vtkWriter::Write;
56 
58 
62  static void ComputeMD5(const unsigned char* content, int size, std::string& hash);
64 
66 
74  static std::string GetShortType(vtkDataArray* input, bool& needConversion);
76 
78 
82  static std::string GetUID(vtkDataArray*, bool& needConversion);
84 
86 
91 
93 
101  bool WriteArrayContents(vtkDataArray*, const char* relativeFilePath);
103 
105 
109  static bool WriteArrayAsRAW(vtkDataArray*, const char* filePath);
111 
114  void PrintSelf(ostream& os, vtkIndent indent) override;
115 
117 
122  VTK_LEGACY(void SetFileName(const char*));
123  VTK_LEGACY(virtual char* GetFileName());
125 
127 
133 
135 
138  virtual void SetArchiver(vtkArchiver*);
139  vtkGetObjectMacro(Archiver, vtkArchiver);
141 
143 
144  bool IsDataSetValid() { return this->ValidDataSet; }
145 
146 protected:
149 
150  void WriteData() final;
151  std::string WriteArray(vtkDataArray*, const char* className, const char* arrayName = nullptr);
152  std::string WriteDataSetAttributes(vtkDataSetAttributes* fields, const char* className);
153 
154  vtkArchiver* Archiver;
155  bool ValidDataSet;
156  int ValidStringCount;
157 
158  int FillInputPortInformation(int port, vtkInformation* info) override;
159 
160 private:
162  void operator=(const vtkJSONDataSetWriter&) = delete;
163 };
164 
165 #endif
Writes an archive.
Definition: vtkArchiver.h:37
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
represent and manipulate attribute data in a dataset
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
a simple class to control print indentation
Definition: vtkIndent.h:34
Store vtkAlgorithm input/output information.
write vtkDataSet using a vtkArchiver with a JSON meta file along with all the binary arrays written a...
static std::string GetShortType(vtkDataArray *input, bool &needConversion)
Compute the target JavaScript typed array name for the given vtkDataArray (Uin8, Uint16,...
vtkDataSet * GetInput()
Get the input to this writer.
vtkDataSet * GetInput(int port)
static void ComputeMD5(const unsigned char *content, int size, std::string &hash)
Compute a MD5 digest of a void/(const unsigned char) pointer to compute a string hash.
void Write(vtkDataSet *)
virtual char * GetFileName()
static bool WriteArrayAsRAW(vtkDataArray *, const char *filePath)
For backwards compatiblity, this static method writes a data array's contents directly to a file.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void WriteData() final
bool WriteArrayContents(vtkDataArray *, const char *relativeFilePath)
Write the contents of the vtkDataArray to disk based on the filePath provided without any extra infor...
static std::string GetUID(vtkDataArray *, bool &needConversion)
Return a Unique identifier for that array (i.e.
~vtkJSONDataSetWriter() override
void SetFileName(const char *)
Specify file name of vtk data file to write.
static vtkJSONDataSetWriter * New()
std::string GetValidString(const char *)
Return a Unique identifier for any invalid string.
virtual void SetArchiver(vtkArchiver *)
Specify the Scene Archiver object.
abstract class to write data to file(s)
Definition: vtkWriter.h:43
virtual int Write()
Write data to output.
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
@ content
Definition: vtkX3D.h:308
@ size
Definition: vtkX3D.h:259
@ string
Definition: vtkX3D.h:496