VTK
dox/IO/vtkMultiBlockPLOT3DReader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkMultiBlockPLOT3DReader.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 =========================================================================*/
00077 #ifndef __vtkMultiBlockPLOT3DReader_h
00078 #define __vtkMultiBlockPLOT3DReader_h
00079 
00080 #include "vtkMultiBlockDataSetAlgorithm.h"
00081 
00082 class vtkUnsignedCharArray;
00083 class vtkIntArray;
00084 class vtkFloatArray;
00085 class vtkStructuredGrid;
00086 //BTX
00087 struct vtkMultiBlockPLOT3DReaderInternals;
00088 //ETX
00089 class VTK_IO_EXPORT vtkMultiBlockPLOT3DReader : public vtkMultiBlockDataSetAlgorithm 
00090 {
00091 public:
00092   static vtkMultiBlockPLOT3DReader *New();
00093   vtkTypeMacro(vtkMultiBlockPLOT3DReader,vtkMultiBlockDataSetAlgorithm);
00094   void PrintSelf(ostream& os, vtkIndent indent);
00095 
00097 
00098   void SetFileName(const char* name) { this->SetXYZFileName(name); }
00099   const char* GetFileName() { return this->GetXYZFileName(); }
00100   virtual void SetXYZFileName( const char* );
00101   vtkGetStringMacro(XYZFileName);
00103 
00105 
00106   vtkSetStringMacro(QFileName);
00107   vtkGetStringMacro(QFileName);
00109 
00111 
00117   int GetNumberOfBlocks();
00118   int GetNumberOfGrids() { return this->GetNumberOfBlocks(); }
00120 
00122 
00124   vtkSetMacro(BinaryFile, int);
00125   vtkGetMacro(BinaryFile, int);
00126   vtkBooleanMacro(BinaryFile, int);
00128 
00130 
00133   vtkSetMacro(MultiGrid, int);
00134   vtkGetMacro(MultiGrid, int);
00135   vtkBooleanMacro(MultiGrid, int);
00137 
00139 
00142   vtkSetMacro(HasByteCount, int);
00143   vtkGetMacro(HasByteCount, int);
00144   vtkBooleanMacro(HasByteCount, int);
00146 
00148 
00151   vtkSetMacro(IBlanking, int);
00152   vtkGetMacro(IBlanking, int);
00153   vtkBooleanMacro(IBlanking, int);
00155 
00157 
00158   vtkSetMacro(TwoDimensionalGeometry, int);
00159   vtkGetMacro(TwoDimensionalGeometry, int);
00160   vtkBooleanMacro(TwoDimensionalGeometry, int);
00162 
00164 
00168   vtkSetMacro(ForceRead, int);
00169   vtkGetMacro(ForceRead, int);
00170   vtkBooleanMacro(ForceRead, int);
00172 
00174 
00177   void SetByteOrderToBigEndian();
00178   void SetByteOrderToLittleEndian();
00179   vtkSetMacro(ByteOrder, int);
00180   vtkGetMacro(ByteOrder, int);
00181   const char *GetByteOrderAsString();
00183 
00185 
00186   vtkSetMacro(R,double);
00187   vtkGetMacro(R,double);
00189 
00191 
00192   vtkSetMacro(Gamma,double);
00193   vtkGetMacro(Gamma,double);
00195 
00197 
00198   vtkSetMacro(Uvinf,double);
00199   vtkGetMacro(Uvinf,double);
00201 
00203 
00204   vtkSetMacro(Vvinf,double);
00205   vtkGetMacro(Vvinf,double);
00207 
00209 
00210   vtkSetMacro(Wvinf,double);
00211   vtkGetMacro(Wvinf,double);
00213 
00215 
00217   void SetScalarFunctionNumber(int num);
00218   vtkGetMacro(ScalarFunctionNumber,int);
00220 
00222 
00224   void SetVectorFunctionNumber(int num);
00225   vtkGetMacro(VectorFunctionNumber,int);
00227 
00229 
00232   void AddFunction(int functionNumber);
00233   void RemoveFunction(int);
00234   void RemoveAllFunctions();
00236 
00239   virtual int CanReadBinaryFile(const char* fname);
00240 
00241 //BTX
00242   enum 
00243   {
00244     FILE_BIG_ENDIAN=0,
00245     FILE_LITTLE_ENDIAN=1
00246   };
00247 //ETX
00248 
00249 protected:
00250   vtkMultiBlockPLOT3DReader();
00251   ~vtkMultiBlockPLOT3DReader();
00252 
00253   int CheckFile(FILE*& fp, const char* fname);
00254   int CheckGeometryFile(FILE*& xyzFp);
00255   int CheckSolutionFile(FILE*& qFp);
00256 
00257   void SkipByteCount (FILE* fp);
00258   int ReadIntBlock  (FILE* fp, int n, int*   block);
00259   int ReadFloatBlock(FILE* fp, int n, float* block);
00260 
00261   int GetNumberOfBlocksInternal(FILE* xyzFp, int verify=1);
00262 
00263   int ReadGeometryHeader(FILE* fp);
00264   int ReadQHeader(FILE* fp);
00265 
00266   void CalculateFileSize(FILE* fp);
00267   long EstimateSize(int ni, int nj, int nk);
00268 
00269   void AssignAttribute(int fNumber, vtkStructuredGrid* output,
00270                        int attributeType);
00271   void MapFunction(int fNumber, vtkStructuredGrid* output);
00272   void ComputeTemperature(vtkStructuredGrid* output);
00273   void ComputePressure(vtkStructuredGrid* output);
00274   void ComputeEnthalpy(vtkStructuredGrid* output);
00275   void ComputeKineticEnergy(vtkStructuredGrid* output);
00276   void ComputeVelocityMagnitude(vtkStructuredGrid* output);
00277   void ComputeEntropy(vtkStructuredGrid* output);
00278   void ComputeSwirl(vtkStructuredGrid* output);
00279   void ComputeVelocity(vtkStructuredGrid* output);
00280   void ComputeVorticity(vtkStructuredGrid* output);
00281   void ComputePressureGradient(vtkStructuredGrid* output);
00282 
00283   // Delete references to any existing vtkPoints and
00284   // I-blank arrays. The next Update() will (re)read
00285   // the XYZ file.
00286   void ClearGeometryCache();
00287 
00288   //plot3d FileNames
00289   char *XYZFileName;
00290   char *QFileName;
00291 
00292   int BinaryFile;
00293   int HasByteCount;
00294   int TwoDimensionalGeometry;
00295   int MultiGrid;
00296   int ForceRead;
00297   int ByteOrder;
00298   int IBlanking;
00299 
00300   long FileSize;
00301 
00302   //parameters used in computing derived functions
00303   double R; 
00304   double Gamma;
00305   double Uvinf;
00306   double Vvinf;
00307   double Wvinf;
00308 
00309   //functions to read that are not scalars or vectors
00310   vtkIntArray *FunctionList;
00311 
00312   int ScalarFunctionNumber;
00313   int VectorFunctionNumber;
00314 
00315   // Cache of geometry
00316   vtkFloatArray** PointCache;
00317   vtkUnsignedCharArray** IBlankCache;
00318 
00319   // First pass at automatically detecting configuration
00320   int GenerateDefaultConfiguration();
00321   int VerifySettings(char* buf, int bufSize);
00322   
00323   void ReadIntBlockV(char** buf, int n, int* block);
00324   void SkipByteCountV(char** buf);
00325 
00326   virtual int FillOutputPortInformation(int port, vtkInformation* info);
00327 
00328   virtual int RequestData(vtkInformation*, 
00329                           vtkInformationVector**, 
00330                           vtkInformationVector*);
00331   virtual int RequestInformation(vtkInformation*, 
00332                                  vtkInformationVector**, 
00333                                  vtkInformationVector*);
00334   
00335 private:
00336 
00337   vtkMultiBlockPLOT3DReaderInternals* Internal;
00338 
00339   vtkMultiBlockPLOT3DReader(const vtkMultiBlockPLOT3DReader&);  // Not implemented.
00340   void operator=(const vtkMultiBlockPLOT3DReader&);  // Not implemented.
00341 };
00342 
00343 #endif
00344 
00345