VTK  9.3.1
vtkGenericEnSightReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
14 #ifndef vtkGenericEnSightReader_h
15 #define vtkGenericEnSightReader_h
16 
17 #include "vtkIOEnSightModule.h" // For export macro
19 
20 #include <string>
21 
22 VTK_ABI_NAMESPACE_BEGIN
23 class vtkCallbackCommand;
27 
28 class TranslationTableType;
29 
30 // Cell/Point Ids store mode:
31 // Sparse Mode is supposed to be for a large number of distributed processes (Unstructured)
32 // Non Sparse Mode is supposed to be for a small number of distributed processes (Unstructured)
33 // Implicit Mode is for Structured Data
35 {
40 };
41 
42 class VTKIOENSIGHT_EXPORT vtkGenericEnSightReader : public vtkMultiBlockDataSetAlgorithm
43 {
44 public:
45  static vtkGenericEnSightReader* New();
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
50 
53  void SetCaseFileName(VTK_FILEPATH const char* fileName);
54  vtkGetFilePathMacro(CaseFileName);
56 
58 
61  vtkSetFilePathMacro(FilePath);
62  vtkGetFilePathMacro(FilePath);
64 
66 
69  vtkGetMacro(EnSightVersion, int);
71 
73 
76  vtkGetMacro(NumberOfVariables, int);
77  vtkGetMacro(NumberOfComplexVariables, int);
79 
81 
84  int GetNumberOfVariables(int type); // returns -1 if unknown type specified
85  vtkGetMacro(NumberOfScalarsPerNode, int);
86  vtkGetMacro(NumberOfVectorsPerNode, int);
87  vtkGetMacro(NumberOfTensorsAsymPerNode, int);
88  vtkGetMacro(NumberOfTensorsSymmPerNode, int);
89  vtkGetMacro(NumberOfScalarsPerElement, int);
90  vtkGetMacro(NumberOfVectorsPerElement, int);
91  vtkGetMacro(NumberOfTensorsAsymPerElement, int);
92  vtkGetMacro(NumberOfTensorsSymmPerElement, int);
93  vtkGetMacro(NumberOfScalarsPerMeasuredNode, int);
94  vtkGetMacro(NumberOfVectorsPerMeasuredNode, int);
95  vtkGetMacro(NumberOfComplexScalarsPerNode, int);
96  vtkGetMacro(NumberOfComplexVectorsPerNode, int);
97  vtkGetMacro(NumberOfComplexScalarsPerElement, int);
98  vtkGetMacro(NumberOfComplexVectorsPerElement, int);
100 
104  const char* GetDescription(int n);
105 
109  const char* GetComplexDescription(int n);
110 
122  const char* GetDescription(int n, int type);
123 
125 
128  int GetVariableType(int n);
129  int GetComplexVariableType(int n);
131 
133 
136  virtual void SetTimeValue(double value);
137  vtkGetMacro(TimeValue, double);
139 
141 
144  vtkGetMacro(MinimumTimeValue, double);
145  vtkGetMacro(MaximumTimeValue, double);
147 
149 
152  vtkGetObjectMacro(TimeSets, vtkDataArrayCollection);
154 
161  int DetermineEnSightVersion(int quiet = 0);
162 
164 
167  vtkBooleanMacro(ReadAllVariables, vtkTypeBool);
168  vtkSetMacro(ReadAllVariables, vtkTypeBool);
169  vtkGetMacro(ReadAllVariables, vtkTypeBool);
171 
173 
177  vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
178  vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
180 
182 
185  int GetNumberOfPointArrays();
186  int GetNumberOfCellArrays();
188 
190 
194  const char* GetPointArrayName(int index);
195  const char* GetCellArrayName(int index);
197 
199 
203  int GetPointArrayStatus(const char* name);
204  int GetCellArrayStatus(const char* name);
205  void SetPointArrayStatus(const char* name, int status);
206  void SetCellArrayStatus(const char* name, int status);
208 
210  {
211  ENSIGHT_6 = 0,
212  ENSIGHT_6_BINARY = 1,
213  ENSIGHT_GOLD = 2,
214  ENSIGHT_GOLD_BINARY = 3,
215  ENSIGHT_MASTER_SERVER = 4
216  };
217 
219 
225  void SetByteOrderToBigEndian();
226  void SetByteOrderToLittleEndian();
227  vtkSetMacro(ByteOrder, int);
228  vtkGetMacro(ByteOrder, int);
229  const char* GetByteOrderAsString();
231 
232  enum
233  {
234  FILE_BIG_ENDIAN = 0,
235  FILE_LITTLE_ENDIAN = 1,
236  FILE_UNKNOWN_ENDIAN = 2
237  };
238 
240 
244  vtkGetFilePathMacro(GeometryFileName);
246 
248 
260  vtkSetMacro(ParticleCoordinatesByIndex, vtkTypeBool);
261  vtkGetMacro(ParticleCoordinatesByIndex, vtkTypeBool);
262  vtkBooleanMacro(ParticleCoordinatesByIndex, vtkTypeBool);
264 
269  static bool IsEnSightFile(VTK_FILEPATH const char* casefilename);
270 
274  virtual int CanReadFile(VTK_FILEPATH const char* casefilename);
275 
276  // THIB
277  vtkGenericEnSightReader* GetReader() { return this->Reader; }
278 
280 
285  vtkGetMacro(ApplyTetrahedralize, bool);
286  vtkSetMacro(ApplyTetrahedralize, bool);
288 
289 protected:
291  ~vtkGenericEnSightReader() override;
292 
296 
302  virtual void ClearForNewCaseFileName();
303 
307  void SanitizeFileName(std::string& filename);
308 
313  int ReadLine(char result[256]);
314 
319  int ReadBinaryLine(char result[80]);
320 
324  bool SkipDataLine(char line[256]);
325 
326  // Internal function that skips blank lines and reads the 1st
327  // non-blank line it finds (up to 256 characters).
328  // Returns 0 is there was an error.
329  int ReadNextDataLine(char result[256]);
330 
332 
335  vtkSetFilePathMacro(GeometryFileName);
337 
339 
342  void AddVariableDescription(const char* description);
343  void AddComplexVariableDescription(const char* description);
345 
347 
350  void AddVariableType(int variableType);
351  void AddComplexVariableType(int variableType);
353 
358  int ReplaceWildcards(char* fileName, int timeSet, int fileSet);
359 
363  static void ReplaceWildcardsHelper(char* fileName, int num);
364 
365  // Callback registered with the SelectionObserver.
366  static void SelectionModifiedCallback(
367  vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
368  void SelectionModified();
369 
370  // Utility to create argument for vtkDataArraySelection::SetArrays.
371  char** CreateStringArray(int numStrings);
372  void DestroyStringArray(int numStrings, char** strings);
373 
374  // Fill the vtkDataArraySelection objects with the current set of
375  // EnSight variables.
376  void SetDataArraySelectionSetsFromVariables();
377 
378  // Fill the vtkDataArraySelection objects with the current set of
379  // arrays in the internal EnSight reader.
380  void SetDataArraySelectionSetsFromReader();
381 
382  // Fill the internal EnSight reader's vtkDataArraySelection objects
383  // from those in this object.
384  void SetReaderDataArraySelectionSetsFromSelf();
385 
386  istream* IS;
387  FILE* IFile;
389 
392  char* FilePath;
393 
394  // array of types (one entry per instance of variable type in case file)
397 
398  // pointers to lists of descriptions
401 
404 
405  // number of file names / descriptions per type
420 
421  double TimeValue;
424 
425  // Flag for whether TimeValue has been set.
427 
429  virtual void SetTimeSets(vtkDataArrayCollection*);
430 
432 
435 
436  // The EnSight file version being read. Valid after
437  // UpdateInformation. Value is -1 for unknown version.
439 
440  // The array selections. These map over the variables and complex
441  // variables to hide the details of EnSight behind VTK terminology.
444 
445  // The observer to modify this object when the array selections are
446  // modified.
448 
449  // Whether the SelectionModified callback should invoke Modified.
450  // This is used when we are copying to/from the internal reader.
452 
453  // Insert a partId and return the 'realId' that should be used.
454  int InsertNewPartId(int partId);
455 
456  // Wrapper around an stl map
457  TranslationTableType* TranslationTable;
458 
459  bool ApplyTetrahedralize = false;
460 
461 private:
463  void operator=(const vtkGenericEnSightReader&) = delete;
464 };
465 
466 VTK_ABI_NAMESPACE_END
467 #endif
vtkDataArrayCollection * TimeSets
vtkCallbackCommand * SelectionObserver
abstract base class for most VTK objects
Definition: vtkObject.h:51
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:64
vtkDataArraySelection * PointDataArraySelection
supports function callbacks
a simple class to control print indentation
Definition: vtkIndent.h:28
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.