VTK  9.0.1
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 
37 class vtkCellArray;
38 class vtkDataArray;
39 class vtkDataSet;
40 class vtkFieldData;
41 class vtkGraph;
42 class vtkInformation;
43 class vtkInformationKey;
44 class vtkPoints;
45 class vtkTable;
46 
47 class VTKIOLEGACY_EXPORT vtkDataWriter : public vtkWriter
48 {
49 public:
50  vtkTypeMacro(vtkDataWriter, vtkWriter);
51  void PrintSelf(ostream& os, vtkIndent indent) override;
52 
57  static vtkDataWriter* New();
58 
60 
63  vtkSetStringMacro(FileName);
64  vtkGetStringMacro(FileName);
66 
68 
71  vtkSetMacro(WriteToOutputString, vtkTypeBool);
72  vtkGetMacro(WriteToOutputString, vtkTypeBool);
73  vtkBooleanMacro(WriteToOutputString, vtkTypeBool);
75 
77 
82  vtkGetMacro(OutputStringLength, vtkIdType);
83  vtkGetStringMacro(OutputString);
84  unsigned char* GetBinaryOutputString()
85  {
86  return reinterpret_cast<unsigned char*>(this->OutputString);
87  }
89 
95 
102 
104 
107  vtkSetStringMacro(Header);
108  vtkGetStringMacro(Header);
110 
112 
116  vtkSetMacro(WriteArrayMetaData, bool);
117  vtkGetMacro(WriteArrayMetaData, bool);
118  vtkBooleanMacro(WriteArrayMetaData, bool);
120 
122 
125  vtkSetClampMacro(FileType, int, VTK_ASCII, VTK_BINARY);
126  vtkGetMacro(FileType, int);
127  void SetFileTypeToASCII() { this->SetFileType(VTK_ASCII); }
128  void SetFileTypeToBinary() { this->SetFileType(VTK_BINARY); }
130 
132 
136  vtkSetStringMacro(ScalarsName);
137  vtkGetStringMacro(ScalarsName);
139 
141 
145  vtkSetStringMacro(VectorsName);
146  vtkGetStringMacro(VectorsName);
148 
150 
154  vtkSetStringMacro(TensorsName);
155  vtkGetStringMacro(TensorsName);
157 
159 
163  vtkSetStringMacro(NormalsName);
164  vtkGetStringMacro(NormalsName);
166 
168 
172  vtkSetStringMacro(TCoordsName);
173  vtkGetStringMacro(TCoordsName);
175 
177 
181  vtkSetStringMacro(GlobalIdsName);
182  vtkGetStringMacro(GlobalIdsName);
184 
186 
190  vtkSetStringMacro(PedigreeIdsName);
191  vtkGetStringMacro(PedigreeIdsName);
193 
195 
199  vtkSetStringMacro(EdgeFlagsName);
200  vtkGetStringMacro(EdgeFlagsName);
202 
204 
208  vtkSetStringMacro(LookupTableName);
209  vtkGetStringMacro(LookupTableName);
211 
213 
217  vtkSetStringMacro(FieldDataName);
218  vtkGetStringMacro(FieldDataName);
220 
224  virtual ostream* OpenVTKFile();
225 
229  int WriteHeader(ostream* fp);
230 
234  int WritePoints(ostream* fp, vtkPoints* p);
235 
239  int WriteCoordinates(ostream* fp, vtkDataArray* coords, int axes);
240 
244  int WriteCells(ostream* fp, vtkCellArray* cells, const char* label);
245 
250  int WriteCellData(ostream* fp, vtkDataSet* ds);
251 
256  int WritePointData(ostream* fp, vtkDataSet* ds);
257 
262  int WriteEdgeData(ostream* fp, vtkGraph* g);
263 
268  int WriteVertexData(ostream* fp, vtkGraph* g);
269 
274  int WriteRowData(ostream* fp, vtkTable* g);
275 
279  int WriteFieldData(ostream* fp, vtkFieldData* f);
280 
285  int WriteDataSetData(ostream* fp, vtkDataSet* ds);
286 
290  void CloseVTKFile(ostream* fp);
291 
292 protected:
294  ~vtkDataWriter() override;
295 
299 
300  void WriteData() override; // dummy method to allow this class to be instantiated and delegated to
301 
302  char* FileName;
303  char* Header;
304  int FileType;
305 
307 
308  char* ScalarsName;
309  char* VectorsName;
310  char* TensorsName;
311  char* TCoordsName;
312  char* NormalsName;
318 
319  std::locale CurrentLocale;
320 
321  int WriteArray(ostream* fp, int dataType, vtkAbstractArray* data, const char* format,
322  vtkIdType num, vtkIdType numComp);
323  int WriteScalarData(ostream* fp, vtkDataArray* s, vtkIdType num);
324  int WriteVectorData(ostream* fp, vtkDataArray* v, vtkIdType num);
325  int WriteNormalData(ostream* fp, vtkDataArray* n, vtkIdType num);
326  int WriteTCoordData(ostream* fp, vtkDataArray* tc, vtkIdType num);
327  int WriteTensorData(ostream* fp, vtkDataArray* t, vtkIdType num);
328  int WriteGlobalIdData(ostream* fp, vtkDataArray* g, vtkIdType num);
329  int WritePedigreeIdData(ostream* fp, vtkAbstractArray* p, vtkIdType num);
330  int WriteEdgeFlagsData(ostream* fp, vtkDataArray* edgeFlags, vtkIdType num);
331 
333 
338 
339 private:
340  vtkDataWriter(const vtkDataWriter&) = delete;
341  void operator=(const vtkDataWriter&) = delete;
342 };
343 
344 #endif
Abstract superclass for all arrays.
object to represent cell connectivity
Definition: vtkCellArray.h:180
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
helper class for objects that write vtk data files
Definition: vtkDataWriter.h:48
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
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()
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.
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.
virtual ostream * OpenVTKFile()
Open a vtk data file.
char * OutputString
char * GlobalIdsName
static vtkDataWriter * New()
Created object with default header, ASCII format, and default names for scalars, vectors,...
int WriteEdgeFlagsData(ostream *fp, vtkDataArray *edgeFlags, vtkIdType num)
int WriteNormalData(ostream *fp, vtkDataArray *n, vtkIdType num)
unsigned char * GetBinaryOutputString()
Definition: vtkDataWriter.h:84
int WriteArray(ostream *fp, int dataType, vtkAbstractArray *data, const char *format, vtkIdType num, vtkIdType numComp)
int WriteScalarData(ostream *fp, vtkDataArray *s, vtkIdType num)
char * RegisterAndGetOutputString()
This convenience method returns the string, sets the IVAR to nullptr, so that the user is responsible...
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()
std::locale CurrentLocale
char * TensorsName
~vtkDataWriter() override
int WriteVectorData(ostream *fp, vtkDataArray *v, vtkIdType num)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
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:54
Base class for graph data types.
Definition: vtkGraph.h:290
a simple class to control print indentation
Definition: vtkIndent.h:34
Superclass for vtkInformation keys.
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition: vtkPoints.h:34
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:35
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:63
abstract class to write data to file(s)
Definition: vtkWriter.h:43
@ key
Definition: vtkX3D.h:263
@ info
Definition: vtkX3D.h:382
@ data
Definition: vtkX3D.h:321
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:338
#define VTK_BINARY
Definition: vtkWriter.h:40
#define VTK_ASCII
Definition: vtkWriter.h:39