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 
94  vtkStdString GetOutputStdString();
95 
101  char* RegisterAndGetOutputString();
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:
293  vtkDataWriter();
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 
332  bool CanWriteInformationKey(vtkInformation* info, vtkInformationKey* key);
333 
337  int WriteInformation(ostream* fp, vtkInformation* info);
338 
339 private:
340  vtkDataWriter(const vtkDataWriter&) = delete;
341  void operator=(const vtkDataWriter&) = delete;
342 };
343 
344 #endif
char * FieldDataName
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:34
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:56
Abstract superclass for all arrays.
helper class for objects that write vtk data files
Definition: vtkDataWriter.h:47
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:84
char * OutputString
int vtkIdType
Definition: vtkType.h:338
char * TensorsName
#define VTK_ASCII
Definition: vtkWriter.h:42
char * EdgeFlagsName
int vtkTypeBool
Definition: vtkABI.h:69
Base class for graph data types.
Definition: vtkGraph.h:289
abstract class to write data to file(s)
Definition: vtkWriter.h:45
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:33
vtkTypeBool WriteToOutputString
void SetFileTypeToBinary()
Specify file type (ASCII or BINARY) for vtk data file.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
#define VTK_BINARY
Definition: vtkWriter.h:43
char * GlobalIdsName
char * PedigreeIdsName
bool WriteArrayMetaData
object to represent cell connectivity
Definition: vtkCellArray.h:179
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:62
std::locale CurrentLocale
char * TCoordsName
static vtkAlgorithm * New()
virtual void WriteData()=0
char * VectorsName
represent and manipulate 3D points
Definition: vtkPoints.h:33
represent and manipulate fields of data
Definition: vtkFieldData.h:53