VTK  9.3.0
vtkXMLWriterBase.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
16 #ifndef vtkXMLWriterBase_h
17 #define vtkXMLWriterBase_h
18 
19 #include "vtkAlgorithm.h"
20 #include "vtkIOXMLModule.h" // For export macro
21 
22 #include <string> // for std::string
23 
24 VTK_ABI_NAMESPACE_BEGIN
25 class vtkDataCompressor;
26 
27 class VTKIOXML_EXPORT vtkXMLWriterBase : public vtkAlgorithm
28 {
29 public:
31  void PrintSelf(ostream& os, vtkIndent indent) override;
32 
36  enum
37  {
39  LittleEndian
40  };
41 
48  enum
49  {
52  Appended
53  };
54 
60  enum
61  {
62  Int32 = 32,
63  Int64 = 64
64  };
65 
71  enum
72  {
73  UInt32 = 32,
74  UInt64 = 64
75  };
76 
78 
82  vtkSetMacro(ByteOrder, int);
83  vtkGetMacro(ByteOrder, int);
84  void SetByteOrderToBigEndian() { this->SetByteOrder(BigEndian); }
85  void SetByteOrderToLittleEndian() { this->SetByteOrder(LittleEndian); }
87 
89 
93  virtual void SetHeaderType(int);
94  vtkGetMacro(HeaderType, int);
95  void SetHeaderTypeToUInt32() { this->SetHeaderType(UInt32); }
96  void SetHeaderTypeToUInt64() { this->SetHeaderType(UInt64); }
98 
100 
104  virtual void SetIdType(int);
105  vtkGetMacro(IdType, int);
106  void SetIdTypeToInt32() { this->SetIdType(Int32); }
107  void SetIdTypeToInt64() { this->SetIdType(Int64); }
109 
111 
117 
119 
122  vtkSetMacro(WriteToOutputString, bool);
123  vtkGetMacro(WriteToOutputString, bool);
124  vtkBooleanMacro(WriteToOutputString, bool);
125  std::string GetOutputString() { return this->OutputString; }
127 
129 
134  vtkGetObjectMacro(Compressor, vtkDataCompressor);
136 
138  {
142  LZMA
143  };
144 
146 
149  void SetCompressorType(int compressorType);
150  void SetCompressorTypeToNone() { this->SetCompressorType(NONE); }
151  void SetCompressorTypeToLZ4() { this->SetCompressorType(LZ4); }
152  void SetCompressorTypeToZLib() { this->SetCompressorType(ZLIB); }
153  void SetCompressorTypeToLZMA() { this->SetCompressorType(LZMA); }
155 
157 
161  void SetCompressionLevel(int compressorLevel);
162  vtkGetMacro(CompressionLevel, int);
164 
166 
172  virtual void SetBlockSize(size_t blockSize);
173  vtkGetMacro(BlockSize, size_t);
175 
177 
182  vtkSetMacro(DataMode, int);
183  vtkGetMacro(DataMode, int);
184  void SetDataModeToAscii() { this->SetDataMode(Ascii); }
185  void SetDataModeToBinary() { this->SetDataMode(Binary); }
186  void SetDataModeToAppended() { this->SetDataMode(Appended); }
188 
190 
197  vtkSetMacro(EncodeAppendedData, bool);
198  vtkGetMacro(EncodeAppendedData, bool);
199  vtkBooleanMacro(EncodeAppendedData, bool);
201 
205  virtual const char* GetDefaultFileExtension() = 0;
206 
210  int Write();
211 
212 protected:
214  ~vtkXMLWriterBase() override;
215 
216  // Methods to define the file's major and minor version numbers.
217  virtual int GetDataSetMajorVersion();
218  virtual int GetDataSetMinorVersion();
219 
220  // The name of the output file.
221  char* FileName;
222 
223  // Whether this object is writing to a string or a file.
224  // Default is 0: write to file.
226 
227  // The output string.
229 
230  // The output byte order.
232 
233  // The output binary header word type.
235 
236  // The output vtkIdType.
237  int IdType;
238 
239  // The form of binary data to write. Used by subclasses to choose
240  // how to write data.
241  int DataMode;
242 
243  // Whether to base64-encode the appended data section.
245 
246  // Compression information.
248  size_t BlockSize;
249 
250  // Compression Level for vtkDataCompressor objects
251  // 1 (worst compression, fastest) ... 9 (best compression, slowest)
253 
254  // This variable is used to ease transition to new versions of VTK XML files.
255  // If data that needs to be written satisfies certain conditions,
256  // the writer can use the previous file version version.
257  // For version change 0.1 -> 2.0 (UInt32 header) and 1.0 -> 2.0
258  // (UInt64 header), if data does not have a vtkGhostType array,
259  // the file is written with version: 0.1/1.0.
261 
262 private:
263  vtkXMLWriterBase(const vtkXMLWriterBase&) = delete;
264  void operator=(const vtkXMLWriterBase&) = delete;
265 };
266 
267 VTK_ABI_NAMESPACE_END
268 #endif
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:52
Abstract interface for data compression classes.
a simple class to control print indentation
Definition: vtkIndent.h:29
Abstract base class for VTK-XML writers.
void SetByteOrderToBigEndian()
Get/Set the byte order of data written to the file.
virtual void SetIdType(int)
Get/Set the size of the vtkIdType values stored in the file.
vtkDataCompressor * Compressor
vtkGetFilePathMacro(FileName)
Get/Set the name of the output file.
int Write()
Invoke the writer.
vtkSetFilePathMacro(FileName)
Get/Set the name of the output file.
virtual int GetDataSetMajorVersion()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetHeaderType(int)
Get/Set the binary data header word type.
void SetIdTypeToInt32()
Get/Set the size of the vtkIdType values stored in the file.
void SetDataModeToBinary()
Get/Set the data mode used for the file's data.
void SetDataModeToAscii()
Get/Set the data mode used for the file's data.
void SetCompressionLevel(int compressorLevel)
Get/Set compression level.
void SetCompressorTypeToLZMA()
Convenience functions to set the compressor to certain known types.
virtual int GetDataSetMinorVersion()
void SetCompressorTypeToNone()
Convenience functions to set the compressor to certain known types.
void SetHeaderTypeToUInt32()
Get/Set the binary data header word type.
virtual const char * GetDefaultFileExtension()=0
Get the default file extension for files written by this writer.
void SetCompressorTypeToLZ4()
Convenience functions to set the compressor to certain known types.
virtual void SetCompressor(vtkDataCompressor *)
Get/Set the compressor used to compress binary and appended data before writing to the file.
void SetIdTypeToInt64()
Get/Set the size of the vtkIdType values stored in the file.
std::string OutputString
~vtkXMLWriterBase() override
void SetHeaderTypeToUInt64()
Get/Set the binary data header word type.
void SetCompressorTypeToZLib()
Convenience functions to set the compressor to certain known types.
virtual void SetBlockSize(size_t blockSize)
Get/Set the block size used in compression.
void SetByteOrderToLittleEndian()
Get/Set the byte order of data written to the file.
void SetCompressorType(int compressorType)
Convenience functions to set the compressor to certain known types.
void SetDataModeToAppended()
Get/Set the data mode used for the file's data.
std::string GetOutputString()
Enable writing to an OutputString instead of the default, a file.
@ string
Definition: vtkX3D.h:490