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

graphics/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 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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   // This supports getting additional information from vtk files
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(); //read entire file, storing important characteristics
00314   void CheckFor(const char* name, char *line, int &num, char** &array, 
00315                 int& allocSize);
00316 
00317 };
00318 
00319 #endif
00320 
00321 

Generated on Wed Nov 21 12:26:58 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001