VTK  9.3.20240423
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
22VTK_ABI_NAMESPACE_BEGIN
27
28class 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
43{
44public:
47 void PrintSelf(ostream& os, vtkIndent indent) override;
48
50
53 void SetCaseFileName(VTK_FILEPATH const char* fileName);
54 vtkGetFilePathMacro(CaseFileName);
56
58
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);
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
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
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
289protected:
292
293 int FillOutputPortInformation(int port, vtkInformation* info) override;
296
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.
367 vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
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.
377
378 // Fill the vtkDataArraySelection objects with the current set of
379 // arrays in the internal EnSight reader.
381
382 // Fill the internal EnSight reader's vtkDataArraySelection objects
383 // from those in this object.
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
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
461private:
463 void operator=(const vtkGenericEnSightReader&) = delete;
464};
465
466VTK_ABI_NAMESPACE_END
467#endif
supports function callbacks
maintain an ordered list of dataarray objects
Store on/off settings for data arrays, etc.
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.
const char * GetCellArrayName(int index)
Get the name of the point or cell array with the given index in the input.
char ** CreateStringArray(int numStrings)
vtkGenericEnSightReader * GetReader()
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...
int GetNumberOfVariables(int type)
Get the number of variables of a particular type.
const char * GetByteOrderAsString()
Set the byte order of the file (remember, more Unix workstations write big endian whereas PCs write l...
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
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...
vtkGetFilePathMacro(GeometryFileName)
Get the Geometry file name.
void SanitizeFileName(std::string &filename)
Sanitizes filename, removing quotations and removing trailing whitespace.
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 * GetDescription(int n, int type)
Get the nth description of a particular variable type.
int GetNumberOfCellArrays()
Get the number of point or cell arrays available in the input.
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.
const char * GetDescription(int n)
Get the nth description for a non-complex variable.
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.
virtual void SetTimeValue(double value)
Set/Get the time value at which to get the value.
const char * GetPointArrayName(int index)
Get the name of the point or cell array with the given index in the input.
int GetVariableType(int n)
Get the variable type of variable n.
virtual int CanReadFile(VTK_FILEPATH const char *casefilename)
Returns IsEnSightFile() by default, but can be overridden.
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...
static vtkGenericEnSightReader * New()
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:108
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:162
int vtkTypeBool
Definition vtkABI.h:64
EnsightReaderCellIdMode
@ SINGLE_PROCESS_MODE
@ IMPLICIT_STRUCTURED_MODE
#define VTK_FILEPATH