VTK  9.3.0
vtkJSONDataSetWriter.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
26 #ifndef vtkJSONDataSetWriter_h
27 #define vtkJSONDataSetWriter_h
28 
29 #include "vtkIOExportModule.h" // For export macro
30 
31 #include "vtkWriter.h"
32 
33 #include <string> // std::string used as parameters in a few methods
34 
35 VTK_ABI_NAMESPACE_BEGIN
36 class vtkDataSet;
37 class vtkDataArray;
39 class vtkArchiver;
40 
41 class VTKIOEXPORT_EXPORT vtkJSONDataSetWriter : public vtkWriter
42 {
43 public:
44  using vtkWriter::Write;
45 
47 
51  static void ComputeMD5(const unsigned char* content, int size, std::string& hash);
53 
55 
63  static std::string GetShortType(vtkDataArray* input, bool& needConversion);
65 
67 
71  static std::string GetUID(vtkDataArray*, bool& needConversion);
73 
75 
80 
82 
90  bool WriteArrayContents(vtkDataArray*, VTK_FILEPATH const char* relativeFilePath);
92 
94 
98  static bool WriteArrayAsRAW(vtkDataArray*, VTK_FILEPATH const char* filePath);
100 
103  void PrintSelf(ostream& os, vtkIndent indent) override;
104 
106 
112 
114 
117  virtual void SetArchiver(vtkArchiver*);
118  vtkGetObjectMacro(Archiver, vtkArchiver);
120 
122 
123  bool IsDataSetValid() { return this->ValidDataSet; }
124 
125 protected:
128 
129  void WriteData() final;
130  std::string WriteArray(vtkDataArray*, const char* className, const char* arrayName = nullptr);
131  std::string WriteDataSetAttributes(vtkDataSetAttributes* fields, const char* className);
132 
133  vtkArchiver* Archiver;
134  bool ValidDataSet;
135  int ValidStringCount;
136 
137  int FillInputPortInformation(int port, vtkInformation* info) override;
138 
139 private:
141  void operator=(const vtkJSONDataSetWriter&) = delete;
142 };
143 
144 VTK_ABI_NAMESPACE_END
145 #endif
Writes an archive.
Definition: vtkArchiver.h:29
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
represent and manipulate attribute data in a dataset
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
a simple class to control print indentation
Definition: vtkIndent.h:38
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)
Get the input to this writer.
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 *)
bool WriteArrayContents(vtkDataArray *, VTK_FILEPATH const char *relativeFilePath)
Write the contents of the vtkDataArray to disk based on the filePath provided without any extra infor...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void WriteData() final
static std::string GetUID(vtkDataArray *, bool &needConversion)
Return a Unique identifier for that array (i.e.
~vtkJSONDataSetWriter() override
static vtkJSONDataSetWriter * New()
static bool WriteArrayAsRAW(vtkDataArray *, VTK_FILEPATH const char *filePath)
For backwards compatibility, this static method writes a data array's contents directly to a file.
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:35
virtual int Write()
Write data to output.
@ info
Definition: vtkX3D.h:376
@ port
Definition: vtkX3D.h:447
@ content
Definition: vtkX3D.h:302
@ size
Definition: vtkX3D.h:253
@ string
Definition: vtkX3D.h:490
#define VTK_FILEPATH