VTK  9.1.0
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 "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_0_0
44#include "vtkWriter.h"
45
46#include <string> // std::string used as parameters in a few methods
47
48class vtkDataSet;
49class vtkDataArray;
51class vtkArchiver;
52
53class VTKIOEXPORT_EXPORT vtkJSONDataSetWriter : public vtkWriter
54{
55public:
56 using vtkWriter::Write;
57
59
63 static void ComputeMD5(const unsigned char* content, int size, std::string& hash);
65
67
75 static std::string GetShortType(vtkDataArray* input, bool& needConversion);
77
79
83 static std::string GetUID(vtkDataArray*, bool& needConversion);
85
87
92
94
102 bool WriteArrayContents(vtkDataArray*, VTK_FILEPATH const char* relativeFilePath);
104
106
110 static bool WriteArrayAsRAW(vtkDataArray*, VTK_FILEPATH const char* filePath);
112
115 void PrintSelf(ostream& os, vtkIndent indent) override;
116
118
123 VTK_DEPRECATED_IN_9_0_0("Use vtkJSONDataSetWriter::SetArchiveName")
124 void SetFileName(VTK_FILEPATH const char*);
125 VTK_DEPRECATED_IN_9_0_0("Use vtkJSONDataSetWriter::GetArchiveName")
126 virtual VTK_FILEPATH char* GetFileName();
128
130
133 vtkDataSet* GetInput();
134 vtkDataSet* GetInput(int port);
136
138
141 virtual void SetArchiver(vtkArchiver*);
142 vtkGetObjectMacro(Archiver, vtkArchiver);
144
145 void Write(vtkDataSet*);
146
147 bool IsDataSetValid() { return this->ValidDataSet; }
148
149protected:
152
153 void WriteData() final;
154 std::string WriteArray(vtkDataArray*, const char* className, const char* arrayName = nullptr);
155 std::string WriteDataSetAttributes(vtkDataSetAttributes* fields, const char* className);
156
157 vtkArchiver* Archiver;
158 bool ValidDataSet;
159 int ValidStringCount;
160
161 int FillInputPortInformation(int port, vtkInformation* info) override;
162
163private:
165 void operator=(const vtkJSONDataSetWriter&) = delete;
166};
167
168#endif
Writes an archive.
Definition: vtkArchiver.h:37
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
represent and manipulate attribute data in a dataset
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
a simple class to control print indentation
Definition: vtkIndent.h:113
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,...
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.
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.
static vtkJSONDataSetWriter * New()
~vtkJSONDataSetWriter() override
static bool WriteArrayAsRAW(vtkDataArray *, VTK_FILEPATH const char *filePath)
For backwards compatiblity, 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.
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
std::string GetFileName(const std::string &fileName) noexcept
Set the appropriate file name based on recognized user input.
#define VTK_DEPRECATED_IN_9_0_0(reason)
#define VTK_FILEPATH