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

IO/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 =========================================================================*/
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 //BTX
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 //ETX
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   // This supports getting additional information from vtk files
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(); //read entire file, storing important characteristics
00336   void CheckFor(const char* name, char *line, int &num, char** &array, 
00337                 int& allocSize);
00338 
00339 private:
00340   vtkDataReader(const vtkDataReader&);  // Not implemented.
00341   void operator=(const vtkDataReader&);  // Not implemented.
00342 };
00343 
00344 #endif
00345 
00346 

Generated on Thu Mar 28 14:19:28 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001