VTK  9.3.0
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
20VTK_ABI_NAMESPACE_BEGIN
25
26class TranslationTableType;
27
28// Cell/Point Ids store mode:
29// Sparse Mode is supposed to be for a large number of distributed processes (Unstructured)
30// Non Sparse Mode is supposed to be for a small number of distributed processes (Unstructured)
31// Implicit Mode is for Structured Data
33{
38};
39
41{
42public:
45 void PrintSelf(ostream& os, vtkIndent indent) override;
46
48
51 void SetCaseFileName(VTK_FILEPATH const char* fileName);
52 vtkGetFilePathMacro(CaseFileName);
54
56
62
64
67 vtkGetMacro(EnSightVersion, int);
69
71
74 vtkGetMacro(NumberOfVariables, int);
75 vtkGetMacro(NumberOfComplexVariables, int);
77
79
82 int GetNumberOfVariables(int type); // returns -1 if unknown type specified
83 vtkGetMacro(NumberOfScalarsPerNode, int);
84 vtkGetMacro(NumberOfVectorsPerNode, int);
85 vtkGetMacro(NumberOfTensorsAsymPerNode, int);
86 vtkGetMacro(NumberOfTensorsSymmPerNode, int);
87 vtkGetMacro(NumberOfScalarsPerElement, int);
88 vtkGetMacro(NumberOfVectorsPerElement, int);
89 vtkGetMacro(NumberOfTensorsAsymPerElement, int);
90 vtkGetMacro(NumberOfTensorsSymmPerElement, int);
91 vtkGetMacro(NumberOfScalarsPerMeasuredNode, int);
92 vtkGetMacro(NumberOfVectorsPerMeasuredNode, int);
93 vtkGetMacro(NumberOfComplexScalarsPerNode, int);
94 vtkGetMacro(NumberOfComplexVectorsPerNode, int);
95 vtkGetMacro(NumberOfComplexScalarsPerElement, int);
96 vtkGetMacro(NumberOfComplexVectorsPerElement, int);
98
102 const char* GetDescription(int n);
103
107 const char* GetComplexDescription(int n);
108
120 const char* GetDescription(int n, int type);
121
123
126 int GetVariableType(int n);
129
131
134 virtual void SetTimeValue(float value);
135 vtkGetMacro(TimeValue, float);
137
139
142 vtkGetMacro(MinimumTimeValue, float);
143 vtkGetMacro(MaximumTimeValue, float);
145
147
150 vtkGetObjectMacro(TimeSets, vtkDataArrayCollection);
152
159 int DetermineEnSightVersion(int quiet = 0);
160
162
165 vtkBooleanMacro(ReadAllVariables, vtkTypeBool);
166 vtkSetMacro(ReadAllVariables, vtkTypeBool);
167 vtkGetMacro(ReadAllVariables, vtkTypeBool);
169
171
175 vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
176 vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
178
180
186
188
192 const char* GetPointArrayName(int index);
193 const char* GetCellArrayName(int index);
195
197
201 int GetPointArrayStatus(const char* name);
202 int GetCellArrayStatus(const char* name);
203 void SetPointArrayStatus(const char* name, int status);
204 void SetCellArrayStatus(const char* name, int status);
206
208 {
209 ENSIGHT_6 = 0,
210 ENSIGHT_6_BINARY = 1,
211 ENSIGHT_GOLD = 2,
212 ENSIGHT_GOLD_BINARY = 3,
213 ENSIGHT_MASTER_SERVER = 4
214 };
215
217
225 vtkSetMacro(ByteOrder, int);
226 vtkGetMacro(ByteOrder, int);
227 const char* GetByteOrderAsString();
229
230 enum
231 {
232 FILE_BIG_ENDIAN = 0,
233 FILE_LITTLE_ENDIAN = 1,
234 FILE_UNKNOWN_ENDIAN = 2
235 };
236
238
242 vtkGetFilePathMacro(GeometryFileName);
244
246
258 vtkSetMacro(ParticleCoordinatesByIndex, vtkTypeBool);
259 vtkGetMacro(ParticleCoordinatesByIndex, vtkTypeBool);
260 vtkBooleanMacro(ParticleCoordinatesByIndex, vtkTypeBool);
262
267 static bool IsEnSightFile(VTK_FILEPATH const char* casefilename);
268
272 virtual int CanReadFile(VTK_FILEPATH const char* casefilename);
273
274 // THIB
275 vtkGenericEnSightReader* GetReader() { return this->Reader; }
276
278
283 vtkGetMacro(ApplyTetrahedralize, bool);
284 vtkSetMacro(ApplyTetrahedralize, bool);
286
287protected:
290
291 int FillOutputPortInformation(int port, vtkInformation* info) override;
294
301
306 int ReadLine(char result[256]);
307
312 int ReadBinaryLine(char result[80]);
313
317 bool SkipDataLine(char line[256]);
318
319 // Internal function that skips blank lines and reads the 1st
320 // non-blank line it finds (up to 256 characters).
321 // Returns 0 is there was an error.
322 int ReadNextDataLine(char result[256]);
323
325
328 vtkSetFilePathMacro(GeometryFileName);
330
332
335 void AddVariableDescription(const char* description);
336 void AddComplexVariableDescription(const char* description);
338
340
343 void AddVariableType(int variableType);
344 void AddComplexVariableType(int variableType);
346
351 int ReplaceWildcards(char* fileName, int timeSet, int fileSet);
352
356 static void ReplaceWildcardsHelper(char* fileName, int num);
357
358 // Callback registered with the SelectionObserver.
360 vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
362
363 // Utility to create argument for vtkDataArraySelection::SetArrays.
364 char** CreateStringArray(int numStrings);
365 void DestroyStringArray(int numStrings, char** strings);
366
367 // Fill the vtkDataArraySelection objects with the current set of
368 // EnSight variables.
370
371 // Fill the vtkDataArraySelection objects with the current set of
372 // arrays in the internal EnSight reader.
374
375 // Fill the internal EnSight reader's vtkDataArraySelection objects
376 // from those in this object.
378
379 istream* IS;
380 FILE* IFile;
382
385 char* FilePath;
386
387 // array of types (one entry per instance of variable type in case file)
390
391 // pointers to lists of descriptions
394
397
398 // number of file names / descriptions per type
413
417
418 // Flag for whether TimeValue has been set.
420
423
425
428
429 // The EnSight file version being read. Valid after
430 // UpdateInformation. Value is -1 for unknown version.
432
433 // The array selections. These map over the variables and complex
434 // variables to hide the details of EnSight behind VTK terminology.
437
438 // The observer to modify this object when the array selections are
439 // modified.
441
442 // Whether the SelectionModified callback should invoke Modified.
443 // This is used when we are copying to/from the internal reader.
445
446 // Insert a partId and return the 'realId' that should be used.
447 int InsertNewPartId(int partId);
448
449 // Wrapper around an stl map
450 TranslationTableType* TranslationTable;
451
452 bool ApplyTetrahedralize = false;
453
454private:
456 void operator=(const vtkGenericEnSightReader&) = delete;
457};
458
459VTK_ABI_NAMESPACE_END
460#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
virtual void SetTimeValue(float value)
Set/Get the time value at which to get the value.
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.
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.
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:29
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:49
int vtkTypeBool
Definition vtkABI.h:64
EnsightReaderCellIdMode
@ SINGLE_PROCESS_MODE
@ IMPLICIT_STRUCTURED_MODE
#define VTK_FILEPATH