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
vtkDataWriter::WritePointData
int WritePointData(ostream *fp, vtkDataSet *ds)
Write the point data (e.g., scalars, vectors, ...) of a vtk dataset.
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:34
vtkDataWriter::WritePedigreeIdData
int WritePedigreeIdData(ostream *fp, vtkAbstractArray *p, vtkIdType num)
vtkDataWriter::WriteEdgeFlagsData
int WriteEdgeFlagsData(ostream *fp, vtkDataArray *edgeFlags, vtkIdType num)
vtkDataWriter::NormalsName
char * NormalsName
Definition: vtkDataWriter.h:312
vtkDataWriter::vtkDataWriter
vtkDataWriter()
vtkDataWriter::WriteArray
int WriteArray(ostream *fp, int dataType, vtkAbstractArray *data, const char *format, vtkIdType num, vtkIdType numComp)
vtkDataWriter::WriteGlobalIdData
int WriteGlobalIdData(ostream *fp, vtkDataArray *g, vtkIdType num)
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkDataWriter::FieldDataName
char * FieldDataName
Definition: vtkDataWriter.h:314
vtkX3D::data
@ data
Definition: vtkX3D.h:321
vtkDataWriter::OutputStringLength
vtkIdType OutputStringLength
Definition: vtkDataWriter.h:298
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:63
vtkDataWriter::WritePoints
int WritePoints(ostream *fp, vtkPoints *p)
Write out the points of the data set.
vtkX3D::key
@ key
Definition: vtkX3D.h:263
vtkDataWriter::WriteVertexData
int WriteVertexData(ostream *fp, vtkGraph *g)
Write the vertex data (e.g., scalars, vectors, ...) of a vtk graph.
vtkDataWriter::SetFileTypeToASCII
void SetFileTypeToASCII()
Definition: vtkDataWriter.h:127
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
vtkDataWriter::OutputString
char * OutputString
Definition: vtkDataWriter.h:297
vtkDataWriter::SetFileTypeToBinary
void SetFileTypeToBinary()
Definition: vtkDataWriter.h:128
vtkFieldData
represent and manipulate fields of data
Definition: vtkFieldData.h:54
vtkDataWriter::WriteArrayMetaData
bool WriteArrayMetaData
Definition: vtkDataWriter.h:306
vtkDataWriter::Header
char * Header
Definition: vtkDataWriter.h:303
vtkDataWriter::WriteTensorData
int WriteTensorData(ostream *fp, vtkDataArray *t, vtkIdType num)
vtkDataWriter::GetOutputStdString
vtkStdString GetOutputStdString()
When WriteToOutputString is on, this method returns a copy of the output string in a vtkStdString.
vtkDataWriter::WriteToOutputString
vtkTypeBool WriteToOutputString
Definition: vtkDataWriter.h:296
vtkDataWriter::WriteCells
int WriteCells(ostream *fp, vtkCellArray *cells, const char *label)
Write out the cells of the data set.
vtkDataWriter::WriteNormalData
int WriteNormalData(ostream *fp, vtkDataArray *n, vtkIdType num)
vtkDataWriter::New
static vtkDataWriter * New()
Created object with default header, ASCII format, and default names for scalars, vectors,...
vtkDataWriter::ScalarsName
char * ScalarsName
Definition: vtkDataWriter.h:308
vtkDataWriter::CurrentLocale
std::locale CurrentLocale
Definition: vtkDataWriter.h:319
vtkDataWriter::WriteCoordinates
int WriteCoordinates(ostream *fp, vtkDataArray *coords, int axes)
Write out coordinates for rectilinear grids.
vtkDataWriter::GetBinaryOutputString
unsigned char * GetBinaryOutputString()
Definition: vtkDataWriter.h:84
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:180
vtkDataWriter::WriteHeader
int WriteHeader(ostream *fp)
Write the header of a vtk data file.
vtkDataWriter::WriteInformation
int WriteInformation(ostream *fp, vtkInformation *info)
Format is detailed here.
vtkDataWriter::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkDataWriter::WriteVectorData
int WriteVectorData(ostream *fp, vtkDataArray *v, vtkIdType num)
vtkWriter
abstract class to write data to file(s)
Definition: vtkWriter.h:43
vtkDataWriter::WriteTCoordData
int WriteTCoordData(ostream *fp, vtkDataArray *tc, vtkIdType num)
VTK_ASCII
#define VTK_ASCII
Definition: vtkWriter.h:39
vtkDataWriter::PedigreeIdsName
char * PedigreeIdsName
Definition: vtkDataWriter.h:316
vtkDataWriter::TCoordsName
char * TCoordsName
Definition: vtkDataWriter.h:311
vtkDataWriter::EdgeFlagsName
char * EdgeFlagsName
Definition: vtkDataWriter.h:317
vtkDataWriter::OpenVTKFile
virtual ostream * OpenVTKFile()
Open a vtk data file.
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:76
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:65
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkDataWriter::FileType
int FileType
Definition: vtkDataWriter.h:304
vtkDataWriter::LookupTableName
char * LookupTableName
Definition: vtkDataWriter.h:313
vtkWriter.h
vtkDataWriter::CloseVTKFile
void CloseVTKFile(ostream *fp)
Close a vtk file.
vtkDataWriter::WriteEdgeData
int WriteEdgeData(ostream *fp, vtkGraph *g)
Write the edge data (e.g., scalars, vectors, ...) of a vtk graph.
vtkDataWriter::CanWriteInformationKey
bool CanWriteInformationKey(vtkInformation *info, vtkInformationKey *key)
vtkDataWriter::GlobalIdsName
char * GlobalIdsName
Definition: vtkDataWriter.h:315
vtkDataWriter::TensorsName
char * TensorsName
Definition: vtkDataWriter.h:310
vtkDataWriter::WriteData
void WriteData() override
vtkDataWriter::FileName
char * FileName
Definition: vtkDataWriter.h:302
vtkDataWriter::RegisterAndGetOutputString
char * RegisterAndGetOutputString()
This convenience method returns the string, sets the IVAR to nullptr, so that the user is responsible...
vtkDataWriter::WriteCellData
int WriteCellData(ostream *fp, vtkDataSet *ds)
Write the cell data (e.g., scalars, vectors, ...) of a vtk dataset.
vtkDataWriter
helper class for objects that write vtk data files
Definition: vtkDataWriter.h:48
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:35
vtkGraph
Base class for graph data types.
Definition: vtkGraph.h:290
vtkDataWriter::WriteDataSetData
int WriteDataSetData(ostream *fp, vtkDataSet *ds)
Write out the data associated with the dataset (i.e.
vtkDataWriter::WriteFieldData
int WriteFieldData(ostream *fp, vtkFieldData *f)
Write out the field data.
vtkDataWriter::WriteRowData
int WriteRowData(ostream *fp, vtkTable *g)
Write the row data (e.g., scalars, vectors, ...) of a vtk table.
VTK_BINARY
#define VTK_BINARY
Definition: vtkWriter.h:40
vtkDataWriter::VectorsName
char * VectorsName
Definition: vtkDataWriter.h:309
vtkInformationKey
Superclass for vtkInformation keys.
Definition: vtkInformationKey.h:39
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkDataWriter::WriteScalarData
int WriteScalarData(ostream *fp, vtkDataArray *s, vtkIdType num)
vtkDataWriter::~vtkDataWriter
~vtkDataWriter() override