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 =========================================================================*/
92 #ifndef vtkMultiBlockPLOT3DReader_h
93 #define vtkMultiBlockPLOT3DReader_h
94 
95 #include <vector> // For holding function-names
96 #include "vtkIOParallelModule.h" // For export macro
98 
99 class vtkDataArray;
101 class vtkIntArray;
102 class vtkStructuredGrid;
106 
107 class VTKIOPARALLEL_EXPORT vtkMultiBlockPLOT3DReader : public vtkMultiBlockDataSetAlgorithm
108 {
109 public:
110  static vtkMultiBlockPLOT3DReader *New();
112  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
113 
115 
118  void SetFileName(const char* name) { this->SetXYZFileName(name); }
119  const char* GetFileName() { return this->GetXYZFileName(); }
120  virtual void SetXYZFileName( const char* );
121  vtkGetStringMacro(XYZFileName);
123 
125 
128  vtkSetStringMacro(QFileName);
129  vtkGetStringMacro(QFileName);
131 
133 
136  vtkSetStringMacro(FunctionFileName);
137  vtkGetStringMacro(FunctionFileName);
139 
141 
151  vtkSetMacro(AutoDetectFormat, int);
152  vtkGetMacro(AutoDetectFormat, int);
153  vtkBooleanMacro(AutoDetectFormat, int);
155 
157 
161  vtkSetMacro(BinaryFile, int);
162  vtkGetMacro(BinaryFile, int);
163  vtkBooleanMacro(BinaryFile, int);
165 
167 
173  vtkSetMacro(MultiGrid, int);
174  vtkGetMacro(MultiGrid, int);
175  vtkBooleanMacro(MultiGrid, int);
177 
179 
184  vtkSetMacro(HasByteCount, int);
185  vtkGetMacro(HasByteCount, int);
186  vtkBooleanMacro(HasByteCount, int);
188 
190 
195  vtkSetMacro(IBlanking, int);
196  vtkGetMacro(IBlanking, int);
197  vtkBooleanMacro(IBlanking, int);
199 
201 
205  vtkSetMacro(TwoDimensionalGeometry, int);
206  vtkGetMacro(TwoDimensionalGeometry, int);
207  vtkBooleanMacro(TwoDimensionalGeometry, int);
209 
211 
216  vtkSetMacro(DoublePrecision, int);
217  vtkGetMacro(DoublePrecision, int);
218  vtkBooleanMacro(DoublePrecision, int);
220 
222 
228  vtkSetMacro(ForceRead, int);
229  vtkGetMacro(ForceRead, int);
230  vtkBooleanMacro(ForceRead, int);
232 
234 
240  void SetByteOrderToBigEndian();
241  void SetByteOrderToLittleEndian();
242  vtkSetMacro(ByteOrder, int);
243  vtkGetMacro(ByteOrder, int);
244  const char *GetByteOrderAsString();
246 
248 
251  vtkSetMacro(R,double);
252  vtkGetMacro(R,double);
254 
256 
259  vtkSetMacro(Gamma,double);
260  vtkGetMacro(Gamma,double);
262 
264 
268  void SetScalarFunctionNumber(int num);
269  vtkGetMacro(ScalarFunctionNumber,int);
271 
273 
277  void SetVectorFunctionNumber(int num);
278  vtkGetMacro(VectorFunctionNumber,int);
280 
282 
287  void AddFunction(int functionNumber);
288  void RemoveFunction(int);
289  void RemoveAllFunctions();
291 
296  virtual int CanReadBinaryFile(const char* fname);
297 
299 
303  void SetController(vtkMultiProcessController *c);
304  vtkGetObjectMacro(Controller, vtkMultiProcessController);
306 
307  void AddFunctionName(const std::string &name) {FunctionNames.push_back(name);}
308 
309  enum
310  {
311  FILE_BIG_ENDIAN=0,
312  FILE_LITTLE_ENDIAN=1
313  };
314 
315 protected:
317  ~vtkMultiBlockPLOT3DReader() VTK_OVERRIDE;
318 
319  vtkDataArray* CreateFloatArray();
320 
321  int CheckFile(FILE*& fp, const char* fname);
322  int CheckGeometryFile(FILE*& xyzFp);
323  int CheckSolutionFile(FILE*& qFp);
324  int CheckFunctionFile(FILE*& fFp);
325 
326  int GetByteCountSize();
327  int SkipByteCount (FILE* fp);
328  int ReadIntBlock (FILE* fp, int n, int* block);
329 
330  vtkIdType ReadValues(
331  FILE* fp,
332  int n,
333  vtkDataArray* scalar);
334  virtual int ReadIntScalar(
335  void* vfp,
336  int extent[6], int wextent[6],
337  vtkDataArray* scalar, vtkTypeUInt64 offset,
338  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
339  virtual int ReadScalar(
340  void* vfp,
341  int extent[6], int wextent[6],
342  vtkDataArray* scalar, vtkTypeUInt64 offset,
343  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
344  virtual int ReadVector(
345  void* vfp,
346  int extent[6], int wextent[6],
347  int numDims, vtkDataArray* vector, vtkTypeUInt64 offset,
348  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
349  virtual int OpenFileForDataRead(void*& fp, const char* fname);
350  virtual void CloseFile(void* fp);
351 
352  int GetNumberOfBlocksInternal(FILE* xyzFp, int allocate);
353 
354  int ReadGeometryHeader(FILE* fp);
355  int ReadQHeader(FILE* fp, bool checkGrid, int& nq, int& nqc, int& overflow);
356  int ReadFunctionHeader(FILE* fp, int* nFunctions);
357 
358  void CalculateFileSize(FILE* fp);
359 
360  int AutoDetectionCheck(FILE* fp);
361 
362  void AssignAttribute(int fNumber, vtkStructuredGrid* output,
363  int attributeType);
364  void MapFunction(int fNumber, vtkStructuredGrid* output);
365  void ComputeTemperature(vtkStructuredGrid* output);
366  void ComputePressure(vtkStructuredGrid* output);
367  void ComputeEnthalpy(vtkStructuredGrid* output);
368  void ComputeKineticEnergy(vtkStructuredGrid* output);
369  void ComputeVelocityMagnitude(vtkStructuredGrid* output);
370  void ComputeEntropy(vtkStructuredGrid* output);
371  void ComputeSwirl(vtkStructuredGrid* output);
372  void ComputeVelocity(vtkStructuredGrid* output);
373  void ComputeVorticity(vtkStructuredGrid* output);
374  void ComputePressureGradient(vtkStructuredGrid* output);
375  void ComputePressureCoefficient(vtkStructuredGrid* output);
376  void ComputeMachNumber(vtkStructuredGrid* output);
377  void ComputeSoundSpeed(vtkStructuredGrid* output);
378  void ComputeVorticityMagnitude(vtkStructuredGrid* output);
379  void ComputeStrainRate(vtkStructuredGrid* output);
380 
381  // Returns a vtkFloatArray or a vtkDoubleArray depending
382  // on DoublePrecision setting
383  vtkDataArray* NewFloatArray();
384 
385  // Delete references to any existing vtkPoints and
386  // I-blank arrays. The next Update() will (re)read
387  // the XYZ file.
388  void ClearGeometryCache();
389 
390  double GetGamma(vtkIdType idx, vtkDataArray* gamma);
391 
392  //plot3d FileNames
393  char *XYZFileName;
394  char *QFileName;
395  char *FunctionFileName;
396 
397  int BinaryFile;
398  int HasByteCount;
399  int TwoDimensionalGeometry;
400  int MultiGrid;
401  int ForceRead;
402  int ByteOrder;
403  int IBlanking;
404  int DoublePrecision;
405  int AutoDetectFormat;
406 
407  int ExecutedGhostLevels;
408 
409  size_t FileSize;
410 
411  //parameters used in computing derived functions
412  double R;
413  double Gamma;
414  double GammaInf;
415  double Uvinf;
416  double Vvinf;
417  double Wvinf;
418 
419  //named functions from meta data
420  std::vector<std::string> FunctionNames;
421 
422  //functions to read that are not scalars or vectors
423  vtkIntArray *FunctionList;
424 
425  int ScalarFunctionNumber;
426  int VectorFunctionNumber;
427 
428  int FillOutputPortInformation(int port, vtkInformation* info) VTK_OVERRIDE;
429 
430  int RequestData(vtkInformation*,
432  vtkInformationVector*) VTK_OVERRIDE;
433  int RequestInformation(vtkInformation*,
434  vtkInformationVector**,
435  vtkInformationVector*) VTK_OVERRIDE;
436 
438 
440 
441 private:
442  vtkMultiBlockPLOT3DReader(const vtkMultiBlockPLOT3DReader&) VTK_DELETE_FUNCTION;
443  void operator=(const vtkMultiBlockPLOT3DReader&) VTK_DELETE_FUNCTION;
444 };
445 
446 #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:45
a simple class to control print indentation
Definition: vtkIndent.h:39
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
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.