00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00028 #ifndef __vtkDataReader_h
00029 #define __vtkDataReader_h
00030
00031 #include "vtkAlgorithm.h"
00032
00033 #define VTK_ASCII 1
00034 #define VTK_BINARY 2
00035
00036 class vtkAbstractArray;
00037 class vtkCharArray;
00038 class vtkDataSet;
00039 class vtkDataSetAttributes;
00040 class vtkFieldData;
00041 class vtkGraph;
00042 class vtkPointSet;
00043 class vtkRectilinearGrid;
00044 class vtkTable;
00045
00046 class VTK_IO_EXPORT vtkDataReader : public vtkAlgorithm
00047 {
00048 public:
00049 static vtkDataReader *New();
00050 vtkTypeMacro(vtkDataReader,vtkAlgorithm);
00051 void PrintSelf(ostream& os, vtkIndent indent);
00052
00054
00055 vtkSetStringMacro(FileName);
00056 vtkGetStringMacro(FileName);
00058
00060
00062 int IsFileValid(const char *dstype);
00063 int IsFileStructuredPoints() {
00064 return this->IsFileValid("structured_points");};
00065 int IsFilePolyData() {
00066 return this->IsFileValid("polydata");};
00067 int IsFileStructuredGrid() {
00068 return this->IsFileValid("structured_grid");};
00069 int IsFileUnstructuredGrid() {
00070 return this->IsFileValid("unstructured_grid");};
00071 int IsFileRectilinearGrid() {
00072 return this->IsFileValid("rectilinear_grid");};
00074
00076
00080 void SetInputString(const char *in);
00081 vtkGetStringMacro(InputString);
00082 void SetInputString(const char *in, int len);
00083 vtkGetMacro(InputStringLength, int);
00084 void SetBinaryInputString(const char *, int len);
00086
00088
00094 virtual void SetInputArray(vtkCharArray*);
00095 vtkGetObjectMacro(InputArray, vtkCharArray);
00097
00099
00100 vtkGetStringMacro(Header);
00102
00104
00106 vtkSetMacro(ReadFromInputString,int);
00107 vtkGetMacro(ReadFromInputString,int);
00108 vtkBooleanMacro(ReadFromInputString,int);
00110
00112
00114 vtkGetMacro(FileType,int);
00116
00118
00122 int GetNumberOfScalarsInFile()
00123 {this->CharacterizeFile(); return this->NumberOfScalarsInFile;}
00124 int GetNumberOfVectorsInFile()
00125 {this->CharacterizeFile(); return this->NumberOfVectorsInFile;}
00126 int GetNumberOfTensorsInFile()
00127 {this->CharacterizeFile(); return this->NumberOfTensorsInFile;}
00128 int GetNumberOfNormalsInFile()
00129 {this->CharacterizeFile(); return this->NumberOfNormalsInFile;}
00130 int GetNumberOfTCoordsInFile()
00131 {this->CharacterizeFile(); return this->NumberOfTCoordsInFile;}
00132 int GetNumberOfFieldDataInFile()
00133 {this->CharacterizeFile(); return this->NumberOfFieldDataInFile;}
00135
00137
00140 const char *GetScalarsNameInFile(int i);
00141 const char *GetVectorsNameInFile(int i);
00142 const char *GetTensorsNameInFile(int i);
00143 const char *GetNormalsNameInFile(int i);
00144 const char *GetTCoordsNameInFile(int i);
00145 const char *GetFieldDataNameInFile(int i);
00147
00149
00151 vtkSetStringMacro(ScalarsName);
00152 vtkGetStringMacro(ScalarsName);
00154
00156
00158 vtkSetStringMacro(VectorsName);
00159 vtkGetStringMacro(VectorsName);
00161
00163
00165 vtkSetStringMacro(TensorsName);
00166 vtkGetStringMacro(TensorsName);
00168
00170
00172 vtkSetStringMacro(NormalsName);
00173 vtkGetStringMacro(NormalsName);
00175
00177
00179 vtkSetStringMacro(TCoordsName);
00180 vtkGetStringMacro(TCoordsName);
00182
00184
00187 vtkSetStringMacro(LookupTableName);
00188 vtkGetStringMacro(LookupTableName);
00190
00192
00194 vtkSetStringMacro(FieldDataName);
00195 vtkGetStringMacro(FieldDataName);
00197
00199
00200 vtkSetMacro(ReadAllScalars,int);
00201 vtkGetMacro(ReadAllScalars,int);
00202 vtkBooleanMacro(ReadAllScalars,int);
00204
00206
00207 vtkSetMacro(ReadAllVectors,int);
00208 vtkGetMacro(ReadAllVectors,int);
00209 vtkBooleanMacro(ReadAllVectors,int);
00211
00213
00214 vtkSetMacro(ReadAllNormals,int);
00215 vtkGetMacro(ReadAllNormals,int);
00216 vtkBooleanMacro(ReadAllNormals,int);
00218
00220
00221 vtkSetMacro(ReadAllTensors,int);
00222 vtkGetMacro(ReadAllTensors,int);
00223 vtkBooleanMacro(ReadAllTensors,int);
00225
00227
00228 vtkSetMacro(ReadAllColorScalars,int);
00229 vtkGetMacro(ReadAllColorScalars,int);
00230 vtkBooleanMacro(ReadAllColorScalars,int);
00232
00234
00235 vtkSetMacro(ReadAllTCoords,int);
00236 vtkGetMacro(ReadAllTCoords,int);
00237 vtkBooleanMacro(ReadAllTCoords,int);
00239
00241
00242 vtkSetMacro(ReadAllFields,int);
00243 vtkGetMacro(ReadAllFields,int);
00244 vtkBooleanMacro(ReadAllFields,int);
00246
00248 int OpenVTKFile();
00249
00251 int ReadHeader();
00252
00256 int ReadCellData(vtkDataSet *ds, int numCells);
00257
00261 int ReadPointData(vtkDataSet *ds, int numPts);
00262
00264 int ReadPoints(vtkPointSet *ps, int numPts);
00265
00267 int ReadPoints(vtkGraph *g, int numPts);
00268
00272 int ReadVertexData(vtkGraph *g, int numVertices);
00273
00277 int ReadEdgeData(vtkGraph *g, int numEdges);
00278
00280 int ReadRowData(vtkTable *t, int numEdges);
00281
00283 int ReadCells(int size, int *data);
00284
00286 int ReadCells(int size, int *data, int skip1, int read2, int skip3);
00287
00290 int ReadCoordinates(vtkRectilinearGrid *rg, int axes, int numCoords);
00291
00293
00294 vtkAbstractArray *ReadArray(const char *dataType, int numTuples, int numComp);
00295 vtkFieldData *ReadFieldData();
00297
00298
00300
00302 int Read(char *);
00303 int Read(unsigned char *);
00304 int Read(short *);
00305 int Read(unsigned short *);
00306 int Read(int *);
00307 int Read(unsigned int *);
00308 int Read(long *);
00309 int Read(unsigned long *);
00310 #if defined(VTK_TYPE_USE___INT64)
00311 int Read(__int64 *result);
00312 int Read(unsigned __int64 *result);
00314 #endif
00315 #if defined(VTK_TYPE_USE_LONG_LONG)
00316 int Read(long long *result);
00317 int Read(unsigned long long *result);
00318 #endif
00319 int Read(float *);
00320 int Read(double *);
00321
00322
00324 void CloseVTKFile();
00325
00326
00329 int ReadLine(char result[256]);
00330
00333 int ReadString(char result[256]);
00334
00336 char *LowerCase(char *str, const size_t len=256);
00337
00339 istream *GetIStream() {return this->IS;};
00340
00341
00344 virtual int ReadMetaData(vtkInformation *) { return 1; }
00345
00346 protected:
00347 vtkDataReader();
00348 ~vtkDataReader();
00349
00350 char *FileName;
00351 int FileType;
00352 istream *IS;
00353
00354 char *ScalarsName;
00355 char *VectorsName;
00356 char *TensorsName;
00357 char *TCoordsName;
00358 char *NormalsName;
00359 char *LookupTableName;
00360 char *FieldDataName;
00361 char *ScalarLut;
00362
00363 int ReadFromInputString;
00364 char *InputString;
00365 int InputStringLength;
00366 int InputStringPos;
00367
00368 void SetScalarLut(const char* lut);
00369 vtkGetStringMacro(ScalarLut);
00370
00371 char *Header;
00372
00373 int ReadScalarData(vtkDataSetAttributes *a, int num);
00374 int ReadVectorData(vtkDataSetAttributes *a, int num);
00375 int ReadNormalData(vtkDataSetAttributes *a, int num);
00376 int ReadTensorData(vtkDataSetAttributes *a, int num);
00377 int ReadCoScalarData(vtkDataSetAttributes *a, int num);
00378 int ReadLutData(vtkDataSetAttributes *a);
00379 int ReadTCoordsData(vtkDataSetAttributes *a, int num);
00380 int ReadGlobalIds(vtkDataSetAttributes *a, int num);
00381 int ReadPedigreeIds(vtkDataSetAttributes *a, int num);
00382
00383 int ReadDataSetData(vtkDataSet *ds);
00384
00385
00386 int NumberOfScalarsInFile;
00387 char **ScalarsNameInFile;
00388 int ScalarsNameAllocSize;
00389 int NumberOfVectorsInFile;
00390 char **VectorsNameInFile;
00391 int VectorsNameAllocSize;
00392 int NumberOfTensorsInFile;
00393 char **TensorsNameInFile;
00394 int TensorsNameAllocSize;
00395 int NumberOfTCoordsInFile;
00396 char **TCoordsNameInFile;
00397 int TCoordsNameAllocSize;
00398 int NumberOfNormalsInFile;
00399 char **NormalsNameInFile;
00400 int NormalsNameAllocSize;
00401 int NumberOfFieldDataInFile;
00402 char **FieldDataNameInFile;
00403 int FieldDataNameAllocSize;
00404 vtkTimeStamp CharacteristicsTime;
00405
00406 int ReadAllScalars;
00407 int ReadAllVectors;
00408 int ReadAllNormals;
00409 int ReadAllTensors;
00410 int ReadAllColorScalars;
00411 int ReadAllTCoords;
00412 int ReadAllFields;
00413
00414 void InitializeCharacteristics();
00415 int CharacterizeFile();
00416 void CheckFor(const char* name, char *line, int &num, char** &array,
00417 int& allocSize);
00418
00419 vtkCharArray* InputArray;
00420
00423 int DecodeString(char *resname, const char* name);
00424
00425 virtual int ProcessRequest(vtkInformation *, vtkInformationVector **,
00426 vtkInformationVector *);
00427 virtual int RequestData(vtkInformation *, vtkInformationVector **,
00428 vtkInformationVector *)
00429 { return 1; }
00430 virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **,
00431 vtkInformationVector *)
00432 { return 1; }
00433 virtual int RequestInformation(vtkInformation *, vtkInformationVector **,
00434 vtkInformationVector *)
00435 { return 1; }
00436
00437 private:
00438 vtkDataReader(const vtkDataReader&);
00439 void operator=(const vtkDataReader&);
00440 };
00441
00442 #endif
00443
00444