VTK
vtkPLOT3DReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPLOT3DReader.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 =========================================================================*/
80 #ifndef __vtkPLOT3DReader_h
81 #define __vtkPLOT3DReader_h
82 
84 #include "vtkIdList.h" // Needed for internal method
85 
87 class vtkIntArray;
88 class vtkFloatArray;
89 class vtkStructuredGrid;
90 
92 {
93 public:
94  static vtkPLOT3DReader *New();
96  void PrintSelf(ostream& os, vtkIndent indent);
97 
99 
100  void SetFileName(const char* name) { this->SetXYZFileName(name); }
101  const char* GetFileName() { return this->GetXYZFileName(); }
102  virtual void SetXYZFileName( const char* );
103  vtkGetStringMacro(XYZFileName);
105 
107 
108  vtkSetStringMacro(QFileName);
109  vtkGetStringMacro(QFileName);
111 
113 
114  vtkSetStringMacro(FunctionFileName);
115  vtkGetStringMacro(FunctionFileName);
117 
119 
125  int GetNumberOfOutputs();
126  int GetNumberOfGrids() { return this->GetNumberOfOutputs(); }
128 
130  void SetOutput(int idx, vtkStructuredGrid *output);
131 
133 
135  vtkSetMacro(BinaryFile, int);
136  vtkGetMacro(BinaryFile, int);
137  vtkBooleanMacro(BinaryFile, int);
139 
141 
144  vtkSetMacro(MultiGrid, int);
145  vtkGetMacro(MultiGrid, int);
146  vtkBooleanMacro(MultiGrid, int);
148 
150 
153  vtkSetMacro(HasByteCount, int);
154  vtkGetMacro(HasByteCount, int);
155  vtkBooleanMacro(HasByteCount, int);
157 
159 
162  vtkSetMacro(IBlanking, int);
163  vtkGetMacro(IBlanking, int);
164  vtkBooleanMacro(IBlanking, int);
166 
168 
169  vtkSetMacro(TwoDimensionalGeometry, int);
170  vtkGetMacro(TwoDimensionalGeometry, int);
171  vtkBooleanMacro(TwoDimensionalGeometry, int);
173 
175 
179  vtkSetMacro(ForceRead, int);
180  vtkGetMacro(ForceRead, int);
181  vtkBooleanMacro(ForceRead, int);
183 
185 
190  vtkSetMacro(DoNotReduceNumberOfOutputs, int);
191  vtkGetMacro(DoNotReduceNumberOfOutputs, int);
192  vtkBooleanMacro(DoNotReduceNumberOfOutputs, int);
194 
196 
199  void SetByteOrderToBigEndian();
200  void SetByteOrderToLittleEndian();
201  vtkSetMacro(ByteOrder, int);
202  vtkGetMacro(ByteOrder, int);
203  const char *GetByteOrderAsString();
205 
207 
208  vtkSetMacro(R,double);
209  vtkGetMacro(R,double);
211 
213 
214  vtkSetMacro(Gamma,double);
215  vtkGetMacro(Gamma,double);
217 
219 
220  vtkSetMacro(Uvinf,double);
221  vtkGetMacro(Uvinf,double);
223 
225 
226  vtkSetMacro(Vvinf,double);
227  vtkGetMacro(Vvinf,double);
229 
231 
232  vtkSetMacro(Wvinf,double);
233  vtkGetMacro(Wvinf,double);
235 
237 
239  void SetScalarFunctionNumber(int num);
240  vtkGetMacro(ScalarFunctionNumber,int);
242 
244 
246  void SetVectorFunctionNumber(int num);
247  vtkGetMacro(VectorFunctionNumber,int);
249 
251 
254  void AddFunction(int functionNumber);
255  void RemoveFunction(int);
256  void RemoveAllFunctions();
258 
261  virtual int CanReadBinaryFile(const char* fname);
262 
263 //BTX
264  enum
265  {
266  FILE_BIG_ENDIAN=0,
267  FILE_LITTLE_ENDIAN=1
268  };
269 //ETX
270 
271 protected:
272  vtkPLOT3DReader();
273  ~vtkPLOT3DReader();
274 
275  void ExecuteInformation();
276  void Execute();
277 
278  int CheckFile(FILE*& fp, const char* fname);
279  int CheckGeometryFile(FILE*& xyzFp);
280  int CheckSolutionFile(FILE*& qFp);
281  int CheckFunctionFile(FILE*& fFp);
282 
283  void SkipByteCount (FILE* fp);
284  int ReadIntBlock (FILE* fp, int n, int* block);
285  int ReadFloatBlock(FILE* fp, int n, float* block);
286 
287  int GetNumberOfOutputsInternal(FILE* xyzFp, int verify=1);
288 
289  int ReadGeometryHeader(FILE* fp);
290  int ReadQHeader(FILE* fp);
291  int ReadFunctionHeader(FILE *fp, vtkIdList*& counts);
292 
293  void CalculateFileSize(FILE* fp);
294  long EstimateSize(int ni, int nj, int nk);
295 
296  void AssignAttribute(int fNumber, vtkStructuredGrid* output,
297  int attributeType);
298  void MapFunction(int fNumber, vtkStructuredGrid* output);
299  void ComputeTemperature(vtkStructuredGrid* output);
300  void ComputePressure(vtkStructuredGrid* output);
301  void ComputeEnthalpy(vtkStructuredGrid* output);
302  void ComputeKineticEnergy(vtkStructuredGrid* output);
303  void ComputeVelocityMagnitude(vtkStructuredGrid* output);
304  void ComputeEntropy(vtkStructuredGrid* output);
305  void ComputeSwirl(vtkStructuredGrid* output);
306  void ComputeVelocity(vtkStructuredGrid* output);
307  void ComputeVorticity(vtkStructuredGrid* output);
308  void ComputePressureGradient(vtkStructuredGrid* output);
309 
310  // Delete references to any existing vtkPoints and
311  // I-blank arrays. The next Update() will (re)read
312  // the XYZ file.
313  void ClearGeometryCache();
314 
315  //plot3d FileNames
316  char *XYZFileName;
317  char *QFileName;
319 
328 
329  long FileSize;
330 
331  //parameters used in computing derived functions
332  double R;
333  double Gamma;
334  double Uvinf;
335  double Vvinf;
336  double Wvinf;
337 
338  //functions to read that are not scalars or vectors
340 
343 
344  // Cache of geometry
347 
348  void ReadIntBlockV(char** buf, int n, int* block);
349  void SkipByteCountV(char** buf);
350 
351 
352 private:
353  vtkPLOT3DReader(const vtkPLOT3DReader&); // Not implemented.
354  void operator=(const vtkPLOT3DReader&); // Not implemented.
355 };
356 
357 #endif
358 
359