00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00056 #ifndef __vtkDataReader_h
00057 #define __vtkDataReader_h
00058
00059 #include "vtkSource.h"
00060 #include "vtkDataSetAttributes.h"
00061
00062 #define VTK_ASCII 1
00063 #define VTK_BINARY 2
00064
00065 class vtkDataSet;
00066 class vtkPointSet;
00067 class vtkRectilinearGrid;
00068
00069 class VTK_IO_EXPORT vtkDataReader : public vtkSource
00070 {
00071 public:
00072 static vtkDataReader *New();
00073 vtkTypeMacro(vtkDataReader,vtkObject);
00074 void PrintSelf(ostream& os, vtkIndent indent);
00075
00077
00078 vtkSetStringMacro(FileName);
00079 vtkGetStringMacro(FileName);
00081
00083
00085 int IsFileValid(const char *dstype);
00086 int IsFileStructuredPoints() {
00087 return this->IsFileValid("structured_points");};
00088 int IsFilePolyData() {
00089 return this->IsFileValid("polydata");};
00090 int IsFileStructuredGrid() {
00091 return this->IsFileValid("structured_grid");};
00092 int IsFileUnstructuredGrid() {
00093 return this->IsFileValid("unstructured_grid");};
00094 int IsFileRectilinearGrid() {
00095 return this->IsFileValid("rectilinear_grid");};
00097
00099
00101 void SetInputString(const char *in);
00102 vtkGetStringMacro(InputString);
00103 void SetInputString(const char *in, int len);
00104 vtkGetMacro(InputStringLength, int);
00105 void SetBinaryInputString(const char *, int len);
00107
00109
00110 vtkGetStringMacro(Header);
00112
00114
00115 vtkSetMacro(ReadFromInputString,int);
00116 vtkGetMacro(ReadFromInputString,int);
00117 vtkBooleanMacro(ReadFromInputString,int);
00119
00121
00123 vtkGetMacro(FileType,int);
00125
00127
00131 int GetNumberOfScalarsInFile()
00132 {this->CharacterizeFile(); return this->NumberOfScalarsInFile;}
00133 int GetNumberOfVectorsInFile()
00134 {this->CharacterizeFile(); return this->NumberOfVectorsInFile;}
00135 int GetNumberOfTensorsInFile()
00136 {this->CharacterizeFile(); return this->NumberOfTensorsInFile;}
00137 int GetNumberOfNormalsInFile()
00138 {this->CharacterizeFile(); return this->NumberOfNormalsInFile;}
00139 int GetNumberOfTCoordsInFile()
00140 {this->CharacterizeFile(); return this->NumberOfTCoordsInFile;}
00141 int GetNumberOfFieldDataInFile()
00142 {this->CharacterizeFile(); return this->NumberOfFieldDataInFile;}
00144
00146
00149 const char *GetScalarsNameInFile(int i);
00150 const char *GetVectorsNameInFile(int i);
00151 const char *GetTensorsNameInFile(int i);
00152 const char *GetNormalsNameInFile(int i);
00153 const char *GetTCoordsNameInFile(int i);
00154 const char *GetFieldDataNameInFile(int i);
00156
00158
00160 vtkSetStringMacro(ScalarsName);
00161 vtkGetStringMacro(ScalarsName);
00163
00165
00167 vtkSetStringMacro(VectorsName);
00168 vtkGetStringMacro(VectorsName);
00170
00172
00174 vtkSetStringMacro(TensorsName);
00175 vtkGetStringMacro(TensorsName);
00177
00179
00181 vtkSetStringMacro(NormalsName);
00182 vtkGetStringMacro(NormalsName);
00184
00186
00188 vtkSetStringMacro(TCoordsName);
00189 vtkGetStringMacro(TCoordsName);
00191
00193
00196 vtkSetStringMacro(LookupTableName);
00197 vtkGetStringMacro(LookupTableName);
00199
00201
00203 vtkSetStringMacro(FieldDataName);
00204 vtkGetStringMacro(FieldDataName);
00206
00208 int OpenVTKFile();
00209
00211 int ReadHeader();
00212
00216 int ReadCellData(vtkDataSet *ds, int numCells);
00217
00221 int ReadPointData(vtkDataSet *ds, int numPts);
00222
00224 int ReadPoints(vtkPointSet *ps, int numPts);
00225
00227 int ReadCells(int size, int *data);
00228
00230 int ReadCells(int size, int *data, int skip1, int read2, int skip3);
00231
00234 int ReadCoordinates(vtkRectilinearGrid *rg, int axes, int numCoords);
00235
00237
00238 vtkDataArray *ReadArray(const char *dataType, int numTuples, int numComp);
00239 vtkFieldData *ReadFieldData();
00241
00243
00245 int Read(char *);
00246 int Read(unsigned char *);
00247 int Read(short *);
00248 int Read(unsigned short *);
00249 int Read(int *);
00250 int Read(unsigned int *);
00251 int Read(long *);
00252 int Read(unsigned long *);
00253 int Read(float *);
00254 int Read(double *);
00256
00258 void CloseVTKFile();
00259
00260
00263 int ReadLine(char result[256]);
00264
00267 int ReadString(char result[256]);
00268
00270 char *LowerCase(char *str, const size_t len=256);
00271
00273 istream *GetIStream() {return this->IS;};
00274
00275
00276 protected:
00277 vtkDataReader();
00278 ~vtkDataReader();
00279
00280 char *FileName;
00281 int FileType;
00282 istream *IS;
00283
00284 char *ScalarsName;
00285 char *VectorsName;
00286 char *TensorsName;
00287 char *TCoordsName;
00288 char *NormalsName;
00289 char *LookupTableName;
00290 char *FieldDataName;
00291 char *ScalarLut;
00292
00293 int ReadFromInputString;
00294 char *InputString;
00295 int InputStringLength;
00296 int InputStringPos;
00297
00298 vtkSetStringMacro(ScalarLut);
00299 vtkGetStringMacro(ScalarLut);
00300
00301 char *Header;
00302
00303 int ReadScalarData(vtkDataSetAttributes *a, int num);
00304 int ReadVectorData(vtkDataSetAttributes *a, int num);
00305 int ReadNormalData(vtkDataSetAttributes *a, int num);
00306 int ReadTensorData(vtkDataSetAttributes *a, int num);
00307 int ReadCoScalarData(vtkDataSetAttributes *a, int num);
00308 int ReadLutData(vtkDataSetAttributes *a);
00309 int ReadTCoordsData(vtkDataSetAttributes *a, int num);
00310
00311 int ReadDataSetData(vtkDataSet *ds);
00312
00313
00314 int NumberOfScalarsInFile;
00315 char **ScalarsNameInFile;
00316 int ScalarsNameAllocSize;
00317 int NumberOfVectorsInFile;
00318 char **VectorsNameInFile;
00319 int VectorsNameAllocSize;
00320 int NumberOfTensorsInFile;
00321 char **TensorsNameInFile;
00322 int TensorsNameAllocSize;
00323 int NumberOfTCoordsInFile;
00324 char **TCoordsNameInFile;
00325 int TCoordsNameAllocSize;
00326 int NumberOfNormalsInFile;
00327 char **NormalsNameInFile;
00328 int NormalsNameAllocSize;
00329 int NumberOfFieldDataInFile;
00330 char **FieldDataNameInFile;
00331 int FieldDataNameAllocSize;
00332 vtkTimeStamp CharacteristicsTime;
00333
00334 void InitializeCharacteristics();
00335 int CharacterizeFile();
00336 void CheckFor(const char* name, char *line, int &num, char** &array,
00337 int& allocSize);
00338
00339 private:
00340 vtkDataReader(const vtkDataReader&);
00341 void operator=(const vtkDataReader&);
00342 };
00343
00344 #endif
00345
00346