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 =========================================================================*/
26 #ifndef vtkGenericEnSightReader_h
27 #define vtkGenericEnSightReader_h
28 
29 #include "vtkIOEnSightModule.h" // For export macro
31 
32 class vtkCallbackCommand;
36 
37 class TranslationTableType;
38 
39 // Cell/Point Ids store mode:
40 // Sparse Mode is supposed to be for a large number of distributed processes (Unstructured)
41 // Non Sparse Mode is supposed to be for a small number of distributed processes (Unstructured)
42 // Implicit Mode is for Structured Data
44 {
49 };
50 
51 class VTKIOENSIGHT_EXPORT vtkGenericEnSightReader : public vtkMultiBlockDataSetAlgorithm
52 {
53 public:
54  static vtkGenericEnSightReader *New();
56  void PrintSelf(ostream& os, vtkIndent indent);
57 
59 
62  void SetCaseFileName(const char* fileName);
63  vtkGetStringMacro(CaseFileName);
65 
67 
70  vtkSetStringMacro(FilePath);
71  vtkGetStringMacro(FilePath);
73 
75 
78  vtkGetMacro(EnSightVersion, int);
80 
82 
85  vtkGetMacro(NumberOfVariables, int);
86  vtkGetMacro(NumberOfComplexVariables, int);
88 
90 
93  int GetNumberOfVariables(int type); // returns -1 if unknown type specified
94  vtkGetMacro(NumberOfScalarsPerNode, int);
95  vtkGetMacro(NumberOfVectorsPerNode, int);
96  vtkGetMacro(NumberOfTensorsSymmPerNode, int);
97  vtkGetMacro(NumberOfScalarsPerElement, int);
98  vtkGetMacro(NumberOfVectorsPerElement, int);
99  vtkGetMacro(NumberOfTensorsSymmPerElement, int);
100  vtkGetMacro(NumberOfScalarsPerMeasuredNode, int);
101  vtkGetMacro(NumberOfVectorsPerMeasuredNode, int);
102  vtkGetMacro(NumberOfComplexScalarsPerNode, int);
103  vtkGetMacro(NumberOfComplexVectorsPerNode, int);
104  vtkGetMacro(NumberOfComplexScalarsPerElement, int);
105  vtkGetMacro(NumberOfComplexVectorsPerElement, int);
107 
111  const char* GetDescription(int n);
112 
116  const char* GetComplexDescription(int n);
117 
128  const char* GetDescription(int n, int type);
129 
131 
134  int GetVariableType(int n);
135  int GetComplexVariableType(int n);
137 
139 
142  virtual void SetTimeValue(float value);
143  vtkGetMacro(TimeValue, float);
145 
147 
150  vtkGetMacro(MinimumTimeValue, float);
151  vtkGetMacro(MaximumTimeValue, float);
153 
155 
158  vtkGetObjectMacro(TimeSets, vtkDataArrayCollection);
160 
167  int DetermineEnSightVersion(int quiet=0);
168 
170 
173  vtkBooleanMacro(ReadAllVariables, int);
174  vtkSetMacro(ReadAllVariables, int);
175  vtkGetMacro(ReadAllVariables, int);
177 
179 
183  vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
184  vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
186 
188 
191  int GetNumberOfPointArrays();
192  int GetNumberOfCellArrays();
194 
196 
200  const char* GetPointArrayName(int index);
201  const char* GetCellArrayName(int index);
203 
205 
209  int GetPointArrayStatus(const char* name);
210  int GetCellArrayStatus(const char* name);
211  void SetPointArrayStatus(const char* name, int status);
212  void SetCellArrayStatus(const char* name, int status);
214 
216  {
217  ENSIGHT_6 = 0,
218  ENSIGHT_6_BINARY = 1,
219  ENSIGHT_GOLD = 2,
220  ENSIGHT_GOLD_BINARY = 3,
221  ENSIGHT_MASTER_SERVER = 4
222  };
223 
225 
231  void SetByteOrderToBigEndian();
232  void SetByteOrderToLittleEndian();
233  vtkSetMacro(ByteOrder, int);
234  vtkGetMacro(ByteOrder, int);
235  const char *GetByteOrderAsString();
237 
238  enum
239  {
240  FILE_BIG_ENDIAN=0,
241  FILE_LITTLE_ENDIAN=1,
242  FILE_UNKNOWN_ENDIAN=2
243  };
244 
246 
250  vtkGetStringMacro(GeometryFileName);
252 
254 
266  vtkSetMacro(ParticleCoordinatesByIndex, int);
267  vtkGetMacro(ParticleCoordinatesByIndex, int);
268  vtkBooleanMacro(ParticleCoordinatesByIndex, int);
270 
275  static int CanReadFile(const char *casefilename);
276 
277 //THIB
278 vtkGenericEnSightReader* GetReader() { return this->Reader; }
279 
280 
281 protected:
284 
286  virtual int RequestInformation(vtkInformation*,
289  virtual int RequestData(vtkInformation*,
292 
298  virtual void ClearForNewCaseFileName();
299 
304  int ReadLine(char result[256]);
305 
310  int ReadBinaryLine(char result[80]);
311 
312  // Internal function that skips blank lines and reads the 1st
313  // non-blank line it finds (up to 256 characters).
314  // Returns 0 is there was an error.
315  int ReadNextDataLine(char result[256]);
316 
318 
321  vtkSetStringMacro(GeometryFileName);
323 
325 
328  void AddVariableDescription(const char* description);
329  void AddComplexVariableDescription(const char* description);
331 
333 
336  void AddVariableType(int variableType);
337  void AddComplexVariableType(int variableType);
339 
341 
345  int ReplaceWildcards(char* fileName, int timeSet, int fileSet);
346  void ReplaceWildcardsHelper(char* fileName, int num);
348 
349  // Callback registered with the SelectionObserver.
350  static void SelectionModifiedCallback(vtkObject* caller, unsigned long eid,
351  void* clientdata, void* calldata);
352  void SelectionModified();
353 
354  // Utility to create argument for vtkDataArraySelection::SetArrays.
355  char** CreateStringArray(int numStrings);
356  void DestroyStringArray(int numStrings, char** strings);
357 
358  // Fill the vtkDataArraySelection objects with the current set of
359  // EnSight variables.
360  void SetDataArraySelectionSetsFromVariables();
361 
362  // Fill the vtkDataArraySelection objects with the current set of
363  // arrays in the internal EnSight reader.
364  void SetDataArraySelectionSetsFromReader();
365 
366  // Fill the internal EnSight reader's vtkDataArraySelection objects
367  // from those in this object.
368  void SetReaderDataArraySelectionSetsFromSelf();
369 
370  istream* IS;
371  FILE *IFile;
373 
376  char* FilePath;
377 
378  // array of types (one entry per instance of variable type in case file)
381 
382  // pointers to lists of descriptions
385 
388 
389  // number of file names / descriptions per type
402 
403  float TimeValue;
406 
407  // Flag for whether TimeValue has been set.
409 
411  virtual void SetTimeSets(vtkDataArrayCollection*);
412 
414 
417 
418  // The EnSight file version being read. Valid after
419  // UpdateInformation. Value is -1 for unknown version.
421 
422  // The array selections. These map over the variables and complex
423  // variables to hide the details of EnSight behind VTK terminology.
426 
427  // The observer to modify this object when the array selections are
428  // modified.
430 
431  // Whether the SelectionModified callback should invoke Modified.
432  // This is used when we are copying to/from the internal reader.
434 
435  // Insert a partId and return the 'realId' that should be used.
436  int InsertNewPartId(int partId);
437 
438  // Wrapper around an stl map
439  TranslationTableType *TranslationTable;
440 
441 private:
442  vtkGenericEnSightReader(const vtkGenericEnSightReader&) VTK_DELETE_FUNCTION;
443  void operator=(const vtkGenericEnSightReader&) VTK_DELETE_FUNCTION;
444 };
445 
446 #endif
vtkDataArrayCollection * TimeSets
vtkCallbackCommand * SelectionObserver
abstract base class for most VTK objects
Definition: vtkObject.h:59
Store vtkAlgorithm input/output information.
EnsightReaderCellIdMode
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
int FillOutputPortInformation(int port, vtkInformation *info) override
Fill the output port information objects for this algorithm.
static vtkMultiBlockDataSetAlgorithm * New()
vtkDataArraySelection * PointDataArraySelection
supports function callbacks
a simple class to control print indentation
Definition: vtkIndent.h:39
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.
TranslationTableType * TranslationTable
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkGenericEnSightReader * Reader
maintain an unordered list of dataarray objects
maintain an unordered list of dataarray objects
Store zero or more vtkInformation instances.
vtkDataArraySelection * CellDataArraySelection
class to read any type of EnSight files
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkGenericEnSightReader * GetReader()
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.