VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkPLOT3DReader.h,v $ 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 __vtkPLOT3DReader_h 00078 #define __vtkPLOT3DReader_h 00079 00080 #include "vtkStructuredGridSource.h" 00081 #include "vtkIdList.h" // Needed for internal method 00082 00083 class vtkUnsignedCharArray; 00084 class vtkIntArray; 00085 class vtkFloatArray; 00086 class vtkStructuredGrid; 00087 00088 class VTK_IO_EXPORT vtkPLOT3DReader : public vtkStructuredGridSource 00089 { 00090 public: 00091 static vtkPLOT3DReader *New(); 00092 vtkTypeRevisionMacro(vtkPLOT3DReader,vtkStructuredGridSource); 00093 void PrintSelf(ostream& os, vtkIndent indent); 00094 00096 00097 void SetFileName(const char* name) { this->SetXYZFileName(name); } 00098 const char* GetFileName() { return this->GetXYZFileName(); } 00099 virtual void SetXYZFileName( const char* ); 00100 vtkGetStringMacro(XYZFileName); 00102 00104 00105 vtkSetStringMacro(QFileName); 00106 vtkGetStringMacro(QFileName); 00108 00110 00111 vtkSetStringMacro(FunctionFileName); 00112 vtkGetStringMacro(FunctionFileName); 00114 00116 00122 int GetNumberOfOutputs(); 00123 int GetNumberOfGrids() { return this->GetNumberOfOutputs(); } 00125 00127 void SetOutput(int idx, vtkStructuredGrid *output); 00128 00130 00132 vtkSetMacro(BinaryFile, int); 00133 vtkGetMacro(BinaryFile, int); 00134 vtkBooleanMacro(BinaryFile, int); 00136 00138 00141 vtkSetMacro(MultiGrid, int); 00142 vtkGetMacro(MultiGrid, int); 00143 vtkBooleanMacro(MultiGrid, int); 00145 00147 00150 vtkSetMacro(HasByteCount, int); 00151 vtkGetMacro(HasByteCount, int); 00152 vtkBooleanMacro(HasByteCount, int); 00154 00156 00159 vtkSetMacro(IBlanking, int); 00160 vtkGetMacro(IBlanking, int); 00161 vtkBooleanMacro(IBlanking, int); 00163 00165 00166 vtkSetMacro(TwoDimensionalGeometry, int); 00167 vtkGetMacro(TwoDimensionalGeometry, int); 00168 vtkBooleanMacro(TwoDimensionalGeometry, int); 00170 00172 00176 vtkSetMacro(ForceRead, int); 00177 vtkGetMacro(ForceRead, int); 00178 vtkBooleanMacro(ForceRead, int); 00180 00182 00187 vtkSetMacro(DoNotReduceNumberOfOutputs, int); 00188 vtkGetMacro(DoNotReduceNumberOfOutputs, int); 00189 vtkBooleanMacro(DoNotReduceNumberOfOutputs, int); 00191 00193 00196 void SetByteOrderToBigEndian(); 00197 void SetByteOrderToLittleEndian(); 00198 vtkSetMacro(ByteOrder, int); 00199 vtkGetMacro(ByteOrder, int); 00200 const char *GetByteOrderAsString(); 00202 00204 00205 vtkSetMacro(R,double); 00206 vtkGetMacro(R,double); 00208 00210 00211 vtkSetMacro(Gamma,double); 00212 vtkGetMacro(Gamma,double); 00214 00216 00217 vtkSetMacro(Uvinf,double); 00218 vtkGetMacro(Uvinf,double); 00220 00222 00223 vtkSetMacro(Vvinf,double); 00224 vtkGetMacro(Vvinf,double); 00226 00228 00229 vtkSetMacro(Wvinf,double); 00230 vtkGetMacro(Wvinf,double); 00232 00234 00236 void SetScalarFunctionNumber(int num); 00237 vtkGetMacro(ScalarFunctionNumber,int); 00239 00241 00243 void SetVectorFunctionNumber(int num); 00244 vtkGetMacro(VectorFunctionNumber,int); 00246 00248 00251 void AddFunction(int functionNumber); 00252 void RemoveFunction(int); 00253 void RemoveAllFunctions(); 00255 00258 virtual int CanReadBinaryFile(const char* fname); 00259 00260 //BTX 00261 enum 00262 { 00263 FILE_BIG_ENDIAN=0, 00264 FILE_LITTLE_ENDIAN=1 00265 }; 00266 //ETX 00267 00268 protected: 00269 vtkPLOT3DReader(); 00270 ~vtkPLOT3DReader(); 00271 00272 void ExecuteInformation(); 00273 void Execute(); 00274 00275 int CheckFile(FILE*& fp, const char* fname); 00276 int CheckGeometryFile(FILE*& xyzFp); 00277 int CheckSolutionFile(FILE*& qFp); 00278 int CheckFunctionFile(FILE*& fFp); 00279 00280 void SkipByteCount (FILE* fp); 00281 int ReadIntBlock (FILE* fp, int n, int* block); 00282 int ReadFloatBlock(FILE* fp, int n, float* block); 00283 00284 int GetNumberOfOutputsInternal(FILE* xyzFp, int verify=1); 00285 00286 int ReadGeometryHeader(FILE* fp); 00287 int ReadQHeader(FILE* fp); 00288 int ReadFunctionHeader(FILE *fp, vtkIdList*& counts); 00289 00290 void CalculateFileSize(FILE* fp); 00291 long EstimateSize(int ni, int nj, int nk); 00292 00293 void AssignAttribute(int fNumber, vtkStructuredGrid* output, 00294 int attributeType); 00295 void MapFunction(int fNumber, vtkStructuredGrid* output); 00296 void ComputeTemperature(vtkStructuredGrid* output); 00297 void ComputePressure(vtkStructuredGrid* output); 00298 void ComputeEnthalpy(vtkStructuredGrid* output); 00299 void ComputeKineticEnergy(vtkStructuredGrid* output); 00300 void ComputeVelocityMagnitude(vtkStructuredGrid* output); 00301 void ComputeEntropy(vtkStructuredGrid* output); 00302 void ComputeSwirl(vtkStructuredGrid* output); 00303 void ComputeVelocity(vtkStructuredGrid* output); 00304 void ComputeVorticity(vtkStructuredGrid* output); 00305 void ComputePressureGradient(vtkStructuredGrid* output); 00306 00307 // Delete references to any existing vtkPoints and 00308 // I-blank arrays. The next Update() will (re)read 00309 // the XYZ file. 00310 void ClearGeometryCache(); 00311 00312 //plot3d FileNames 00313 char *XYZFileName; 00314 char *QFileName; 00315 char *FunctionFileName; 00316 00317 int BinaryFile; 00318 int HasByteCount; 00319 int TwoDimensionalGeometry; 00320 int MultiGrid; 00321 int ForceRead; 00322 int ByteOrder; 00323 int IBlanking; 00324 int DoNotReduceNumberOfOutputs; 00325 00326 long FileSize; 00327 00328 //parameters used in computing derived functions 00329 double R; 00330 double Gamma; 00331 double Uvinf; 00332 double Vvinf; 00333 double Wvinf; 00334 00335 //functions to read that are not scalars or vectors 00336 vtkIntArray *FunctionList; 00337 00338 int ScalarFunctionNumber; 00339 int VectorFunctionNumber; 00340 00341 // Cache of geometry 00342 vtkFloatArray** PointCache; 00343 vtkUnsignedCharArray** IBlankCache; 00344 00345 void ReadIntBlockV(char** buf, int n, int* block); 00346 void SkipByteCountV(char** buf); 00347 00348 00349 private: 00350 vtkPLOT3DReader(const vtkPLOT3DReader&); // Not implemented. 00351 void operator=(const vtkPLOT3DReader&); // Not implemented. 00352 }; 00353 00354 #endif 00355 00356