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 =========================================================================*/
28 #ifndef vtkDataWriter_h
29 #define vtkDataWriter_h
30 
31 #include "vtkIOLegacyModule.h" // For export macro
32 #include "vtkWriter.h"
33 
34 class vtkCellArray;
35 class vtkDataArray;
36 class vtkDataSet;
37 class vtkFieldData;
38 class vtkGraph;
39 class vtkPoints;
40 class vtkTable;
41 
43 {
44 public:
45  vtkTypeMacro(vtkDataWriter,vtkWriter);
46  void PrintSelf(ostream& os, vtkIndent indent);
47 
50  static vtkDataWriter *New();
51 
53 
54  vtkSetStringMacro(FileName);
55  vtkGetStringMacro(FileName);
57 
59 
60  vtkSetMacro(WriteToOutputString,int);
61  vtkGetMacro(WriteToOutputString,int);
62  vtkBooleanMacro(WriteToOutputString,int);
64 
66 
69  vtkGetMacro(OutputStringLength, int);
70  vtkGetStringMacro(OutputString);
71  unsigned char *GetBinaryOutputString()
72  {
73  return reinterpret_cast<unsigned char *>(this->OutputString);
74  }
76 
79  vtkStdString GetOutputStdString();
80 
84  char *RegisterAndGetOutputString();
85 
87 
88  vtkSetStringMacro(Header);
89  vtkGetStringMacro(Header);
91 
93 
94  vtkSetClampMacro(FileType,int,VTK_ASCII,VTK_BINARY);
95  vtkGetMacro(FileType,int);
96  void SetFileTypeToASCII() {this->SetFileType(VTK_ASCII);};
97  void SetFileTypeToBinary() {this->SetFileType(VTK_BINARY);};
99 
101 
103  vtkSetStringMacro(ScalarsName);
104  vtkGetStringMacro(ScalarsName);
106 
108 
110  vtkSetStringMacro(VectorsName);
111  vtkGetStringMacro(VectorsName);
113 
115 
117  vtkSetStringMacro(TensorsName);
118  vtkGetStringMacro(TensorsName);
120 
122 
124  vtkSetStringMacro(NormalsName);
125  vtkGetStringMacro(NormalsName);
127 
129 
131  vtkSetStringMacro(TCoordsName);
132  vtkGetStringMacro(TCoordsName);
134 
136 
138  vtkSetStringMacro(GlobalIdsName);
139  vtkGetStringMacro(GlobalIdsName);
141 
143 
145  vtkSetStringMacro(PedigreeIdsName);
146  vtkGetStringMacro(PedigreeIdsName);
148 
150 
152  vtkSetStringMacro(EdgeFlagsName);
153  vtkGetStringMacro(EdgeFlagsName);
155 
157 
159  vtkSetStringMacro(LookupTableName);
160  vtkGetStringMacro(LookupTableName);
162 
164 
166  vtkSetStringMacro(FieldDataName);
167  vtkGetStringMacro(FieldDataName);
169 
171  virtual ostream *OpenVTKFile();
172 
174  int WriteHeader(ostream *fp);
175 
177  int WritePoints(ostream *fp, vtkPoints *p);
178 
180  int WriteCoordinates(ostream *fp, vtkDataArray *coords, int axes);
181 
183  int WriteCells(ostream *fp, vtkCellArray *cells, const char *label);
184 
187  int WriteCellData(ostream *fp, vtkDataSet *ds);
188 
191  int WritePointData(ostream *fp, vtkDataSet *ds);
192 
195  int WriteEdgeData(ostream *fp, vtkGraph *g);
196 
199  int WriteVertexData(ostream *fp, vtkGraph *g);
200 
203  int WriteRowData(ostream *fp, vtkTable *g);
204 
206  int WriteFieldData(ostream *fp, vtkFieldData *f);
207 
211  int WriteDataSetData(ostream *fp, vtkDataSet *ds);
212 
214  void CloseVTKFile(ostream *fp);
215 
216 
217 protected:
218  vtkDataWriter();
219  ~vtkDataWriter();
220 
224 
225  void WriteData(); //dummy method to allow this class to be instantiated and delegated to
226 
227  char *FileName;
228  char *Header;
229  int FileType;
230 
231  char *ScalarsName;
232  char *VectorsName;
233  char *TensorsName;
234  char *TCoordsName;
235  char *NormalsName;
241 
242  int WriteArray(ostream *fp, int dataType, vtkAbstractArray *data, const char *format,
243  int num, int numComp);
244  int WriteScalarData(ostream *fp, vtkDataArray *s, int num);
245  int WriteVectorData(ostream *fp, vtkDataArray *v, int num);
246  int WriteNormalData(ostream *fp, vtkDataArray *n, int num);
247  int WriteTCoordData(ostream *fp, vtkDataArray *tc, int num);
248  int WriteTensorData(ostream *fp, vtkDataArray *t, int num);
249  int WriteGlobalIdData(ostream *fp, vtkDataArray *g, int num);
250  int WritePedigreeIdData(ostream *fp, vtkAbstractArray *p, int num);
251  int WriteEdgeFlagsData(ostream *fp, vtkDataArray *edgeFlags, int num);
252 
253 private:
254  vtkDataWriter(const vtkDataWriter&); // Not implemented.
255  void operator=(const vtkDataWriter&); // Not implemented.
256 };
257 
258 #endif
char * FieldDataName
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
char * NormalsName
void SetFileTypeToASCII()
Definition: vtkDataWriter.h:96
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
Abstract superclass for all arrays.
helper class for objects that write vtk data files
Definition: vtkDataWriter.h:42
char * ScalarsName
char * LookupTableName
unsigned char * GetBinaryOutputString()
Definition: vtkDataWriter.h:71
char * OutputString
char * TensorsName
#define VTK_ASCII
Definition: vtkWriter.h:41
#define VTKIOLEGACY_EXPORT
char * EdgeFlagsName
Base class for graph data types.
Definition: vtkGraph.h:288
abstract class to write data to file(s)
Definition: vtkWriter.h:44
a simple class to control print indentation
Definition: vtkIndent.h:38
void SetFileTypeToBinary()
Definition: vtkDataWriter.h:97
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
#define VTK_BINARY
Definition: vtkWriter.h:42
char * GlobalIdsName
char * PedigreeIdsName
object to represent cell connectivity
Definition: vtkCellArray.h:49
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:67
char * TCoordsName
static vtkAlgorithm * New()
virtual void WriteData()=0
char * VectorsName
void PrintSelf(ostream &os, vtkIndent indent)
represent and manipulate 3D points
Definition: vtkPoints.h:38
represent and manipulate fields of data
Definition: vtkFieldData.h:55