VTK  9.1.0
vtkDataWriter.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkDataWriter.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=========================================================================*/
29#ifndef vtkDataWriter_h
30#define vtkDataWriter_h
31
32#include "vtkIOLegacyModule.h" // For export macro
33#include "vtkWriter.h"
34
35#include <locale> // For locale settings
36
37class vtkCellArray;
38class vtkDataArray;
39class vtkDataSet;
40class vtkFieldData;
41class vtkGraph;
42class vtkInformation;
44class vtkPoints;
45class vtkTable;
46
47class VTKIOLEGACY_EXPORT vtkDataWriter : public vtkWriter
48{
49public:
51
54 vtkTypeMacro(vtkDataWriter, vtkWriter);
55 void PrintSelf(ostream& os, vtkIndent indent) override;
57
62 static vtkDataWriter* New();
63
65
71
72 // Currently VTK can write out two different versions of file format: files
73 // of VTK reader version 4.2 and previous; and VTK reader version 5.1 and
74 // later. This will likely change in the future. (Note: the major
75 // difference in the two formats is the way cell arrays are written out.)
76 // By default, Version 5.1 files are written out.
78 {
79 VTK_LEGACY_READER_VERSION_4_2 = 42,
80 VTK_LEGACY_READER_VERSION_5_1 = 51
81 };
82
84
93 void SetFileVersion(int);
94 vtkGetMacro(FileVersion, int);
95 vtkGetMacro(FileMajorVersion, int);
96 vtkGetMacro(FileMinorVersion, int);
98
100
103 vtkSetMacro(WriteToOutputString, vtkTypeBool);
104 vtkGetMacro(WriteToOutputString, vtkTypeBool);
105 vtkBooleanMacro(WriteToOutputString, vtkTypeBool);
107
109
114 vtkGetMacro(OutputStringLength, vtkIdType);
115 vtkGetStringMacro(OutputString);
116 unsigned char* GetBinaryOutputString()
117 {
118 return reinterpret_cast<unsigned char*>(this->OutputString);
119 }
121
127
134
136
139 vtkSetStringMacro(Header);
140 vtkGetStringMacro(Header);
142
144
148 vtkSetMacro(WriteArrayMetaData, bool);
149 vtkGetMacro(WriteArrayMetaData, bool);
150 vtkBooleanMacro(WriteArrayMetaData, bool);
152
154
157 vtkSetClampMacro(FileType, int, VTK_ASCII, VTK_BINARY);
158 vtkGetMacro(FileType, int);
159 void SetFileTypeToASCII() { this->SetFileType(VTK_ASCII); }
160 void SetFileTypeToBinary() { this->SetFileType(VTK_BINARY); }
162
164
168 vtkSetStringMacro(ScalarsName);
169 vtkGetStringMacro(ScalarsName);
171
173
177 vtkSetStringMacro(VectorsName);
178 vtkGetStringMacro(VectorsName);
180
182
186 vtkSetStringMacro(TensorsName);
187 vtkGetStringMacro(TensorsName);
189
191
195 vtkSetStringMacro(NormalsName);
196 vtkGetStringMacro(NormalsName);
198
200
204 vtkSetStringMacro(TCoordsName);
205 vtkGetStringMacro(TCoordsName);
207
209
213 vtkSetStringMacro(GlobalIdsName);
214 vtkGetStringMacro(GlobalIdsName);
216
218
222 vtkSetStringMacro(PedigreeIdsName);
223 vtkGetStringMacro(PedigreeIdsName);
225
227
231 vtkSetStringMacro(EdgeFlagsName);
232 vtkGetStringMacro(EdgeFlagsName);
234
236
240 vtkSetStringMacro(LookupTableName);
241 vtkGetStringMacro(LookupTableName);
243
245
249 vtkSetStringMacro(FieldDataName);
250 vtkGetStringMacro(FieldDataName);
252
256 virtual ostream* OpenVTKFile();
257
261 int WriteHeader(ostream* fp);
262
266 int WritePoints(ostream* fp, vtkPoints* p);
267
271 int WriteCoordinates(ostream* fp, vtkDataArray* coords, int axes);
272
276 int WriteCells(ostream* fp, vtkCellArray* cells, const char* label);
277
282 int WriteCellsLegacy(ostream* fp, vtkCellArray* cells, const char* label);
283
288 int WriteCellData(ostream* fp, vtkDataSet* ds);
289
294 int WritePointData(ostream* fp, vtkDataSet* ds);
295
300 int WriteEdgeData(ostream* fp, vtkGraph* g);
301
306 int WriteVertexData(ostream* fp, vtkGraph* g);
307
312 int WriteRowData(ostream* fp, vtkTable* g);
313
317 int WriteFieldData(ostream* fp, vtkFieldData* f);
318
323 int WriteDataSetData(ostream* fp, vtkDataSet* ds);
324
328 void CloseVTKFile(ostream* fp);
329
330protected:
332 ~vtkDataWriter() override;
333
337
338 void WriteData() override; // dummy method to allow this class to be instantiated and delegated to
339
340 char* FileName;
344 char* Header;
346
348
359
360 std::locale CurrentLocale;
361
362 int WriteArray(ostream* fp, int dataType, vtkAbstractArray* data, const char* format,
363 vtkIdType num, vtkIdType numComp);
364 int WriteScalarData(ostream* fp, vtkDataArray* s, vtkIdType num);
365 int WriteVectorData(ostream* fp, vtkDataArray* v, vtkIdType num);
366 int WriteNormalData(ostream* fp, vtkDataArray* n, vtkIdType num);
367 int WriteTCoordData(ostream* fp, vtkDataArray* tc, vtkIdType num);
368 int WriteTensorData(ostream* fp, vtkDataArray* t, vtkIdType num);
369 int WriteGlobalIdData(ostream* fp, vtkDataArray* g, vtkIdType num);
371 int WriteEdgeFlagsData(ostream* fp, vtkDataArray* edgeFlags, vtkIdType num);
372
374
378 int WriteInformation(ostream* fp, vtkInformation* info);
379
380private:
381 vtkDataWriter(const vtkDataWriter&) = delete;
382 void operator=(const vtkDataWriter&) = delete;
383};
384
385#endif
Abstract superclass for all arrays.
object to represent cell connectivity
Definition: vtkCellArray.h:290
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
helper class for objects that write VTK data files
Definition: vtkDataWriter.h:48
vtkSetFilePathMacro(FileName)
Specify the file name of VTK data file to write.
int WriteEdgeData(ostream *fp, vtkGraph *g)
Write the edge data (e.g., scalars, vectors, ...) of a vtk graph.
int WriteTCoordData(ostream *fp, vtkDataArray *tc, vtkIdType num)
int WritePointData(ostream *fp, vtkDataSet *ds)
Write the point data (e.g., scalars, vectors, ...) of a vtk dataset.
int WriteDataSetData(ostream *fp, vtkDataSet *ds)
Write out the data associated with the dataset (i.e.
char * LookupTableName
void SetFileVersion(int)
Specify the VTK file version to write.
char * EdgeFlagsName
vtkStdString GetOutputStdString()
When WriteToOutputString is on, this method returns a copy of the output string in a vtkStdString.
void WriteData() override
char * VectorsName
void SetFileTypeToBinary()
Specify the file type (ASCII or BINARY) of the VTK data file.
int WriteGlobalIdData(ostream *fp, vtkDataArray *g, vtkIdType num)
char * TCoordsName
char * NormalsName
int WriteInformation(ostream *fp, vtkInformation *info)
Format is detailed here.
char * ScalarsName
int WriteVertexData(ostream *fp, vtkGraph *g)
Write the vertex data (e.g., scalars, vectors, ...) of a vtk graph.
vtkIdType OutputStringLength
int WriteTensorData(ostream *fp, vtkDataArray *t, vtkIdType num)
int WriteHeader(ostream *fp)
Write the header of a vtk data file.
int WriteCells(ostream *fp, vtkCellArray *cells, const char *label)
Write out the cells of the data set.
virtual ostream * OpenVTKFile()
Open a vtk data file.
static vtkDataWriter * New()
Create object with default header, ASCII format, and default names for scalars, vectors,...
int WriteCoordinates(ostream *fp, vtkDataArray *coords, int axes)
Write out coordinates for rectilinear grids.
char * FieldDataName
char * PedigreeIdsName
void CloseVTKFile(ostream *fp)
Close a vtk file.
char * OutputString
char * RegisterAndGetOutputString()
This convenience method returns the string, sets the IVAR to nullptr, so that the user is responsible...
char * GlobalIdsName
int WriteEdgeFlagsData(ostream *fp, vtkDataArray *edgeFlags, vtkIdType num)
int WriteNormalData(ostream *fp, vtkDataArray *n, vtkIdType num)
int WriteArray(ostream *fp, int dataType, vtkAbstractArray *data, const char *format, vtkIdType num, vtkIdType numComp)
int WriteScalarData(ostream *fp, vtkDataArray *s, vtkIdType num)
int WritePoints(ostream *fp, vtkPoints *p)
Write out the points of the data set.
int WriteFieldData(ostream *fp, vtkFieldData *f)
Write out the field data.
void SetFileTypeToASCII()
Specify the file type (ASCII or BINARY) of the VTK data file.
std::locale CurrentLocale
char * TensorsName
~vtkDataWriter() override
int WriteCellsLegacy(ostream *fp, vtkCellArray *cells, const char *label)
Write out the cells of the data set.
unsigned char * GetBinaryOutputString()
When WriteToOutputString in on, then a string is allocated, written to, and can be retrieved with the...
int WriteVectorData(ostream *fp, vtkDataArray *v, vtkIdType num)
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and printing.
vtkGetFilePathMacro(FileName)
Specify the file name of VTK data file to write.
bool WriteArrayMetaData
int WriteCellData(ostream *fp, vtkDataSet *ds)
Write the cell data (e.g., scalars, vectors, ...) of a vtk dataset.
vtkTypeBool WriteToOutputString
int WriteRowData(ostream *fp, vtkTable *g)
Write the row data (e.g., scalars, vectors, ...) of a vtk table.
bool CanWriteInformationKey(vtkInformation *info, vtkInformationKey *key)
int WritePedigreeIdData(ostream *fp, vtkAbstractArray *p, vtkIdType num)
represent and manipulate fields of data
Definition: vtkFieldData.h:164
Base class for graph data types.
Definition: vtkGraph.h:339
a simple class to control print indentation
Definition: vtkIndent.h:113
Superclass for vtkInformation keys.
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition: vtkPoints.h:143
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:105
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:172
abstract class to write data to file(s)
Definition: vtkWriter.h:46
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:332
#define VTK_BINARY
Definition: vtkWriter.h:43
#define VTK_ASCII
Definition: vtkWriter.h:42