VTK
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 
293 protected:
295  ~vtkDataWriter() override;
296 
300 
301  void WriteData() override; //dummy method to allow this class to be instantiated and delegated to
302 
303  char *FileName;
304  char *Header;
305  int FileType;
306 
308 
309  char *ScalarsName;
310  char *VectorsName;
311  char *TensorsName;
312  char *TCoordsName;
313  char *NormalsName;
319 
320  std::locale CurrentLocale;
321 
322  int WriteArray(ostream *fp, int dataType, vtkAbstractArray *data, const char *format,
323  vtkIdType num, vtkIdType numComp);
324  int WriteScalarData(ostream *fp, vtkDataArray *s, vtkIdType num);
325  int WriteVectorData(ostream *fp, vtkDataArray *v, vtkIdType num);
326  int WriteNormalData(ostream *fp, vtkDataArray *n, vtkIdType num);
327  int WriteTCoordData(ostream *fp, vtkDataArray *tc, vtkIdType num);
328  int WriteTensorData(ostream *fp, vtkDataArray *t, vtkIdType num);
329  int WriteGlobalIdData(ostream *fp, vtkDataArray *g, vtkIdType num);
330  int WritePedigreeIdData(ostream *fp, vtkAbstractArray *p, vtkIdType num);
331  int WriteEdgeFlagsData(ostream *fp, vtkDataArray *edgeFlags, vtkIdType num);
332 
334 
339 
340 private:
341  vtkDataWriter(const vtkDataWriter&) = delete;
342  void operator=(const vtkDataWriter&) = delete;
343 };
344 
345 #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:40
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:313
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:347
vtkDataWriter::FieldDataName
char * FieldDataName
Definition: vtkDataWriter.h:315
vtkX3D::data
@ data
Definition: vtkX3D.h:315
vtkDataWriter::OutputStringLength
vtkIdType OutputStringLength
Definition: vtkDataWriter.h:299
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:69
vtkDataWriter::WritePoints
int WritePoints(ostream *fp, vtkPoints *p)
Write out the points of the data set.
vtkX3D::key
@ key
Definition: vtkX3D.h:257
vtkDataWriter::WriteVertexData
int WriteVertexData(ostream *fp, vtkGraph *g)
Write the vertex data (e.g., scalars, vectors, ...) of a vtk graph.
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkDataWriter::OutputString
char * OutputString
Definition: vtkDataWriter.h:298
vtkDataWriter::SetFileTypeToBinary
void SetFileTypeToBinary()
Definition: vtkDataWriter.h:128
vtkFieldData
represent and manipulate fields of data
Definition: vtkFieldData.h:57
vtkDataWriter::WriteArrayMetaData
bool WriteArrayMetaData
Definition: vtkDataWriter.h:307
vtkDataWriter::Header
char * Header
Definition: vtkDataWriter.h:304
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:297
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:309
vtkDataWriter::CurrentLocale
std::locale CurrentLocale
Definition: vtkDataWriter.h:320
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:40
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:51
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:317
vtkDataWriter::TCoordsName
char * TCoordsName
Definition: vtkDataWriter.h:312
vtkDataWriter::EdgeFlagsName
char * EdgeFlagsName
Definition: vtkDataWriter.h:318
vtkDataWriter::OpenVTKFile
virtual ostream * OpenVTKFile()
Open a vtk data file.
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:63
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:79
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:87
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkDataWriter::FileType
int FileType
Definition: vtkDataWriter.h:305
vtkDataWriter::LookupTableName
char * LookupTableName
Definition: vtkDataWriter.h:314
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:316
vtkDataWriter::TensorsName
char * TensorsName
Definition: vtkDataWriter.h:311
vtkDataWriter::WriteData
void WriteData() override
vtkDataWriter::FileName
char * FileName
Definition: vtkDataWriter.h:303
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:41
vtkGraph
Base class for graph data types.
Definition: vtkGraph.h:288
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:310
vtkInformationKey
Superclass for vtkInformation keys.
Definition: vtkInformationKey.h:42
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkDataWriter::WriteScalarData
int WriteScalarData(ostream *fp, vtkDataArray *s, vtkIdType num)
vtkDataWriter::~vtkDataWriter
~vtkDataWriter() override