VTK  9.4.20241219
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#include "vtkDataArraySelection.h" // Instantiated
36#include "vtkNew.h" // Used for DataArray selection
37
38VTK_ABI_NAMESPACE_BEGIN
39class vtkDataSet;
40class vtkDataArray;
42class vtkArchiver;
43
44class VTKIOEXPORT_EXPORT vtkJSONDataSetWriter : public vtkWriter
45{
46public:
47 using vtkWriter::Write;
48
50
54 static void ComputeMD5(const unsigned char* content, int size, std::string& hash);
56
58
66 static std::string GetShortType(vtkDataArray* input, bool& needConversion);
68
70
74 static std::string GetUID(vtkDataArray*, bool& needConversion);
76
78
81 std::string GetValidString(const char*);
83
85
93 bool WriteArrayContents(vtkDataArray*, VTK_FILEPATH const char* relativeFilePath);
95
97
101 static bool WriteArrayAsRAW(vtkDataArray*, VTK_FILEPATH const char* filePath);
103
106 void PrintSelf(ostream& os, vtkIndent indent) override;
107
109
115
117
120 virtual void SetArchiver(vtkArchiver*);
121 vtkGetObjectMacro(Archiver, vtkArchiver);
123
127 vtkGetObjectMacro(PointArraySelection, vtkDataArraySelection);
128
132 vtkGetObjectMacro(CellArraySelection, vtkDataArraySelection);
133
135
136 bool IsDataSetValid() { return this->ValidDataSet; }
137
138protected:
141
142 void WriteData() final;
143 std::string WriteArray(vtkDataArray*, const char* className, const char* arrayName = nullptr);
144 std::string WriteDataSetAttributes(vtkDataSetAttributes* fields, const char* className);
145
146 vtkArchiver* Archiver;
147 bool ValidDataSet;
148 int ValidStringCount;
149
150 int FillInputPortInformation(int port, vtkInformation* info) override;
151
152private:
154 void operator=(const vtkJSONDataSetWriter&) = delete;
155
156 vtkNew<vtkDataArraySelection> PointArraySelection;
157 vtkNew<vtkDataArraySelection> CellArraySelection;
158};
159
160VTK_ABI_NAMESPACE_END
161#endif
Writes an archive.
Definition vtkArchiver.h:29
Store on/off settings for data arrays, etc.
abstract superclass for arrays of numeric data
represent and manipulate attribute data in a dataset
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
a simple class to control print indentation
Definition vtkIndent.h:108
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(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
vtkDataSet * GetInput()
Get the input to this writer.
static std::string GetUID(vtkDataArray *, bool &needConversion)
Return a Unique identifier for that array (i.e.: Float32_356_13f880891af7b77262c49cae09a41e28 )
static vtkJSONDataSetWriter * New()
~vtkJSONDataSetWriter() override
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.
Allocate and hold a VTK object.
Definition vtkNew.h:167
abstract class to write data to file(s)
Definition vtkWriter.h:35
virtual int Write()
Write data to output.
#define VTK_FILEPATH