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
00055 #ifndef __vtkDataReader_h
00056 #define __vtkDataReader_h
00057
00058 #include "vtkSource.h"
00059 #include "vtkDataSetAttributes.h"
00060
00061 #define VTK_ASCII 1
00062 #define VTK_BINARY 2
00063
00064 class vtkDataSet;
00065 class vtkPointSet;
00066 class vtkRectilinearGrid;
00067
00068 class VTK_EXPORT vtkDataReader : public vtkSource
00069 {
00070 public:
00071 static vtkDataReader *New();
00072 vtkTypeMacro(vtkDataReader,vtkObject);
00073 void PrintSelf(ostream& os, vtkIndent indent);
00074
00076 vtkSetStringMacro(FileName);
00077 vtkGetStringMacro(FileName);
00078
00081 int IsFileValid(const char *dstype);
00082 int IsFileStructuredPoints() {
00083 return this->IsFileValid("structured_points");};
00084 int IsFilePolyData() {
00085 return this->IsFileValid("polydata");};
00086 int IsFileStructuredGrid() {
00087 return this->IsFileValid("structured_grid");};
00088 int IsFileUnstructuredGrid() {
00089 return this->IsFileValid("unstructured_grid");};
00090 int IsFileRectilinearGrid() {
00091 return this->IsFileValid("rectilinear_grid");};
00092
00095 void SetInputString(const char *in);
00096 vtkGetStringMacro(InputString);
00097 void SetInputString(const char *in, int len);
00098 vtkGetMacro(InputStringLength, int);
00099 void SetBinaryInputString(const char *, int len);
00100
00102 vtkGetStringMacro(Header);
00103
00105 vtkSetMacro(ReadFromInputString,int);
00106 vtkGetMacro(ReadFromInputString,int);
00107 vtkBooleanMacro(ReadFromInputString,int);
00108
00111 vtkGetMacro(FileType,int);
00112
00117 int GetNumberOfScalarsInFile()
00118 {this->CharacterizeFile(); return this->NumberOfScalarsInFile;}
00119 int GetNumberOfVectorsInFile()
00120 {this->CharacterizeFile(); return this->NumberOfVectorsInFile;}
00121 int GetNumberOfTensorsInFile()
00122 {this->CharacterizeFile(); return this->NumberOfTensorsInFile;}
00123 int GetNumberOfNormalsInFile()
00124 {this->CharacterizeFile(); return this->NumberOfNormalsInFile;}
00125 int GetNumberOfTCoordsInFile()
00126 {this->CharacterizeFile(); return this->NumberOfTCoordsInFile;}
00127 int GetNumberOfFieldDataInFile()
00128 {this->CharacterizeFile(); return this->NumberOfFieldDataInFile;}
00129 int GetNumberOfGhostLevelsInFile()
00130 {this->CharacterizeFile(); return this->NumberOfGhostLevelsInFile;}
00131
00135 const char *GetScalarsNameInFile(int i);
00136 const char *GetVectorsNameInFile(int i);
00137 const char *GetTensorsNameInFile(int i);
00138 const char *GetNormalsNameInFile(int i);
00139 const char *GetTCoordsNameInFile(int i);
00140 const char *GetFieldDataNameInFile(int i);
00141 const char *GetGhostLevelsNameInFile(int i);
00142
00145 vtkSetStringMacro(ScalarsName);
00146 vtkGetStringMacro(ScalarsName);
00147
00150 vtkSetStringMacro(VectorsName);
00151 vtkGetStringMacro(VectorsName);
00152
00155 vtkSetStringMacro(TensorsName);
00156 vtkGetStringMacro(TensorsName);
00157
00160 vtkSetStringMacro(GhostLevelsName);
00161 vtkGetStringMacro(GhostLevelsName);
00162
00165 vtkSetStringMacro(NormalsName);
00166 vtkGetStringMacro(NormalsName);
00167
00170 vtkSetStringMacro(TCoordsName);
00171 vtkGetStringMacro(TCoordsName);
00172
00176 vtkSetStringMacro(LookupTableName);
00177 vtkGetStringMacro(LookupTableName);
00178
00181 vtkSetStringMacro(FieldDataName);
00182 vtkGetStringMacro(FieldDataName);
00183
00185 int OpenVTKFile();
00186
00188 int ReadHeader();
00189
00193 int ReadCellData(vtkDataSet *ds, int numCells);
00194
00198 int ReadPointData(vtkDataSet *ds, int numPts);
00199
00201 int ReadPoints(vtkPointSet *ps, int numPts);
00202
00204 int ReadCells(int size, int *data);
00205
00207 int ReadCells(int size, int *data, int skip1, int read2, int skip3);
00208
00211 int ReadCoordinates(vtkRectilinearGrid *rg, int axes, int numCoords);
00212
00214 vtkDataArray *ReadArray(const char *dataType, int numTuples, int numComp);
00215 vtkFieldData *ReadFieldData();
00216
00219 int Read(char *);
00220 int Read(unsigned char *);
00221 int Read(short *);
00222 int Read(unsigned short *);
00223 int Read(int *);
00224 int Read(unsigned int *);
00225 int Read(long *);
00226 int Read(unsigned long *);
00227 int Read(float *);
00228 int Read(double *);
00229
00231 void CloseVTKFile();
00232
00235 int ReadLine(char result[256]);
00236
00239 int ReadString(char result[256]);
00240
00242 char *LowerCase(char *);
00243
00245 istream *GetIStream() {return this->IS;};
00246
00247 protected:
00248 vtkDataReader();
00249 ~vtkDataReader();
00250 vtkDataReader(const vtkDataReader&) {};
00251 void operator=(const vtkDataReader&) {};
00252
00253 char *FileName;
00254 int FileType;
00255 istream *IS;
00256
00257 char *ScalarsName;
00258 char *VectorsName;
00259 char *TensorsName;
00260 char *GhostLevelsName;
00261 char *TCoordsName;
00262 char *NormalsName;
00263 char *LookupTableName;
00264 char *FieldDataName;
00265 char *ScalarLut;
00266
00267 int ReadFromInputString;
00268 char *InputString;
00269 int InputStringLength;
00270 int InputStringPos;
00271
00272 vtkSetStringMacro(ScalarLut);
00273 vtkGetStringMacro(ScalarLut);
00274
00275 char *Header;
00276
00277 int ReadScalarData(vtkDataSetAttributes *a, int num);
00278 int ReadVectorData(vtkDataSetAttributes *a, int num);
00279 int ReadNormalData(vtkDataSetAttributes *a, int num);
00280 int ReadTensorData(vtkDataSetAttributes *a, int num);
00281 int ReadGhostLevelData(vtkDataSetAttributes *a, int num);
00282 int ReadCoScalarData(vtkDataSetAttributes *a, int num);
00283 int ReadLutData(vtkDataSetAttributes *a);
00284 int ReadTCoordsData(vtkDataSetAttributes *a, int num);
00285
00286 int ReadDataSetData(vtkDataSet *ds);
00287
00288
00289 int NumberOfScalarsInFile;
00290 char **ScalarsNameInFile;
00291 int ScalarsNameAllocSize;
00292 int NumberOfVectorsInFile;
00293 char **VectorsNameInFile;
00294 int VectorsNameAllocSize;
00295 int NumberOfTensorsInFile;
00296 char **TensorsNameInFile;
00297 int TensorsNameAllocSize;
00298 int NumberOfGhostLevelsInFile;
00299 char **GhostLevelsNameInFile;
00300 int GhostLevelsNameAllocSize;
00301 int NumberOfTCoordsInFile;
00302 char **TCoordsNameInFile;
00303 int TCoordsNameAllocSize;
00304 int NumberOfNormalsInFile;
00305 char **NormalsNameInFile;
00306 int NormalsNameAllocSize;
00307 int NumberOfFieldDataInFile;
00308 char **FieldDataNameInFile;
00309 int FieldDataNameAllocSize;
00310 vtkTimeStamp CharacteristicsTime;
00311
00312 void InitializeCharacteristics();
00313 int CharacterizeFile();
00314 void CheckFor(const char* name, char *line, int &num, char** &array,
00315 int& allocSize);
00316
00317 };
00318
00319 #endif
00320
00321