00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00028 #ifndef __vtkDataWriter_h
00029 #define __vtkDataWriter_h
00030
00031 #include "vtkWriter.h"
00032
00033 class vtkCellArray;
00034 class vtkDataArray;
00035 class vtkDataSet;
00036 class vtkFieldData;
00037 class vtkGraph;
00038 class vtkPoints;
00039 class vtkTable;
00040
00041 class VTK_IO_EXPORT vtkDataWriter : public vtkWriter
00042 {
00043 public:
00044 vtkTypeMacro(vtkDataWriter,vtkWriter);
00045 void PrintSelf(ostream& os, vtkIndent indent);
00046
00049 static vtkDataWriter *New();
00050
00052
00053 vtkSetStringMacro(FileName);
00054 vtkGetStringMacro(FileName);
00056
00058
00059 vtkSetMacro(WriteToOutputString,int);
00060 vtkGetMacro(WriteToOutputString,int);
00061 vtkBooleanMacro(WriteToOutputString,int);
00063
00065
00068 vtkGetMacro(OutputStringLength, int);
00069 vtkGetStringMacro(OutputString);
00070 unsigned char *GetBinaryOutputString()
00071 {
00072 return reinterpret_cast<unsigned char *>(this->OutputString);
00073 }
00075
00079 char *RegisterAndGetOutputString();
00080
00082
00083 vtkSetStringMacro(Header);
00084 vtkGetStringMacro(Header);
00086
00088
00089 vtkSetClampMacro(FileType,int,VTK_ASCII,VTK_BINARY);
00090 vtkGetMacro(FileType,int);
00091 void SetFileTypeToASCII() {this->SetFileType(VTK_ASCII);};
00092 void SetFileTypeToBinary() {this->SetFileType(VTK_BINARY);};
00094
00096
00098 vtkSetStringMacro(ScalarsName);
00099 vtkGetStringMacro(ScalarsName);
00101
00103
00105 vtkSetStringMacro(VectorsName);
00106 vtkGetStringMacro(VectorsName);
00108
00110
00112 vtkSetStringMacro(TensorsName);
00113 vtkGetStringMacro(TensorsName);
00115
00117
00119 vtkSetStringMacro(NormalsName);
00120 vtkGetStringMacro(NormalsName);
00122
00124
00126 vtkSetStringMacro(TCoordsName);
00127 vtkGetStringMacro(TCoordsName);
00129
00131
00133 vtkSetStringMacro(GlobalIdsName);
00134 vtkGetStringMacro(GlobalIdsName);
00136
00138
00140 vtkSetStringMacro(PedigreeIdsName);
00141 vtkGetStringMacro(PedigreeIdsName);
00143
00145
00147 vtkSetStringMacro(LookupTableName);
00148 vtkGetStringMacro(LookupTableName);
00150
00152
00154 vtkSetStringMacro(FieldDataName);
00155 vtkGetStringMacro(FieldDataName);
00157
00159 virtual ostream *OpenVTKFile();
00160
00162 int WriteHeader(ostream *fp);
00163
00165 int WritePoints(ostream *fp, vtkPoints *p);
00166
00168 int WriteCoordinates(ostream *fp, vtkDataArray *coords, int axes);
00169
00171 int WriteCells(ostream *fp, vtkCellArray *cells, const char *label);
00172
00175 int WriteCellData(ostream *fp, vtkDataSet *ds);
00176
00179 int WritePointData(ostream *fp, vtkDataSet *ds);
00180
00183 int WriteEdgeData(ostream *fp, vtkGraph *g);
00184
00187 int WriteVertexData(ostream *fp, vtkGraph *g);
00188
00191 int WriteRowData(ostream *fp, vtkTable *g);
00192
00194 int WriteFieldData(ostream *fp, vtkFieldData *f);
00195
00199 int WriteDataSetData(ostream *fp, vtkDataSet *ds);
00200
00202 void CloseVTKFile(ostream *fp);
00203
00204
00205 protected:
00206 vtkDataWriter();
00207 ~vtkDataWriter();
00208
00209 int WriteToOutputString;
00210 char *OutputString;
00211 int OutputStringLength;
00212
00213 void WriteData();
00214
00215 char *FileName;
00216 char *Header;
00217 int FileType;
00218
00219 char *ScalarsName;
00220 char *VectorsName;
00221 char *TensorsName;
00222 char *TCoordsName;
00223 char *NormalsName;
00224 char *LookupTableName;
00225 char *FieldDataName;
00226 char* GlobalIdsName;
00227 char* PedigreeIdsName;
00228
00229 int WriteArray(ostream *fp, int dataType, vtkAbstractArray *data, const char *format,
00230 int num, int numComp);
00231 int WriteScalarData(ostream *fp, vtkDataArray *s, int num);
00232 int WriteVectorData(ostream *fp, vtkDataArray *v, int num);
00233 int WriteNormalData(ostream *fp, vtkDataArray *n, int num);
00234 int WriteTCoordData(ostream *fp, vtkDataArray *tc, int num);
00235 int WriteTensorData(ostream *fp, vtkDataArray *t, int num);
00236 int WriteGlobalIdData(ostream *fp, vtkDataArray *g, int num);
00237 int WritePedigreeIdData(ostream *fp, vtkAbstractArray *p, int num);
00238
00239 private:
00240 vtkDataWriter(const vtkDataWriter&);
00241 void operator=(const vtkDataWriter&);
00242 };
00243
00244 #endif