VTK
dox/IO/vtkPLOT3DReader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkPLOT3DReader.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00080 #ifndef __vtkPLOT3DReader_h
00081 #define __vtkPLOT3DReader_h
00082 
00083 #include "vtkStructuredGridSource.h"
00084 #include "vtkIdList.h" // Needed for internal method
00085 
00086 class vtkUnsignedCharArray;
00087 class vtkIntArray;
00088 class vtkFloatArray;
00089 class vtkStructuredGrid;
00090 
00091 class VTK_IO_EXPORT vtkPLOT3DReader : public vtkStructuredGridSource 
00092 {
00093 public:
00094   static vtkPLOT3DReader *New();
00095   vtkTypeMacro(vtkPLOT3DReader,vtkStructuredGridSource);
00096   void PrintSelf(ostream& os, vtkIndent indent);
00097 
00099 
00100   void SetFileName(const char* name) { this->SetXYZFileName(name); }
00101   const char* GetFileName() { return this->GetXYZFileName(); }
00102   virtual void SetXYZFileName( const char* );
00103   vtkGetStringMacro(XYZFileName);
00105 
00107 
00108   vtkSetStringMacro(QFileName);
00109   vtkGetStringMacro(QFileName);
00111 
00113 
00114   vtkSetStringMacro(FunctionFileName);
00115   vtkGetStringMacro(FunctionFileName);
00117 
00119 
00125   int GetNumberOfOutputs();
00126   int GetNumberOfGrids() { return this->GetNumberOfOutputs(); }
00128 
00130   void SetOutput(int idx, vtkStructuredGrid *output);
00131   
00133 
00135   vtkSetMacro(BinaryFile, int);
00136   vtkGetMacro(BinaryFile, int);
00137   vtkBooleanMacro(BinaryFile, int);
00139 
00141 
00144   vtkSetMacro(MultiGrid, int);
00145   vtkGetMacro(MultiGrid, int);
00146   vtkBooleanMacro(MultiGrid, int);
00148 
00150 
00153   vtkSetMacro(HasByteCount, int);
00154   vtkGetMacro(HasByteCount, int);
00155   vtkBooleanMacro(HasByteCount, int);
00157 
00159 
00162   vtkSetMacro(IBlanking, int);
00163   vtkGetMacro(IBlanking, int);
00164   vtkBooleanMacro(IBlanking, int);
00166 
00168 
00169   vtkSetMacro(TwoDimensionalGeometry, int);
00170   vtkGetMacro(TwoDimensionalGeometry, int);
00171   vtkBooleanMacro(TwoDimensionalGeometry, int);
00173 
00175 
00179   vtkSetMacro(ForceRead, int);
00180   vtkGetMacro(ForceRead, int);
00181   vtkBooleanMacro(ForceRead, int);
00183 
00185 
00190   vtkSetMacro(DoNotReduceNumberOfOutputs, int);
00191   vtkGetMacro(DoNotReduceNumberOfOutputs, int);
00192   vtkBooleanMacro(DoNotReduceNumberOfOutputs, int);
00194 
00196 
00199   void SetByteOrderToBigEndian();
00200   void SetByteOrderToLittleEndian();
00201   vtkSetMacro(ByteOrder, int);
00202   vtkGetMacro(ByteOrder, int);
00203   const char *GetByteOrderAsString();
00205 
00207 
00208   vtkSetMacro(R,double);
00209   vtkGetMacro(R,double);
00211 
00213 
00214   vtkSetMacro(Gamma,double);
00215   vtkGetMacro(Gamma,double);
00217 
00219 
00220   vtkSetMacro(Uvinf,double);
00221   vtkGetMacro(Uvinf,double);
00223 
00225 
00226   vtkSetMacro(Vvinf,double);
00227   vtkGetMacro(Vvinf,double);
00229 
00231 
00232   vtkSetMacro(Wvinf,double);
00233   vtkGetMacro(Wvinf,double);
00235 
00237 
00239   void SetScalarFunctionNumber(int num);
00240   vtkGetMacro(ScalarFunctionNumber,int);
00242 
00244 
00246   void SetVectorFunctionNumber(int num);
00247   vtkGetMacro(VectorFunctionNumber,int);
00249 
00251 
00254   void AddFunction(int functionNumber);
00255   void RemoveFunction(int);
00256   void RemoveAllFunctions();
00258 
00261   virtual int CanReadBinaryFile(const char* fname);
00262 
00263 //BTX
00264   enum 
00265   {
00266     FILE_BIG_ENDIAN=0,
00267     FILE_LITTLE_ENDIAN=1
00268   };
00269 //ETX
00270 
00271 protected:
00272   vtkPLOT3DReader();
00273   ~vtkPLOT3DReader();
00274 
00275   void ExecuteInformation();
00276   void Execute();
00277 
00278   int CheckFile(FILE*& fp, const char* fname);
00279   int CheckGeometryFile(FILE*& xyzFp);
00280   int CheckSolutionFile(FILE*& qFp);
00281   int CheckFunctionFile(FILE*& fFp);
00282 
00283   void SkipByteCount (FILE* fp);
00284   int ReadIntBlock  (FILE* fp, int n, int*   block);
00285   int ReadFloatBlock(FILE* fp, int n, float* block);
00286 
00287   int GetNumberOfOutputsInternal(FILE* xyzFp, int verify=1);
00288 
00289   int ReadGeometryHeader(FILE* fp);
00290   int ReadQHeader(FILE* fp);
00291   int ReadFunctionHeader(FILE *fp, vtkIdList*& counts);
00292 
00293   void CalculateFileSize(FILE* fp);
00294   long EstimateSize(int ni, int nj, int nk);
00295 
00296   void AssignAttribute(int fNumber, vtkStructuredGrid* output,
00297                        int attributeType);
00298   void MapFunction(int fNumber, vtkStructuredGrid* output);
00299   void ComputeTemperature(vtkStructuredGrid* output);
00300   void ComputePressure(vtkStructuredGrid* output);
00301   void ComputeEnthalpy(vtkStructuredGrid* output);
00302   void ComputeKineticEnergy(vtkStructuredGrid* output);
00303   void ComputeVelocityMagnitude(vtkStructuredGrid* output);
00304   void ComputeEntropy(vtkStructuredGrid* output);
00305   void ComputeSwirl(vtkStructuredGrid* output);
00306   void ComputeVelocity(vtkStructuredGrid* output);
00307   void ComputeVorticity(vtkStructuredGrid* output);
00308   void ComputePressureGradient(vtkStructuredGrid* output);
00309 
00310   // Delete references to any existing vtkPoints and
00311   // I-blank arrays. The next Update() will (re)read
00312   // the XYZ file.
00313   void ClearGeometryCache();
00314 
00315   //plot3d FileNames
00316   char *XYZFileName;
00317   char *QFileName;
00318   char *FunctionFileName;
00319 
00320   int BinaryFile;
00321   int HasByteCount;
00322   int TwoDimensionalGeometry;
00323   int MultiGrid;
00324   int ForceRead;
00325   int ByteOrder;
00326   int IBlanking;
00327   int DoNotReduceNumberOfOutputs;
00328 
00329   long FileSize;
00330 
00331   //parameters used in computing derived functions
00332   double R; 
00333   double Gamma;
00334   double Uvinf;
00335   double Vvinf;
00336   double Wvinf;
00337 
00338   //functions to read that are not scalars or vectors
00339   vtkIntArray *FunctionList;
00340 
00341   int ScalarFunctionNumber;
00342   int VectorFunctionNumber;
00343 
00344   // Cache of geometry
00345   vtkFloatArray** PointCache;
00346   vtkUnsignedCharArray** IBlankCache;
00347 
00348   void ReadIntBlockV(char** buf, int n, int* block);
00349   void SkipByteCountV(char** buf);
00350 
00351   
00352 private:
00353   vtkPLOT3DReader(const vtkPLOT3DReader&);  // Not implemented.
00354   void operator=(const vtkPLOT3DReader&);  // Not implemented.
00355 };
00356 
00357 #endif
00358 
00359