Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

IO/vtkDataWriter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkDataWriter.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00046 #ifndef __vtkDataWriter_h
00047 #define __vtkDataWriter_h
00048 
00049 #include "vtkWriter.h"
00050 
00051 class vtkDataSet;
00052 class vtkPoints;
00053 class vtkCellArray;
00054 class vtkDataArray;
00055 class vtkFieldData;
00056 
00057 class VTK_IO_EXPORT vtkDataWriter : public vtkWriter
00058 {
00059 public:
00060   vtkTypeRevisionMacro(vtkDataWriter,vtkWriter);
00061   void PrintSelf(ostream& os, vtkIndent indent);
00062 
00065   static vtkDataWriter *New();
00066 
00068 
00069   vtkSetStringMacro(FileName);
00070   vtkGetStringMacro(FileName);
00072 
00074 
00075   vtkSetMacro(WriteToOutputString,int);
00076   vtkGetMacro(WriteToOutputString,int);
00077   vtkBooleanMacro(WriteToOutputString,int);
00079 
00081 
00084   vtkGetMacro(OutputStringLength, int);  
00085   vtkGetStringMacro(OutputString);
00086   unsigned char *GetBinaryOutputString() {
00087       return (unsigned char *)this->OutputString;};
00089       
00093   char *RegisterAndGetOutputString();
00094   
00096 
00097   vtkSetStringMacro(Header);
00098   vtkGetStringMacro(Header);
00100 
00102 
00103   vtkSetClampMacro(FileType,int,VTK_ASCII,VTK_BINARY);
00104   vtkGetMacro(FileType,int);
00105   void SetFileTypeToASCII() {this->SetFileType(VTK_ASCII);};
00106   void SetFileTypeToBinary() {this->SetFileType(VTK_BINARY);};
00108 
00110 
00112   vtkSetStringMacro(ScalarsName);
00113   vtkGetStringMacro(ScalarsName);
00115 
00117 
00119   vtkSetStringMacro(VectorsName);
00120   vtkGetStringMacro(VectorsName);
00122 
00124 
00126   vtkSetStringMacro(TensorsName);
00127   vtkGetStringMacro(TensorsName);
00129 
00131 
00133   vtkSetStringMacro(NormalsName);
00134   vtkGetStringMacro(NormalsName);
00136 
00138 
00140   vtkSetStringMacro(TCoordsName);
00141   vtkGetStringMacro(TCoordsName);
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 
00182   int WriteFieldData(ostream *fp, vtkFieldData *f);
00183 
00187   int WriteDataSetData(ostream *fp, vtkDataSet *ds);
00188 
00190   void CloseVTKFile(ostream *fp);
00191 
00192 
00193 protected:
00194   vtkDataWriter();
00195   ~vtkDataWriter();
00196 
00197   int WriteToOutputString;
00198   char *OutputString;
00199   int OutputStringLength;
00200   int OutputStringAllocatedLength;
00201   
00202   void WriteData(); //dummy method to allow this class to be instantiated and delegated to
00203 
00204   char *FileName;
00205   char *Header;
00206   int FileType;
00207 
00208   char *ScalarsName;
00209   char *VectorsName;
00210   char *TensorsName;
00211   char *TCoordsName;
00212   char *NormalsName;
00213   char *LookupTableName;
00214   char *FieldDataName;
00215 
00216   int WriteArray(ostream *fp, int dataType, vtkDataArray *data, const char *format, 
00217                  int num, int numComp);
00218   int WriteScalarData(ostream *fp, vtkDataArray *s, int num);
00219   int WriteVectorData(ostream *fp, vtkDataArray *v, int num);
00220   int WriteNormalData(ostream *fp, vtkDataArray *n, int num);
00221   int WriteTCoordData(ostream *fp, vtkDataArray *tc, int num);
00222   int WriteTensorData(ostream *fp, vtkDataArray *t, int num);
00223 
00224 private:
00225   vtkDataWriter(const vtkDataWriter&);  // Not implemented.
00226   void operator=(const vtkDataWriter&);  // Not implemented.
00227 };
00228 
00229 #endif
00230 
00231