VTK  9.1.0
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:
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
56 
59  void SetCaseFileName(VTK_FILEPATH const char* fileName);
60  vtkGetFilePathMacro(CaseFileName);
62 
64 
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(NumberOfTensorsAsymPerNode, int);
94  vtkGetMacro(NumberOfTensorsSymmPerNode, int);
95  vtkGetMacro(NumberOfScalarsPerElement, int);
96  vtkGetMacro(NumberOfVectorsPerElement, int);
97  vtkGetMacro(NumberOfTensorsAsymPerElement, int);
98  vtkGetMacro(NumberOfTensorsSymmPerElement, int);
99  vtkGetMacro(NumberOfScalarsPerMeasuredNode, int);
100  vtkGetMacro(NumberOfVectorsPerMeasuredNode, int);
101  vtkGetMacro(NumberOfComplexScalarsPerNode, int);
102  vtkGetMacro(NumberOfComplexVectorsPerNode, int);
103  vtkGetMacro(NumberOfComplexScalarsPerElement, int);
104  vtkGetMacro(NumberOfComplexVectorsPerElement, int);
106 
110  const char* GetDescription(int n);
111 
115  const char* GetComplexDescription(int n);
116 
128  const char* GetDescription(int n, int type);
129 
131 
134  int GetVariableType(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, vtkTypeBool);
174  vtkSetMacro(ReadAllVariables, vtkTypeBool);
175  vtkGetMacro(ReadAllVariables, vtkTypeBool);
177 
179 
183  vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
184  vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
186 
188 
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 
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  vtkGetFilePathMacro(GeometryFileName);
252 
254 
266  vtkSetMacro(ParticleCoordinatesByIndex, vtkTypeBool);
267  vtkGetMacro(ParticleCoordinatesByIndex, vtkTypeBool);
268  vtkBooleanMacro(ParticleCoordinatesByIndex, vtkTypeBool);
270 
275  static bool IsEnSightFile(VTK_FILEPATH const char* casefilename);
276 
280  virtual int CanReadFile(VTK_FILEPATH const char* casefilename);
281 
282  // THIB
283  vtkGenericEnSightReader* GetReader() { return this->Reader; }
284 
285 protected:
288 
292 
298  virtual void ClearForNewCaseFileName();
299 
304  int ReadLine(char result[256]);
305 
310  int ReadBinaryLine(char result[80]);
311 
315  bool SkipDataLine(char line[256]);
316 
317  // Internal function that skips blank lines and reads the 1st
318  // non-blank line it finds (up to 256 characters).
319  // Returns 0 is there was an error.
320  int ReadNextDataLine(char result[256]);
321 
323 
326  vtkSetFilePathMacro(GeometryFileName);
328 
330 
336 
338 
341  void AddVariableType(int variableType);
342  void AddComplexVariableType(int variableType);
344 
349  int ReplaceWildcards(char* fileName, int timeSet, int fileSet);
350 
354  static void ReplaceWildcardsHelper(char* fileName, int num);
355 
356  // Callback registered with the SelectionObserver.
358  vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
360 
361  // Utility to create argument for vtkDataArraySelection::SetArrays.
362  char** CreateStringArray(int numStrings);
363  void DestroyStringArray(int numStrings, char** strings);
364 
365  // Fill the vtkDataArraySelection objects with the current set of
366  // EnSight variables.
368 
369  // Fill the vtkDataArraySelection objects with the current set of
370  // arrays in the internal EnSight reader.
372 
373  // Fill the internal EnSight reader's vtkDataArraySelection objects
374  // from those in this object.
376 
377  istream* IS;
378  FILE* IFile;
380 
383  char* FilePath;
384 
385  // array of types (one entry per instance of variable type in case file)
388 
389  // pointers to lists of descriptions
392 
395 
396  // number of file names / descriptions per type
411 
412  float TimeValue;
415 
416  // Flag for whether TimeValue has been set.
418 
421 
423 
426 
427  // The EnSight file version being read. Valid after
428  // UpdateInformation. Value is -1 for unknown version.
430 
431  // The array selections. These map over the variables and complex
432  // variables to hide the details of EnSight behind VTK terminology.
435 
436  // The observer to modify this object when the array selections are
437  // modified.
439 
440  // Whether the SelectionModified callback should invoke Modified.
441  // This is used when we are copying to/from the internal reader.
443 
444  // Insert a partId and return the 'realId' that should be used.
445  int InsertNewPartId(int partId);
446 
447  // Wrapper around an stl map
448  TranslationTableType* TranslationTable;
449 
450 private:
452  void operator=(const vtkGenericEnSightReader&) = delete;
453 };
454 
455 #endif
supports function callbacks
maintain an ordered list of dataarray objects
Store on/off settings for data arrays for a vtkSource.
class to read any type of EnSight files
vtkDataArraySelection * PointDataArraySelection
bool SkipDataLine(char line[256])
Skip certain non-comment lines that are not needed.
int ReadNextDataLine(char result[256])
int InsertNewPartId(int partId)
virtual void SetTimeSets(vtkDataArrayCollection *)
static void ReplaceWildcardsHelper(char *fileName, int num)
Replace the *'s in the filename with the given filename number.
void SetReaderDataArraySelectionSetsFromSelf()
const char * GetComplexDescription(int n)
Get the nth description for a complex variable.
vtkGenericEnSightReader * Reader
void SetCellArrayStatus(const char *name, int status)
Get/Set whether the point or cell array with the given name is to be read.
int DetermineEnSightVersion(int quiet=0)
Reads the FORMAT part of the case file to determine whether this is an EnSight6 or EnSightGold data s...
const char * GetByteOrderAsString()
Set the byte order of the file (remember, more Unix workstations write big endian whereas PCs write l...
int GetNumberOfVariables(int type)
Get the number of variables of a particular type.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
void DestroyStringArray(int numStrings, char **strings)
void AddComplexVariableType(int variableType)
Add a variable type to the appropriate array.
vtkDataArrayCollection * TimeSets
virtual void SetTimeValue(float value)
Set/Get the time value at which to get the value.
const char * GetDescription(int n)
Get the nth description for a non-complex variable.
static void SelectionModifiedCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
~vtkGenericEnSightReader() override
int ReplaceWildcards(char *fileName, int timeSet, int fileSet)
Replace the wildcards in the geometry file name with appropriate filename numbers as specified in the...
char ** CreateStringArray(int numStrings)
vtkGetFilePathMacro(GeometryFileName)
Get the Geometry file name.
int GetComplexVariableType(int n)
Get the variable type of variable n.
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkSetFilePathMacro(GeometryFileName)
Set the geometry file name.
virtual void ClearForNewCaseFileName()
Clear data structures such that setting a new case file name works.
const char * GetPointArrayName(int index)
Get the name of the point or cell array with the given index in the input.
int GetNumberOfCellArrays()
Get the number of point or cell arrays available in the input.
static vtkGenericEnSightReader * New()
void SetCaseFileName(VTK_FILEPATH const char *fileName)
Set/Get the Case file name.
int GetPointArrayStatus(const char *name)
Get/Set whether the point or cell array with the given name is to be read.
int GetCellArrayStatus(const char *name)
Get/Set whether the point or cell array with the given name is to be read.
int ReadBinaryLine(char result[80])
Internal function to read up to 80 characters from a binary file.
static bool IsEnSightFile(VTK_FILEPATH const char *casefilename)
Returns true if the file pointed to by casefilename appears to be a valid EnSight case file.
vtkGetFilePathMacro(FilePath)
Set/Get the file path.
int GetVariableType(int n)
Get the variable type of variable n.
const char * GetCellArrayName(int index)
Get the name of the point or cell array with the given index in the input.
virtual int CanReadFile(VTK_FILEPATH const char *casefilename)
Returns IsEnSightFile() by default, but can be overridden.
vtkGenericEnSightReader * GetReader()
const char * GetDescription(int n, int type)
Get the nth description of a particular variable type.
void SetDataArraySelectionSetsFromReader()
int FillOutputPortInformation(int port, vtkInformation *info) override
Fill the output port information objects for this algorithm.
void AddComplexVariableDescription(const char *description)
Add a variable description to the appropriate array.
void SetPointArrayStatus(const char *name, int status)
Get/Set whether the point or cell array with the given name is to be read.
void AddVariableDescription(const char *description)
Add a variable description to the appropriate array.
vtkGetFilePathMacro(CaseFileName)
Set/Get the Case file name.
TranslationTableType * TranslationTable
void AddVariableType(int variableType)
Add a variable type to the appropriate array.
vtkSetFilePathMacro(FilePath)
Set/Get the file path.
vtkCallbackCommand * SelectionObserver
int ReadLine(char result[256])
Internal function to read in a line up to 256 characters.
void SetDataArraySelectionSetsFromVariables()
void SetByteOrderToLittleEndian()
Set the byte order of the file (remember, more Unix workstations write big endian whereas PCs write l...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkDataArraySelection * CellDataArraySelection
int GetNumberOfPointArrays()
Get the number of point or cell arrays available in the input.
void SetByteOrderToBigEndian()
Set the byte order of the file (remember, more Unix workstations write big endian whereas PCs write l...
maintain an ordered list of IdList objects
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
abstract base class for most VTK objects
Definition: vtkObject.h:63
@ info
Definition: vtkX3D.h:382
@ value
Definition: vtkX3D.h:226
@ port
Definition: vtkX3D.h:453
@ type
Definition: vtkX3D.h:522
@ description
Definition: vtkX3D.h:328
@ name
Definition: vtkX3D.h:225
@ index
Definition: vtkX3D.h:252
int vtkTypeBool
Definition: vtkABI.h:69
EnsightReaderCellIdMode
@ SINGLE_PROCESS_MODE
@ IMPLICIT_STRUCTURED_MODE
@ NON_SPARSE_MODE
#define VTK_FILEPATH