VTK
vtkGenericEnSightReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGenericEnSightReader.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 =========================================================================*/
23 #ifndef vtkGenericEnSightReader_h
24 #define vtkGenericEnSightReader_h
25 
26 #include "vtkIOEnSightModule.h" // For export macro
28 
29 class vtkCallbackCommand;
33 
34 class TranslationTableType;
35 
36 // Cell/Point Ids store mode:
37 // Sparse Mode is supposed to be for a large number of distributed processes (Unstructured)
38 // Non Sparse Mode is supposed to be for a small number of distributed processes (Unstructured)
39 // Implicit Mode is for Structured Data
41 {
46 };
47 
48 class VTKIOENSIGHT_EXPORT vtkGenericEnSightReader : public vtkMultiBlockDataSetAlgorithm
49 {
50 public:
51  static vtkGenericEnSightReader *New();
53  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
54 
56 
59  void SetCaseFileName(const char* fileName);
60  vtkGetStringMacro(CaseFileName);
62 
64 
67  vtkSetStringMacro(FilePath);
68  vtkGetStringMacro(FilePath);
70 
72 
75  vtkGetMacro(EnSightVersion, int);
77 
79 
82  vtkGetMacro(NumberOfVariables, int);
83  vtkGetMacro(NumberOfComplexVariables, int);
85 
87 
90  int GetNumberOfVariables(int type); // returns -1 if unknown type specified
91  vtkGetMacro(NumberOfScalarsPerNode, int);
92  vtkGetMacro(NumberOfVectorsPerNode, int);
93  vtkGetMacro(NumberOfTensorsSymmPerNode, int);
94  vtkGetMacro(NumberOfScalarsPerElement, int);
95  vtkGetMacro(NumberOfVectorsPerElement, int);
96  vtkGetMacro(NumberOfTensorsSymmPerElement, int);
97  vtkGetMacro(NumberOfScalarsPerMeasuredNode, int);
98  vtkGetMacro(NumberOfVectorsPerMeasuredNode, int);
99  vtkGetMacro(NumberOfComplexScalarsPerNode, int);
100  vtkGetMacro(NumberOfComplexVectorsPerNode, int);
101  vtkGetMacro(NumberOfComplexScalarsPerElement, int);
102  vtkGetMacro(NumberOfComplexVectorsPerElement, int);
104 
108  const char* GetDescription(int n);
109 
113  const char* GetComplexDescription(int n);
114 
125  const char* GetDescription(int n, int type);
126 
128 
131  int GetVariableType(int n);
132  int GetComplexVariableType(int n);
134 
136 
139  virtual void SetTimeValue(float value);
140  vtkGetMacro(TimeValue, float);
142 
144 
147  vtkGetMacro(MinimumTimeValue, float);
148  vtkGetMacro(MaximumTimeValue, float);
150 
152 
155  vtkGetObjectMacro(TimeSets, vtkDataArrayCollection);
157 
164  int DetermineEnSightVersion(int quiet=0);
165 
167 
170  vtkBooleanMacro(ReadAllVariables, int);
171  vtkSetMacro(ReadAllVariables, int);
172  vtkGetMacro(ReadAllVariables, int);
174 
176 
180  vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
181  vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
183 
185 
188  int GetNumberOfPointArrays();
189  int GetNumberOfCellArrays();
191 
193 
197  const char* GetPointArrayName(int index);
198  const char* GetCellArrayName(int index);
200 
202 
206  int GetPointArrayStatus(const char* name);
207  int GetCellArrayStatus(const char* name);
208  void SetPointArrayStatus(const char* name, int status);
209  void SetCellArrayStatus(const char* name, int status);
211 
213  {
214  ENSIGHT_6 = 0,
215  ENSIGHT_6_BINARY = 1,
216  ENSIGHT_GOLD = 2,
217  ENSIGHT_GOLD_BINARY = 3,
218  ENSIGHT_MASTER_SERVER = 4
219  };
220 
222 
228  void SetByteOrderToBigEndian();
229  void SetByteOrderToLittleEndian();
230  vtkSetMacro(ByteOrder, int);
231  vtkGetMacro(ByteOrder, int);
232  const char *GetByteOrderAsString();
234 
235  enum
236  {
237  FILE_BIG_ENDIAN=0,
238  FILE_LITTLE_ENDIAN=1,
239  FILE_UNKNOWN_ENDIAN=2
240  };
241 
243 
247  vtkGetStringMacro(GeometryFileName);
249 
251 
263  vtkSetMacro(ParticleCoordinatesByIndex, int);
264  vtkGetMacro(ParticleCoordinatesByIndex, int);
265  vtkBooleanMacro(ParticleCoordinatesByIndex, int);
267 
272  static int CanReadFile(const char *casefilename);
273 
274 //THIB
275 vtkGenericEnSightReader* GetReader() { return this->Reader; }
276 
277 
278 protected:
280  ~vtkGenericEnSightReader() VTK_OVERRIDE;
281 
282  int FillOutputPortInformation(int port, vtkInformation* info) VTK_OVERRIDE;
283  int RequestInformation(vtkInformation*,
285  vtkInformationVector*) VTK_OVERRIDE;
286  int RequestData(vtkInformation*,
287  vtkInformationVector**,
288  vtkInformationVector*) VTK_OVERRIDE;
289 
295  virtual void ClearForNewCaseFileName();
296 
301  int ReadLine(char result[256]);
302 
307  int ReadBinaryLine(char result[80]);
308 
309  // Internal function that skips blank lines and reads the 1st
310  // non-blank line it finds (up to 256 characters).
311  // Returns 0 is there was an error.
312  int ReadNextDataLine(char result[256]);
313 
315 
318  vtkSetStringMacro(GeometryFileName);
320 
322 
325  void AddVariableDescription(const char* description);
326  void AddComplexVariableDescription(const char* description);
328 
330 
333  void AddVariableType(int variableType);
334  void AddComplexVariableType(int variableType);
336 
338 
342  int ReplaceWildcards(char* fileName, int timeSet, int fileSet);
343  void ReplaceWildcardsHelper(char* fileName, int num);
345 
346  // Callback registered with the SelectionObserver.
347  static void SelectionModifiedCallback(vtkObject* caller, unsigned long eid,
348  void* clientdata, void* calldata);
349  void SelectionModified();
350 
351  // Utility to create argument for vtkDataArraySelection::SetArrays.
352  char** CreateStringArray(int numStrings);
353  void DestroyStringArray(int numStrings, char** strings);
354 
355  // Fill the vtkDataArraySelection objects with the current set of
356  // EnSight variables.
357  void SetDataArraySelectionSetsFromVariables();
358 
359  // Fill the vtkDataArraySelection objects with the current set of
360  // arrays in the internal EnSight reader.
361  void SetDataArraySelectionSetsFromReader();
362 
363  // Fill the internal EnSight reader's vtkDataArraySelection objects
364  // from those in this object.
365  void SetReaderDataArraySelectionSetsFromSelf();
366 
367  istream* IS;
368  FILE *IFile;
370 
371  char* CaseFileName;
372  char* GeometryFileName;
373  char* FilePath;
374 
375  // array of types (one entry per instance of variable type in case file)
376  int* VariableTypes;
377  int* ComplexVariableTypes;
378 
379  // pointers to lists of descriptions
380  char** VariableDescriptions;
381  char** ComplexVariableDescriptions;
382 
383  int NumberOfVariables;
384  int NumberOfComplexVariables;
385 
386  // number of file names / descriptions per type
387  int NumberOfScalarsPerNode;
388  int NumberOfVectorsPerNode;
389  int NumberOfTensorsSymmPerNode;
390  int NumberOfScalarsPerElement;
391  int NumberOfVectorsPerElement;
392  int NumberOfTensorsSymmPerElement;
393  int NumberOfScalarsPerMeasuredNode;
394  int NumberOfVectorsPerMeasuredNode;
395  int NumberOfComplexScalarsPerNode;
396  int NumberOfComplexVectorsPerNode;
397  int NumberOfComplexScalarsPerElement;
398  int NumberOfComplexVectorsPerElement;
399 
400  float TimeValue;
401  float MinimumTimeValue;
402  float MaximumTimeValue;
403 
404  // Flag for whether TimeValue has been set.
405  int TimeValueInitialized;
406 
408  virtual void SetTimeSets(vtkDataArrayCollection*);
409 
410  int ReadAllVariables;
411 
412  int ByteOrder;
413  int ParticleCoordinatesByIndex;
414 
415  // The EnSight file version being read. Valid after
416  // UpdateInformation. Value is -1 for unknown version.
417  int EnSightVersion;
418 
419  // The array selections. These map over the variables and complex
420  // variables to hide the details of EnSight behind VTK terminology.
421  vtkDataArraySelection* PointDataArraySelection;
422  vtkDataArraySelection* CellDataArraySelection;
423 
424  // The observer to modify this object when the array selections are
425  // modified.
426  vtkCallbackCommand* SelectionObserver;
427 
428  // Whether the SelectionModified callback should invoke Modified.
429  // This is used when we are copying to/from the internal reader.
430  int SelectionModifiedDoNotCallModified;
431 
432  // Insert a partId and return the 'realId' that should be used.
433  int InsertNewPartId(int partId);
434 
435  // Wrapper around an stl map
436  TranslationTableType *TranslationTable;
437 
438 private:
439  vtkGenericEnSightReader(const vtkGenericEnSightReader&) VTK_DELETE_FUNCTION;
440  void operator=(const vtkGenericEnSightReader&) VTK_DELETE_FUNCTION;
441 };
442 
443 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:53
Store vtkAlgorithm input/output information.
EnsightReaderCellIdMode
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
static vtkMultiBlockDataSetAlgorithm * New()
supports function callbacks
a simple class to control print indentation
Definition: vtkIndent.h:33
Store on/off settings for data arrays for a vtkSource.
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.
maintain an ordered list of IdList objects
maintain an ordered list of dataarray objects
Store zero or more vtkInformation instances.
class to read any type of EnSight files
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkGenericEnSightReader * GetReader()
#define IS