VTK
dox/IO/Legacy/vtkDataWriter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkDataWriter.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00028 #ifndef __vtkDataWriter_h
00029 #define __vtkDataWriter_h
00030 
00031 #include "vtkIOLegacyModule.h" // For export macro
00032 #include "vtkWriter.h"
00033 
00034 class vtkCellArray;
00035 class vtkDataArray;
00036 class vtkDataSet;
00037 class vtkFieldData;
00038 class vtkGraph;
00039 class vtkPoints;
00040 class vtkTable;
00041 
00042 class VTKIOLEGACY_EXPORT vtkDataWriter : public vtkWriter
00043 {
00044 public:
00045   vtkTypeMacro(vtkDataWriter,vtkWriter);
00046   void PrintSelf(ostream& os, vtkIndent indent);
00047 
00050   static vtkDataWriter *New();
00051 
00053 
00054   vtkSetStringMacro(FileName);
00055   vtkGetStringMacro(FileName);
00057 
00059 
00060   vtkSetMacro(WriteToOutputString,int);
00061   vtkGetMacro(WriteToOutputString,int);
00062   vtkBooleanMacro(WriteToOutputString,int);
00064 
00066 
00069   vtkGetMacro(OutputStringLength, int);
00070   vtkGetStringMacro(OutputString);
00071   unsigned char *GetBinaryOutputString()
00072     {
00073       return reinterpret_cast<unsigned char *>(this->OutputString);
00074     }
00076 
00079   vtkStdString GetOutputStdString();
00080 
00084   char *RegisterAndGetOutputString();
00085 
00087 
00088   vtkSetStringMacro(Header);
00089   vtkGetStringMacro(Header);
00091 
00093 
00094   vtkSetClampMacro(FileType,int,VTK_ASCII,VTK_BINARY);
00095   vtkGetMacro(FileType,int);
00096   void SetFileTypeToASCII() {this->SetFileType(VTK_ASCII);};
00097   void SetFileTypeToBinary() {this->SetFileType(VTK_BINARY);};
00099 
00101 
00103   vtkSetStringMacro(ScalarsName);
00104   vtkGetStringMacro(ScalarsName);
00106 
00108 
00110   vtkSetStringMacro(VectorsName);
00111   vtkGetStringMacro(VectorsName);
00113 
00115 
00117   vtkSetStringMacro(TensorsName);
00118   vtkGetStringMacro(TensorsName);
00120 
00122 
00124   vtkSetStringMacro(NormalsName);
00125   vtkGetStringMacro(NormalsName);
00127 
00129 
00131   vtkSetStringMacro(TCoordsName);
00132   vtkGetStringMacro(TCoordsName);
00134 
00136 
00138   vtkSetStringMacro(GlobalIdsName);
00139   vtkGetStringMacro(GlobalIdsName);
00141 
00143 
00145   vtkSetStringMacro(PedigreeIdsName);
00146   vtkGetStringMacro(PedigreeIdsName);
00148 
00150 
00152   vtkSetStringMacro(LookupTableName);
00153   vtkGetStringMacro(LookupTableName);
00155 
00157 
00159   vtkSetStringMacro(FieldDataName);
00160   vtkGetStringMacro(FieldDataName);
00162 
00164   virtual ostream *OpenVTKFile();
00165 
00167   int WriteHeader(ostream *fp);
00168 
00170   int WritePoints(ostream *fp, vtkPoints *p);
00171 
00173   int WriteCoordinates(ostream *fp, vtkDataArray *coords, int axes);
00174 
00176   int WriteCells(ostream *fp, vtkCellArray *cells, const char *label);
00177 
00180   int WriteCellData(ostream *fp, vtkDataSet *ds);
00181 
00184   int WritePointData(ostream *fp, vtkDataSet *ds);
00185 
00188   int WriteEdgeData(ostream *fp, vtkGraph *g);
00189 
00192   int WriteVertexData(ostream *fp, vtkGraph *g);
00193 
00196   int WriteRowData(ostream *fp, vtkTable *g);
00197 
00199   int WriteFieldData(ostream *fp, vtkFieldData *f);
00200 
00204   int WriteDataSetData(ostream *fp, vtkDataSet *ds);
00205 
00207   void CloseVTKFile(ostream *fp);
00208 
00209 
00210 protected:
00211   vtkDataWriter();
00212   ~vtkDataWriter();
00213 
00214   int WriteToOutputString;
00215   char *OutputString;
00216   int OutputStringLength;
00217 
00218   void WriteData(); //dummy method to allow this class to be instantiated and delegated to
00219 
00220   char *FileName;
00221   char *Header;
00222   int FileType;
00223 
00224   char *ScalarsName;
00225   char *VectorsName;
00226   char *TensorsName;
00227   char *TCoordsName;
00228   char *NormalsName;
00229   char *LookupTableName;
00230   char *FieldDataName;
00231   char* GlobalIdsName;
00232   char* PedigreeIdsName;
00233 
00234   int WriteArray(ostream *fp, int dataType, vtkAbstractArray *data, const char *format,
00235                  int num, int numComp);
00236   int WriteScalarData(ostream *fp, vtkDataArray *s, int num);
00237   int WriteVectorData(ostream *fp, vtkDataArray *v, int num);
00238   int WriteNormalData(ostream *fp, vtkDataArray *n, int num);
00239   int WriteTCoordData(ostream *fp, vtkDataArray *tc, int num);
00240   int WriteTensorData(ostream *fp, vtkDataArray *t, int num);
00241   int WriteGlobalIdData(ostream *fp, vtkDataArray *g, int num);
00242   int WritePedigreeIdData(ostream *fp, vtkAbstractArray *p, int num);
00243 
00244 private:
00245   vtkDataWriter(const vtkDataWriter&);  // Not implemented.
00246   void operator=(const vtkDataWriter&);  // Not implemented.
00247 };
00248 
00249 #endif