VTK  9.2.6
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) override;
57 
59 
62  void SetCaseFileName(VTK_FILEPATH const char* fileName);
63  vtkGetFilePathMacro(CaseFileName);
65 
67 
70  vtkSetFilePathMacro(FilePath);
71  vtkGetFilePathMacro(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(NumberOfTensorsAsymPerNode, int);
97  vtkGetMacro(NumberOfTensorsSymmPerNode, int);
98  vtkGetMacro(NumberOfScalarsPerElement, int);
99  vtkGetMacro(NumberOfVectorsPerElement, int);
100  vtkGetMacro(NumberOfTensorsAsymPerElement, int);
101  vtkGetMacro(NumberOfTensorsSymmPerElement, int);
102  vtkGetMacro(NumberOfScalarsPerMeasuredNode, int);
103  vtkGetMacro(NumberOfVectorsPerMeasuredNode, int);
104  vtkGetMacro(NumberOfComplexScalarsPerNode, int);
105  vtkGetMacro(NumberOfComplexVectorsPerNode, int);
106  vtkGetMacro(NumberOfComplexScalarsPerElement, int);
107  vtkGetMacro(NumberOfComplexVectorsPerElement, int);
109 
113  const char* GetDescription(int n);
114 
118  const char* GetComplexDescription(int n);
119 
131  const char* GetDescription(int n, int type);
132 
134 
137  int GetVariableType(int n);
138  int GetComplexVariableType(int n);
140 
142 
145  virtual void SetTimeValue(float value);
146  vtkGetMacro(TimeValue, float);
148 
150 
153  vtkGetMacro(MinimumTimeValue, float);
154  vtkGetMacro(MaximumTimeValue, float);
156 
158 
161  vtkGetObjectMacro(TimeSets, vtkDataArrayCollection);
163 
170  int DetermineEnSightVersion(int quiet = 0);
171 
173 
176  vtkBooleanMacro(ReadAllVariables, vtkTypeBool);
177  vtkSetMacro(ReadAllVariables, vtkTypeBool);
178  vtkGetMacro(ReadAllVariables, vtkTypeBool);
180 
182 
186  vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
187  vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
189 
191 
194  int GetNumberOfPointArrays();
195  int GetNumberOfCellArrays();
197 
199 
203  const char* GetPointArrayName(int index);
204  const char* GetCellArrayName(int index);
206 
208 
212  int GetPointArrayStatus(const char* name);
213  int GetCellArrayStatus(const char* name);
214  void SetPointArrayStatus(const char* name, int status);
215  void SetCellArrayStatus(const char* name, int status);
217 
219  {
220  ENSIGHT_6 = 0,
221  ENSIGHT_6_BINARY = 1,
222  ENSIGHT_GOLD = 2,
223  ENSIGHT_GOLD_BINARY = 3,
224  ENSIGHT_MASTER_SERVER = 4
225  };
226 
228 
234  void SetByteOrderToBigEndian();
235  void SetByteOrderToLittleEndian();
236  vtkSetMacro(ByteOrder, int);
237  vtkGetMacro(ByteOrder, int);
238  const char* GetByteOrderAsString();
240 
241  enum
242  {
243  FILE_BIG_ENDIAN = 0,
244  FILE_LITTLE_ENDIAN = 1,
245  FILE_UNKNOWN_ENDIAN = 2
246  };
247 
249 
253  vtkGetFilePathMacro(GeometryFileName);
255 
257 
269  vtkSetMacro(ParticleCoordinatesByIndex, vtkTypeBool);
270  vtkGetMacro(ParticleCoordinatesByIndex, vtkTypeBool);
271  vtkBooleanMacro(ParticleCoordinatesByIndex, vtkTypeBool);
273 
278  static bool IsEnSightFile(VTK_FILEPATH const char* casefilename);
279 
283  virtual int CanReadFile(VTK_FILEPATH const char* casefilename);
284 
285  // THIB
286  vtkGenericEnSightReader* GetReader() { return this->Reader; }
287 
288 protected:
290  ~vtkGenericEnSightReader() override;
291 
295 
301  virtual void ClearForNewCaseFileName();
302 
307  int ReadLine(char result[256]);
308 
313  int ReadBinaryLine(char result[80]);
314 
318  bool SkipDataLine(char line[256]);
319 
320  // Internal function that skips blank lines and reads the 1st
321  // non-blank line it finds (up to 256 characters).
322  // Returns 0 is there was an error.
323  int ReadNextDataLine(char result[256]);
324 
326 
329  vtkSetFilePathMacro(GeometryFileName);
331 
333 
336  void AddVariableDescription(const char* description);
337  void AddComplexVariableDescription(const char* description);
339 
341 
344  void AddVariableType(int variableType);
345  void AddComplexVariableType(int variableType);
347 
352  int ReplaceWildcards(char* fileName, int timeSet, int fileSet);
353 
357  static void ReplaceWildcardsHelper(char* fileName, int num);
358 
359  // Callback registered with the SelectionObserver.
360  static void SelectionModifiedCallback(
361  vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
362  void SelectionModified();
363 
364  // Utility to create argument for vtkDataArraySelection::SetArrays.
365  char** CreateStringArray(int numStrings);
366  void DestroyStringArray(int numStrings, char** strings);
367 
368  // Fill the vtkDataArraySelection objects with the current set of
369  // EnSight variables.
370  void SetDataArraySelectionSetsFromVariables();
371 
372  // Fill the vtkDataArraySelection objects with the current set of
373  // arrays in the internal EnSight reader.
374  void SetDataArraySelectionSetsFromReader();
375 
376  // Fill the internal EnSight reader's vtkDataArraySelection objects
377  // from those in this object.
378  void SetReaderDataArraySelectionSetsFromSelf();
379 
380  istream* IS;
381  FILE* IFile;
383 
386  char* FilePath;
387 
388  // array of types (one entry per instance of variable type in case file)
391 
392  // pointers to lists of descriptions
395 
398 
399  // number of file names / descriptions per type
414 
415  float TimeValue;
418 
419  // Flag for whether TimeValue has been set.
421 
423  virtual void SetTimeSets(vtkDataArrayCollection*);
424 
426 
429 
430  // The EnSight file version being read. Valid after
431  // UpdateInformation. Value is -1 for unknown version.
433 
434  // The array selections. These map over the variables and complex
435  // variables to hide the details of EnSight behind VTK terminology.
438 
439  // The observer to modify this object when the array selections are
440  // modified.
442 
443  // Whether the SelectionModified callback should invoke Modified.
444  // This is used when we are copying to/from the internal reader.
446 
447  // Insert a partId and return the 'realId' that should be used.
448  int InsertNewPartId(int partId);
449 
450  // Wrapper around an stl map
451  TranslationTableType* TranslationTable;
452 
453 private:
455  void operator=(const vtkGenericEnSightReader&) = delete;
456 };
457 
458 #endif
vtkDataArrayCollection * TimeSets
vtkCallbackCommand * SelectionObserver
abstract base class for most VTK objects
Definition: vtkObject.h:62
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()
int vtkTypeBool
Definition: vtkABI.h:69
vtkDataArraySelection * PointDataArraySelection
supports function callbacks
a simple class to control print indentation
Definition: vtkIndent.h:39
Store on/off settings for data arrays, etc.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
TranslationTableType * TranslationTable
vtkGenericEnSightReader * Reader
#define VTK_FILEPATH
maintain an ordered list of IdList objects
maintain an ordered list of dataarray objects
Store zero or more vtkInformation instances.
vtkDataArraySelection * CellDataArraySelection
class to read any type of EnSight files
vtkGenericEnSightReader * GetReader()
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.