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);
00313 #endif
00314 #if defined(VTK_TYPE_USE_LONG_LONG)
00315 int Read(long long *result);
00316 int Read(unsigned long long *result);
00317 #endif
00318 int Read(float *);
00319 int Read(double *);
00320
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
00340 istream *GetIStream() {return this->IS;};
00341
00343
00346 virtual int ReadMetaData(vtkInformation *) { return 1; }
00347
00348 protected:
00349 vtkDataReader();
00350 ~vtkDataReader();
00351
00352 char *FileName;
00353 int FileType;
00354 istream *IS;
00355
00356 char *ScalarsName;
00357 char *VectorsName;
00358 char *TensorsName;
00359 char *TCoordsName;
00360 char *NormalsName;
00361 char *LookupTableName;
00362 char *FieldDataName;
00363 char *ScalarLut;
00364
00365 int ReadFromInputString;
00366 char *InputString;
00367 int InputStringLength;
00368 int InputStringPos;
00369
00370 void SetScalarLut(const char* lut);
00371 vtkGetStringMacro(ScalarLut);
00372
00373 char *Header;
00374
00375 int ReadScalarData(vtkDataSetAttributes *a, int num);
00376 int ReadVectorData(vtkDataSetAttributes *a, int num);
00377 int ReadNormalData(vtkDataSetAttributes *a, int num);
00378 int ReadTensorData(vtkDataSetAttributes *a, int num);
00379 int ReadCoScalarData(vtkDataSetAttributes *a, int num);
00380 int ReadLutData(vtkDataSetAttributes *a);
00381 int ReadTCoordsData(vtkDataSetAttributes *a, int num);
00382 int ReadGlobalIds(vtkDataSetAttributes *a, int num);
00383 int ReadPedigreeIds(vtkDataSetAttributes *a, int num);
00384
00385 int ReadDataSetData(vtkDataSet *ds);
00386
00387
00388 int NumberOfScalarsInFile;
00389 char **ScalarsNameInFile;
00390 int ScalarsNameAllocSize;
00391 int NumberOfVectorsInFile;
00392 char **VectorsNameInFile;
00393 int VectorsNameAllocSize;
00394 int NumberOfTensorsInFile;
00395 char **TensorsNameInFile;
00396 int TensorsNameAllocSize;
00397 int NumberOfTCoordsInFile;
00398 char **TCoordsNameInFile;
00399 int TCoordsNameAllocSize;
00400 int NumberOfNormalsInFile;
00401 char **NormalsNameInFile;
00402 int NormalsNameAllocSize;
00403 int NumberOfFieldDataInFile;
00404 char **FieldDataNameInFile;
00405 int FieldDataNameAllocSize;
00406 vtkTimeStamp CharacteristicsTime;
00407
00408 int ReadAllScalars;
00409 int ReadAllVectors;
00410 int ReadAllNormals;
00411 int ReadAllTensors;
00412 int ReadAllColorScalars;
00413 int ReadAllTCoords;
00414 int ReadAllFields;
00415
00416 void InitializeCharacteristics();
00417 int CharacterizeFile();
00418 void CheckFor(const char* name, char *line, int &num, char** &array,
00419 int& allocSize);
00420
00421 vtkCharArray* InputArray;
00422
00425 int DecodeString(char *resname, const char* name);
00426
00427 virtual int ProcessRequest(vtkInformation *, vtkInformationVector **,
00428 vtkInformationVector *);
00429 virtual int RequestData(vtkInformation *, vtkInformationVector **,
00430 vtkInformationVector *)
00431 { return 1; }
00432 virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **,
00433 vtkInformationVector *)
00434 { return 1; }
00435 virtual int RequestInformation(vtkInformation *, vtkInformationVector **,
00436 vtkInformationVector *)
00437 { return 1; }
00438
00439 private:
00440 vtkDataReader(const vtkDataReader&);
00441 void operator=(const vtkDataReader&);
00442 };
00443
00444 #endif
00445
00446