VTK
vtkMultiBlockPLOT3DReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMultiBlockPLOT3DReader.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
86 #ifndef vtkMultiBlockPLOT3DReader_h
87 #define vtkMultiBlockPLOT3DReader_h
88 
89 #include <vector> // For holding function-names
90 #include "vtkIOParallelModule.h" // For export macro
92 
93 class vtkDataArray;
95 class vtkIntArray;
96 class vtkStructuredGrid;
100 
101 class VTKIOPARALLEL_EXPORT vtkMultiBlockPLOT3DReader : public vtkMultiBlockDataSetAlgorithm
102 {
103 public:
104  static vtkMultiBlockPLOT3DReader *New();
106  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
107 
109 
112  void SetFileName(const char* name) { this->SetXYZFileName(name); }
113  const char* GetFileName() { return this->GetXYZFileName(); }
114  virtual void SetXYZFileName( const char* );
115  vtkGetStringMacro(XYZFileName);
117 
119 
122  vtkSetStringMacro(QFileName);
123  vtkGetStringMacro(QFileName);
125 
127 
130  vtkSetStringMacro(FunctionFileName);
131  vtkGetStringMacro(FunctionFileName);
133 
135 
145  vtkSetMacro(AutoDetectFormat, int);
146  vtkGetMacro(AutoDetectFormat, int);
147  vtkBooleanMacro(AutoDetectFormat, int);
149 
151 
155  vtkSetMacro(BinaryFile, int);
156  vtkGetMacro(BinaryFile, int);
157  vtkBooleanMacro(BinaryFile, int);
159 
161 
167  vtkSetMacro(MultiGrid, int);
168  vtkGetMacro(MultiGrid, int);
169  vtkBooleanMacro(MultiGrid, int);
171 
173 
178  vtkSetMacro(HasByteCount, int);
179  vtkGetMacro(HasByteCount, int);
180  vtkBooleanMacro(HasByteCount, int);
182 
184 
189  vtkSetMacro(IBlanking, int);
190  vtkGetMacro(IBlanking, int);
191  vtkBooleanMacro(IBlanking, int);
193 
195 
199  vtkSetMacro(TwoDimensionalGeometry, int);
200  vtkGetMacro(TwoDimensionalGeometry, int);
201  vtkBooleanMacro(TwoDimensionalGeometry, int);
203 
205 
210  vtkSetMacro(DoublePrecision, int);
211  vtkGetMacro(DoublePrecision, int);
212  vtkBooleanMacro(DoublePrecision, int);
214 
216 
222  vtkSetMacro(ForceRead, int);
223  vtkGetMacro(ForceRead, int);
224  vtkBooleanMacro(ForceRead, int);
226 
228 
234  void SetByteOrderToBigEndian();
235  void SetByteOrderToLittleEndian();
236  vtkSetMacro(ByteOrder, int);
237  vtkGetMacro(ByteOrder, int);
238  const char *GetByteOrderAsString();
240 
242 
245  vtkSetMacro(R,double);
246  vtkGetMacro(R,double);
248 
250 
253  vtkSetMacro(Gamma,double);
254  vtkGetMacro(Gamma,double);
256 
258 
262  void SetScalarFunctionNumber(int num);
263  vtkGetMacro(ScalarFunctionNumber,int);
265 
267 
271  void SetVectorFunctionNumber(int num);
272  vtkGetMacro(VectorFunctionNumber,int);
274 
276 
281  void AddFunction(int functionNumber);
282  void RemoveFunction(int);
283  void RemoveAllFunctions();
285 
290  virtual int CanReadBinaryFile(const char* fname);
291 
293 
297  void SetController(vtkMultiProcessController *c);
298  vtkGetObjectMacro(Controller, vtkMultiProcessController);
300 
301  void AddFunctionName(const std::string &name) {FunctionNames.push_back(name);}
302 
303  enum
304  {
305  FILE_BIG_ENDIAN=0,
306  FILE_LITTLE_ENDIAN=1
307  };
308 
309 protected:
311  ~vtkMultiBlockPLOT3DReader() VTK_OVERRIDE;
312 
313  vtkDataArray* CreateFloatArray();
314 
315  int CheckFile(FILE*& fp, const char* fname);
316  int CheckGeometryFile(FILE*& xyzFp);
317  int CheckSolutionFile(FILE*& qFp);
318  int CheckFunctionFile(FILE*& fFp);
319 
320  int GetByteCountSize();
321  int SkipByteCount (FILE* fp);
322  int ReadIntBlock (FILE* fp, int n, int* block);
323 
324  vtkIdType ReadValues(
325  FILE* fp,
326  int n,
327  vtkDataArray* scalar);
328  virtual int ReadIntScalar(
329  void* vfp,
330  int extent[6], int wextent[6],
331  vtkDataArray* scalar, vtkTypeUInt64 offset,
332  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
333  virtual int ReadScalar(
334  void* vfp,
335  int extent[6], int wextent[6],
336  vtkDataArray* scalar, vtkTypeUInt64 offset,
337  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
338  virtual int ReadVector(
339  void* vfp,
340  int extent[6], int wextent[6],
341  int numDims, vtkDataArray* vector, vtkTypeUInt64 offset,
342  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
343  virtual int OpenFileForDataRead(void*& fp, const char* fname);
344  virtual void CloseFile(void* fp);
345 
346  int GetNumberOfBlocksInternal(FILE* xyzFp, int allocate);
347 
348  int ReadGeometryHeader(FILE* fp);
349  int ReadQHeader(FILE* fp, bool checkGrid, int& nq, int& nqc, int& overflow);
350  int ReadFunctionHeader(FILE* fp, int* nFunctions);
351 
352  void CalculateFileSize(FILE* fp);
353 
354  int AutoDetectionCheck(FILE* fp);
355 
356  void AssignAttribute(int fNumber, vtkStructuredGrid* output,
357  int attributeType);
358  void MapFunction(int fNumber, vtkStructuredGrid* output);
359  void ComputeTemperature(vtkStructuredGrid* output);
360  void ComputePressure(vtkStructuredGrid* output);
361  void ComputeEnthalpy(vtkStructuredGrid* output);
362  void ComputeKineticEnergy(vtkStructuredGrid* output);
363  void ComputeVelocityMagnitude(vtkStructuredGrid* output);
364  void ComputeEntropy(vtkStructuredGrid* output);
365  void ComputeSwirl(vtkStructuredGrid* output);
366  void ComputeVelocity(vtkStructuredGrid* output);
367  void ComputeVorticity(vtkStructuredGrid* output);
368  void ComputePressureGradient(vtkStructuredGrid* output);
369  void ComputePressureCoefficient(vtkStructuredGrid* output);
370  void ComputeMachNumber(vtkStructuredGrid* output);
371  void ComputeSoundSpeed(vtkStructuredGrid* output);
372  void ComputeVorticityMagnitude(vtkStructuredGrid* output);
373  void ComputeStrainRate(vtkStructuredGrid* output);
374 
375  // Returns a vtkFloatArray or a vtkDoubleArray depending
376  // on DoublePrecision setting
377  vtkDataArray* NewFloatArray();
378 
379  // Delete references to any existing vtkPoints and
380  // I-blank arrays. The next Update() will (re)read
381  // the XYZ file.
382  void ClearGeometryCache();
383 
384  double GetGamma(vtkIdType idx, vtkDataArray* gamma);
385 
386  //plot3d FileNames
387  char *XYZFileName;
388  char *QFileName;
389  char *FunctionFileName;
390 
391  int BinaryFile;
392  int HasByteCount;
393  int TwoDimensionalGeometry;
394  int MultiGrid;
395  int ForceRead;
396  int ByteOrder;
397  int IBlanking;
398  int DoublePrecision;
399  int AutoDetectFormat;
400 
401  int ExecutedGhostLevels;
402 
403  size_t FileSize;
404 
405  //parameters used in computing derived functions
406  double R;
407  double Gamma;
408  double GammaInf;
409  double Uvinf;
410  double Vvinf;
411  double Wvinf;
412 
413  //named functions from meta data
414  std::vector<std::string> FunctionNames;
415 
416  //functions to read that are not scalars or vectors
417  vtkIntArray *FunctionList;
418 
419  int ScalarFunctionNumber;
420  int VectorFunctionNumber;
421 
422  int FillOutputPortInformation(int port, vtkInformation* info) VTK_OVERRIDE;
423 
424  int RequestData(vtkInformation*,
426  vtkInformationVector*) VTK_OVERRIDE;
427  int RequestInformation(vtkInformation*,
429  vtkInformationVector*) VTK_OVERRIDE;
430 
432 
434 
435 private:
436  vtkMultiBlockPLOT3DReader(const vtkMultiBlockPLOT3DReader&) VTK_DELETE_FUNCTION;
437  void operator=(const vtkMultiBlockPLOT3DReader&) VTK_DELETE_FUNCTION;
438 };
439 
440 #endif
void AddFunctionName(const std::string &name)
void SetFileName(const char *name)
Set/Get the PLOT3D geometry filename.
Store vtkAlgorithm input/output information.
int vtkIdType
Definition: vtkType.h:345
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
static vtkMultiBlockDataSetAlgorithm * New()
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
a simple class to control print indentation
Definition: vtkIndent.h:33
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
dynamic, self-adjusting array of unsigned char
topologically regular array of data
Store zero or more vtkInformation instances.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
const char * GetFileName()
Set/Get the PLOT3D geometry filename.
Multiprocessing communication superclass.