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 class vtkCellArray;
36 class vtkDataArray;
37 class vtkDataSet;
38 class vtkFieldData;
39 class vtkGraph;
40 class vtkInformation;
41 class vtkInformationKey;
42 class vtkPoints;
43 class vtkTable;
44 
45 class VTKIOLEGACY_EXPORT vtkDataWriter : public vtkWriter
46 {
47 public:
48  vtkTypeMacro(vtkDataWriter,vtkWriter);
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
55  static vtkDataWriter *New();
56 
58 
61  vtkSetStringMacro(FileName);
62  vtkGetStringMacro(FileName);
64 
66 
69  vtkSetMacro(WriteToOutputString,vtkTypeBool);
70  vtkGetMacro(WriteToOutputString,vtkTypeBool);
71  vtkBooleanMacro(WriteToOutputString,vtkTypeBool);
73 
75 
80  vtkGetMacro(OutputStringLength, vtkIdType);
81  vtkGetStringMacro(OutputString);
82  unsigned char *GetBinaryOutputString()
83  {
84  return reinterpret_cast<unsigned char *>(this->OutputString);
85  }
87 
92  vtkStdString GetOutputStdString();
93 
99  char *RegisterAndGetOutputString();
100 
102 
105  vtkSetStringMacro(Header);
106  vtkGetStringMacro(Header);
108 
110 
114  vtkSetMacro(WriteArrayMetaData, bool)
115  vtkGetMacro(WriteArrayMetaData, bool)
116  vtkBooleanMacro(WriteArrayMetaData, bool)
118 
120 
123  vtkSetClampMacro(FileType,int,VTK_ASCII,VTK_BINARY);
124  vtkGetMacro(FileType,int);
125  void SetFileTypeToASCII() {this->SetFileType(VTK_ASCII);};
126  void SetFileTypeToBinary() {this->SetFileType(VTK_BINARY);};
128 
130 
134  vtkSetStringMacro(ScalarsName);
135  vtkGetStringMacro(ScalarsName);
137 
139 
143  vtkSetStringMacro(VectorsName);
144  vtkGetStringMacro(VectorsName);
146 
148 
152  vtkSetStringMacro(TensorsName);
153  vtkGetStringMacro(TensorsName);
155 
157 
161  vtkSetStringMacro(NormalsName);
162  vtkGetStringMacro(NormalsName);
164 
166 
170  vtkSetStringMacro(TCoordsName);
171  vtkGetStringMacro(TCoordsName);
173 
175 
179  vtkSetStringMacro(GlobalIdsName);
180  vtkGetStringMacro(GlobalIdsName);
182 
184 
188  vtkSetStringMacro(PedigreeIdsName);
189  vtkGetStringMacro(PedigreeIdsName);
191 
193 
197  vtkSetStringMacro(EdgeFlagsName);
198  vtkGetStringMacro(EdgeFlagsName);
200 
202 
206  vtkSetStringMacro(LookupTableName);
207  vtkGetStringMacro(LookupTableName);
209 
211 
215  vtkSetStringMacro(FieldDataName);
216  vtkGetStringMacro(FieldDataName);
218 
222  virtual ostream *OpenVTKFile();
223 
227  int WriteHeader(ostream *fp);
228 
232  int WritePoints(ostream *fp, vtkPoints *p);
233 
237  int WriteCoordinates(ostream *fp, vtkDataArray *coords, int axes);
238 
242  int WriteCells(ostream *fp, vtkCellArray *cells, const char *label);
243 
248  int WriteCellData(ostream *fp, vtkDataSet *ds);
249 
254  int WritePointData(ostream *fp, vtkDataSet *ds);
255 
260  int WriteEdgeData(ostream *fp, vtkGraph *g);
261 
266  int WriteVertexData(ostream *fp, vtkGraph *g);
267 
272  int WriteRowData(ostream *fp, vtkTable *g);
273 
277  int WriteFieldData(ostream *fp, vtkFieldData *f);
278 
283  int WriteDataSetData(ostream *fp, vtkDataSet *ds);
284 
288  void CloseVTKFile(ostream *fp);
289 
290 
291 protected:
292  vtkDataWriter();
293  ~vtkDataWriter() override;
294 
298 
299  void WriteData() override; //dummy method to allow this class to be instantiated and delegated to
300 
301  char *FileName;
302  char *Header;
303  int FileType;
304 
306 
307  char *ScalarsName;
308  char *VectorsName;
309  char *TensorsName;
310  char *TCoordsName;
311  char *NormalsName;
317 
318  int WriteArray(ostream *fp, int dataType, vtkAbstractArray *data, const char *format,
319  vtkIdType num, vtkIdType numComp);
320  int WriteScalarData(ostream *fp, vtkDataArray *s, vtkIdType num);
321  int WriteVectorData(ostream *fp, vtkDataArray *v, vtkIdType num);
322  int WriteNormalData(ostream *fp, vtkDataArray *n, vtkIdType num);
323  int WriteTCoordData(ostream *fp, vtkDataArray *tc, vtkIdType num);
324  int WriteTensorData(ostream *fp, vtkDataArray *t, vtkIdType num);
325  int WriteGlobalIdData(ostream *fp, vtkDataArray *g, vtkIdType num);
326  int WritePedigreeIdData(ostream *fp, vtkAbstractArray *p, vtkIdType num);
327  int WriteEdgeFlagsData(ostream *fp, vtkDataArray *edgeFlags, vtkIdType num);
328 
329  bool CanWriteInformationKey(vtkInformation *info, vtkInformationKey *key);
330 
334  int WriteInformation(ostream *fp, vtkInformation *info);
335 
336 private:
337  vtkDataWriter(const vtkDataWriter&) = delete;
338  void operator=(const vtkDataWriter&) = delete;
339 };
340 
341 #endif
char * FieldDataName
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
vtkIdType OutputStringLength
char * NormalsName
Store vtkAlgorithm input/output information.
void SetFileTypeToASCII()
Specify file type (ASCII or BINARY) for vtk data file.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
Abstract superclass for all arrays.
helper class for objects that write vtk data files
Definition: vtkDataWriter.h:45
char * ScalarsName
char * LookupTableName
unsigned char * GetBinaryOutputString()
When WriteToOutputString in on, then a string is allocated, written to, and can be retrieved with the...
Definition: vtkDataWriter.h:82
char * OutputString
int vtkIdType
Definition: vtkType.h:347
char * TensorsName
#define VTK_ASCII
Definition: vtkWriter.h:39
char * EdgeFlagsName
int vtkTypeBool
Definition: vtkABI.h:69
Base class for graph data types.
Definition: vtkGraph.h:287
abstract class to write data to file(s)
Definition: vtkWriter.h:42
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Superclass for vtkInformation keys.
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkTypeBool WriteToOutputString
void SetFileTypeToBinary()
Specify file type (ASCII or BINARY) for vtk data file.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
#define VTK_BINARY
Definition: vtkWriter.h:40
char * GlobalIdsName
char * PedigreeIdsName
bool WriteArrayMetaData
object to represent cell connectivity
Definition: vtkCellArray.h:50
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:68
char * TCoordsName
static vtkAlgorithm * New()
virtual void WriteData()=0
char * VectorsName
represent and manipulate 3D points
Definition: vtkPoints.h:39
represent and manipulate fields of data
Definition: vtkFieldData.h:56