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

# IO/vtkDataReader.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkDataReader.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 =========================================================================*/
    00044 #ifndef __vtkDataReader_h
    00045 #define __vtkDataReader_h
    00046
    00047 #include "vtkSource.h"
    00048
    00049 #define VTK_ASCII 1
    00050 #define VTK_BINARY 2
    00051
    00052 class vtkCharArray;
    00053 class vtkDataArray;
    00054 class vtkDataSet;
    00055 class vtkDataSetAttributes;
    00056 class vtkFieldData;
    00057 class vtkPointSet;
    00058 class vtkRectilinearGrid;
    00059
    00060 class VTK_IO_EXPORT vtkDataReader : public vtkSource
    00061 {
    00062 public:
    00063   static vtkDataReader *New();
    00064   vtkTypeRevisionMacro(vtkDataReader,vtkSource);
    00065   void PrintSelf(ostream& os, vtkIndent indent);
    00066
    00068
    00069   vtkSetStringMacro(FileName);
    00070   vtkGetStringMacro(FileName);
    00072
    00074
    00076   int IsFileValid(const char *dstype);
    00077   int IsFileStructuredPoints() {
    00078     return this->IsFileValid("structured_points");};
    00079   int IsFilePolyData() {
    00080     return this->IsFileValid("polydata");};
    00081   int IsFileStructuredGrid() {
    00082     return this->IsFileValid("structured_grid");};
    00083   int IsFileUnstructuredGrid() {
    00084     return this->IsFileValid("unstructured_grid");};
    00085   int IsFileRectilinearGrid() {
    00086     return this->IsFileValid("rectilinear_grid");};
    00088
    00090
    00094   void SetInputString(const char *in);
    00095   vtkGetStringMacro(InputString);
    00096   void SetInputString(const char *in, int len);
    00097   vtkGetMacro(InputStringLength, int);
    00098   void SetBinaryInputString(const char *, int len);
    00100
    00102
    00108   virtual void SetInputArray(vtkCharArray*);
    00109   vtkGetObjectMacro(InputArray, vtkCharArray);
    00111
    00113
    00114   vtkGetStringMacro(Header);
    00116
    00118
    00120   vtkSetMacro(ReadFromInputString,int);
    00121   vtkGetMacro(ReadFromInputString,int);
    00122   vtkBooleanMacro(ReadFromInputString,int);
    00124
    00126
    00128   vtkGetMacro(FileType,int);
    00130
    00132
    00136   int GetNumberOfScalarsInFile()
    00137     {this->CharacterizeFile(); return this->NumberOfScalarsInFile;}
    00138   int GetNumberOfVectorsInFile()
    00139     {this->CharacterizeFile(); return this->NumberOfVectorsInFile;}
    00140   int GetNumberOfTensorsInFile()
    00141     {this->CharacterizeFile(); return this->NumberOfTensorsInFile;}
    00142   int GetNumberOfNormalsInFile()
    00143     {this->CharacterizeFile(); return this->NumberOfNormalsInFile;}
    00144   int GetNumberOfTCoordsInFile()
    00145     {this->CharacterizeFile(); return this->NumberOfTCoordsInFile;}
    00146   int GetNumberOfFieldDataInFile()
    00147     {this->CharacterizeFile(); return this->NumberOfFieldDataInFile;}
    00149
    00151
    00154   const char *GetScalarsNameInFile(int i);
    00155   const char *GetVectorsNameInFile(int i);
    00156   const char *GetTensorsNameInFile(int i);
    00157   const char *GetNormalsNameInFile(int i);
    00158   const char *GetTCoordsNameInFile(int i);
    00159   const char *GetFieldDataNameInFile(int i);
    00161
    00163
    00165   vtkSetStringMacro(ScalarsName);
    00166   vtkGetStringMacro(ScalarsName);
    00168
    00170
    00172   vtkSetStringMacro(VectorsName);
    00173   vtkGetStringMacro(VectorsName);
    00175
    00177
    00179   vtkSetStringMacro(TensorsName);
    00180   vtkGetStringMacro(TensorsName);
    00182
    00184
    00186   vtkSetStringMacro(NormalsName);
    00187   vtkGetStringMacro(NormalsName);
    00189
    00191
    00193   vtkSetStringMacro(TCoordsName);
    00194   vtkGetStringMacro(TCoordsName);
    00196
    00198
    00201   vtkSetStringMacro(LookupTableName);
    00202   vtkGetStringMacro(LookupTableName);
    00204
    00206
    00208   vtkSetStringMacro(FieldDataName);
    00209   vtkGetStringMacro(FieldDataName);
    00211
    00213   int OpenVTKFile();
    00214
    00216   int ReadHeader();
    00217
    00221   int ReadCellData(vtkDataSet *ds, int numCells);
    00222
    00226   int ReadPointData(vtkDataSet *ds, int numPts);
    00227
    00229   int ReadPoints(vtkPointSet *ps, int numPts);
    00230
    00232   int ReadCells(int size, int *data);
    00233
    00235   int ReadCells(int size, int *data, int skip1, int read2, int skip3);
    00236
    00239   int ReadCoordinates(vtkRectilinearGrid *rg, int axes, int numCoords);
    00240
    00242
    00243   vtkDataArray *ReadArray(const char *dataType, int numTuples, int numComp);
    00244   vtkFieldData *ReadFieldData();
    00246
    00248
    00250   int Read(char *);
    00251   int Read(unsigned char *);
    00252   int Read(short *);
    00253   int Read(unsigned short *);
    00254   int Read(int *);
    00255   int Read(unsigned int *);
    00256   int Read(long *);
    00257   int Read(unsigned long *);
    00258   int Read(float *);
    00259   int Read(double *);
    00261
    00263   void CloseVTKFile();
    00264
    00265 //BTX
    00268   int ReadLine(char result[256]);
    00269
    00272   int ReadString(char result[256]);
    00273
    00275   char *LowerCase(char *str, const size_t len=256);
    00276
    00278   istream *GetIStream() {return this->IS;};
    00279 //ETX
    00280
    00281 protected:
    00282   vtkDataReader();
    00283   ~vtkDataReader();
    00284
    00285   char *FileName;
    00286   int FileType;
    00287   istream *IS;
    00288
    00289   char *ScalarsName;
    00290   char *VectorsName;
    00291   char *TensorsName;
    00292   char *TCoordsName;
    00293   char *NormalsName;
    00294   char *LookupTableName;
    00295   char *FieldDataName;
    00296   char *ScalarLut;
    00297
    00298   int ReadFromInputString;
    00299   char *InputString;
    00300   int InputStringLength;
    00301   int InputStringPos;
    00302
    00303   vtkSetStringMacro(ScalarLut);
    00304   vtkGetStringMacro(ScalarLut);
    00305
    00306   char *Header;
    00307
    00308   int ReadScalarData(vtkDataSetAttributes *a, int num);
    00309   int ReadVectorData(vtkDataSetAttributes *a, int num);
    00310   int ReadNormalData(vtkDataSetAttributes *a, int num);
    00311   int ReadTensorData(vtkDataSetAttributes *a, int num);
    00312   int ReadCoScalarData(vtkDataSetAttributes *a, int num);
    00313   int ReadLutData(vtkDataSetAttributes *a);
    00314   int ReadTCoordsData(vtkDataSetAttributes *a, int num);
    00315
    00316   int ReadDataSetData(vtkDataSet *ds);
    00317
    00318   // This supports getting additional information from vtk files
    00319   int  NumberOfScalarsInFile;
    00320   char **ScalarsNameInFile;
    00321   int ScalarsNameAllocSize;
    00322   int  NumberOfVectorsInFile;
    00323   char **VectorsNameInFile;
    00324   int VectorsNameAllocSize;
    00325   int  NumberOfTensorsInFile;
    00326   char **TensorsNameInFile;
    00327   int TensorsNameAllocSize;
    00328   int  NumberOfTCoordsInFile;
    00329   char **TCoordsNameInFile;
    00330   int TCoordsNameAllocSize;
    00331   int  NumberOfNormalsInFile;
    00332   char **NormalsNameInFile;
    00333   int NormalsNameAllocSize;
    00334   int  NumberOfFieldDataInFile;
    00335   char **FieldDataNameInFile;
    00336   int FieldDataNameAllocSize;
    00337   vtkTimeStamp CharacteristicsTime;
    00338
    00339   void InitializeCharacteristics();
    00340   int CharacterizeFile(); //read entire file, storing important characteristics
    00341   void CheckFor(const char* name, char *line, int &num, char** &array,
    00342                 int& allocSize);
    00343
    00344   vtkCharArray* InputArray;
    00345
    00348   void DecodeArrayName(char *resname, const char* name);
    00349
    00350 private:
    00351   vtkDataReader(const vtkDataReader&);  // Not implemented.
    00352   void operator=(const vtkDataReader&);  // Not implemented.
    00353 };
    00354
    00355 #endif
    00356
    00357