VTK  9.2.6
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 
89  std::string GetValidString(const char*);
91 
93 
101  bool WriteArrayContents(vtkDataArray*, VTK_FILEPATH const char* relativeFilePath);
103 
105 
109  static bool WriteArrayAsRAW(vtkDataArray*, VTK_FILEPATH const char* filePath);
111 
112  static vtkJSONDataSetWriter* New();
114  void PrintSelf(ostream& os, vtkIndent indent) override;
115 
117 
120  vtkDataSet* GetInput();
121  vtkDataSet* GetInput(int port);
123 
125 
128  virtual void SetArchiver(vtkArchiver*);
129  vtkGetObjectMacro(Archiver, vtkArchiver);
131 
132  void Write(vtkDataSet*);
133 
134  bool IsDataSetValid() { return this->ValidDataSet; }
135 
136 protected:
138  ~vtkJSONDataSetWriter() override;
139 
140  void WriteData() final;
141  std::string WriteArray(vtkDataArray*, const char* className, const char* arrayName = nullptr);
142  std::string WriteDataSetAttributes(vtkDataSetAttributes* fields, const char* className);
143 
144  vtkArchiver* Archiver;
145  bool ValidDataSet;
146  int ValidStringCount;
147 
148  int FillInputPortInformation(int port, vtkInformation* info) override;
149 
150 private:
152  void operator=(const vtkJSONDataSetWriter&) = delete;
153 };
154 
155 #endif
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
write vtkDataSet using a vtkArchiver with a JSON meta file along with all the binary arrays written a...
abstract class to write data to file(s)
Definition: vtkWriter.h:45
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkDataObject * GetInput()
Writes an archive.
Definition: vtkArchiver.h:39
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
represent and manipulate attribute data in a dataset
#define VTK_FILEPATH
virtual int Write()
Write data to output.
static vtkAlgorithm * New()
virtual void WriteData()=0