VTK  9.1.0
vtkXMLWriterBase.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkXMLWriterBase.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 =========================================================================*/
28 #ifndef vtkXMLWriterBase_h
29 #define vtkXMLWriterBase_h
30 
31 #include "vtkAlgorithm.h"
32 #include "vtkIOXMLModule.h" // For export macro
33 
34 #include <string> // for std::string
35 
36 class vtkDataCompressor;
37 
38 class VTKIOXML_EXPORT vtkXMLWriterBase : public vtkAlgorithm
39 {
40 public:
42  void PrintSelf(ostream& os, vtkIndent indent) override;
43 
47  enum
48  {
50  LittleEndian
51  };
52 
59  enum
60  {
63  Appended
64  };
65 
71  enum
72  {
73  Int32 = 32,
74  Int64 = 64
75  };
76 
82  enum
83  {
84  UInt32 = 32,
85  UInt64 = 64
86  };
87 
89 
93  vtkSetMacro(ByteOrder, int);
94  vtkGetMacro(ByteOrder, int);
95  void SetByteOrderToBigEndian() { this->SetByteOrder(BigEndian); }
96  void SetByteOrderToLittleEndian() { this->SetByteOrder(LittleEndian); }
98 
100 
104  virtual void SetHeaderType(int);
105  vtkGetMacro(HeaderType, int);
106  void SetHeaderTypeToUInt32() { this->SetHeaderType(UInt32); }
107  void SetHeaderTypeToUInt64() { this->SetHeaderType(UInt64); }
109 
111 
115  virtual void SetIdType(int);
116  vtkGetMacro(IdType, int);
117  void SetIdTypeToInt32() { this->SetIdType(Int32); }
118  void SetIdTypeToInt64() { this->SetIdType(Int64); }
120 
122 
128 
130 
133  vtkSetMacro(WriteToOutputString, bool);
134  vtkGetMacro(WriteToOutputString, bool);
135  vtkBooleanMacro(WriteToOutputString, bool);
136  std::string GetOutputString() { return this->OutputString; }
138 
140 
145  vtkGetObjectMacro(Compressor, vtkDataCompressor);
147 
149  {
153  LZMA
154  };
155 
157 
160  void SetCompressorType(int compressorType);
161  void SetCompressorTypeToNone() { this->SetCompressorType(NONE); }
162  void SetCompressorTypeToLZ4() { this->SetCompressorType(LZ4); }
163  void SetCompressorTypeToZLib() { this->SetCompressorType(ZLIB); }
164  void SetCompressorTypeToLZMA() { this->SetCompressorType(LZMA); }
166 
168 
172  void SetCompressionLevel(int compressorLevel);
173  vtkGetMacro(CompressionLevel, int);
175 
177 
183  virtual void SetBlockSize(size_t blockSize);
184  vtkGetMacro(BlockSize, size_t);
186 
188 
193  vtkSetMacro(DataMode, int);
194  vtkGetMacro(DataMode, int);
195  void SetDataModeToAscii() { this->SetDataMode(Ascii); }
196  void SetDataModeToBinary() { this->SetDataMode(Binary); }
197  void SetDataModeToAppended() { this->SetDataMode(Appended); }
199 
201 
208  vtkSetMacro(EncodeAppendedData, bool);
209  vtkGetMacro(EncodeAppendedData, bool);
210  vtkBooleanMacro(EncodeAppendedData, bool);
212 
216  virtual const char* GetDefaultFileExtension() = 0;
217 
221  int Write();
222 
223 protected:
225  ~vtkXMLWriterBase() override;
226 
227  // Methods to define the file's major and minor version numbers.
228  virtual int GetDataSetMajorVersion();
229  virtual int GetDataSetMinorVersion();
230 
231  // The name of the output file.
232  char* FileName;
233 
234  // Whether this object is writing to a string or a file.
235  // Default is 0: write to file.
237 
238  // The output string.
240 
241  // The output byte order.
243 
244  // The output binary header word type.
246 
247  // The output vtkIdType.
248  int IdType;
249 
250  // The form of binary data to write. Used by subclasses to choose
251  // how to write data.
252  int DataMode;
253 
254  // Whether to base64-encode the appended data section.
256 
257  // Compression information.
259  size_t BlockSize;
260 
261  // Compression Level for vtkDataCompressor objects
262  // 1 (worst compression, fastest) ... 9 (best compression, slowest)
264 
265  // This variable is used to ease transition to new versions of VTK XML files.
266  // If data that needs to be written satisfies certain conditions,
267  // the writer can use the previous file version version.
268  // For version change 0.1 -> 2.0 (UInt32 header) and 1.0 -> 2.0
269  // (UInt64 header), if data does not have a vtkGhostType array,
270  // the file is written with version: 0.1/1.0.
272 
273 private:
274  vtkXMLWriterBase(const vtkXMLWriterBase&) = delete;
275  void operator=(const vtkXMLWriterBase&) = delete;
276 };
277 
278 #endif
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:64
Abstract interface for data compression classes.
a simple class to control print indentation
Definition: vtkIndent.h:34
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:496