VTK  9.4.20250208
vtkEnSightReader.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
8#ifndef vtkEnSightReader_h
9#define vtkEnSightReader_h
10
12#include "vtkIOEnSightModule.h" // For export macro
13#include "vtkSmartPointer.h" // for vtkSmartPointer
14
15#include <map> // for std::map
16#include <vector> // for std::vector
17
18VTK_ABI_NAMESPACE_BEGIN
19class vtkDataSet;
21class vtkDoubleArray;
22class vtkEnSightReaderCellIdsType;
23class vtkIdList;
25class vtkTransform;
26
27class VTKIOENSIGHT_EXPORT vtkEnSightReader : public vtkGenericEnSightReader
28{
29public:
31 void PrintSelf(ostream& os, vtkIndent indent) override;
32
34 {
35 POINT = 0,
36 BAR2 = 1,
37 BAR3 = 2,
38 NSIDED = 3,
39 TRIA3 = 4,
40 TRIA6 = 5,
41 QUAD4 = 6,
42 QUAD8 = 7,
43 NFACED = 8,
44 TETRA4 = 9,
45 TETRA10 = 10,
46 PYRAMID5 = 11,
47 PYRAMID13 = 12,
48 HEXA8 = 13,
49 HEXA20 = 14,
50 PENTA6 = 15,
51 PENTA15 = 16,
52 NUMBER_OF_ELEMENT_TYPES = 17
53 };
54
56 {
57 SCALAR_PER_NODE = 0,
58 VECTOR_PER_NODE = 1,
59 TENSOR_SYMM_PER_NODE = 2,
60 SCALAR_PER_ELEMENT = 3,
61 VECTOR_PER_ELEMENT = 4,
62 TENSOR_SYMM_PER_ELEMENT = 5,
63 SCALAR_PER_MEASURED_NODE = 6,
64 VECTOR_PER_MEASURED_NODE = 7,
65 COMPLEX_SCALAR_PER_NODE = 8,
66 COMPLEX_VECTOR_PER_NODE = 9,
67 COMPLEX_SCALAR_PER_ELEMENT = 10,
68 COMPLEX_VECTOR_PER_ELEMENT = 11,
69 TENSOR_ASYM_PER_NODE = 12,
70 TENSOR_ASYM_PER_ELEMENT = 13
71 };
72
74 {
75 COORDINATES = 0,
76 BLOCK = 1,
77 ELEMENT = 2
78 };
79
81
85 vtkGetFilePathMacro(MeasuredFileName);
87
89
93 vtkGetFilePathMacro(MatchFileName);
95
97
101 vtkGetFilePathMacro(RigidBodyFileName);
103
104protected:
107
110
111 void ClearForNewCaseFileName() override;
112
114
117 vtkSetFilePathMacro(MeasuredFileName);
119
121
124 vtkSetFilePathMacro(MatchFileName);
126
128
131 vtkSetFilePathMacro(RigidBodyFileName);
133
135
139 int ReadCaseFileGeometry(char* line);
140 int ReadCaseFileVariable(char* line);
141 int ReadCaseFileTime(char* line);
142 int ReadCaseFileFile(char* line);
143 int ReadCaseFileScripts(char* line);
144
146
147 // set in UpdateInformation to value returned from ReadCaseFile
149
153 virtual int ReadGeometryFile(
154 const char* fileName, int timeStep, vtkMultiBlockDataSet* output) = 0;
155
161 const char* fileName, int timeStep, vtkMultiBlockDataSet* output) = 0;
162
169
176 int ReadRigidBodyEulerParameterFile(const char* path);
177
181 int ReadRigidBodyMatrixLines(char* line, vtkTransform* transform, bool& applyToVectors);
182
188 int ApplyRigidBodyTransforms(int partId, const char* name, vtkDataSet* output);
189
194
199 virtual int ReadScalarsPerNode(const char* fileName, const char* description, int timeStep,
200 vtkMultiBlockDataSet* output, int measured = 0, int numberOfComponents = 1,
201 int component = 0) = 0;
202
207 virtual int ReadVectorsPerNode(const char* fileName, const char* description, int timeStep,
208 vtkMultiBlockDataSet* output, int measured = 0) = 0;
209
215 const char* fileName, const char* description, int timeStep, vtkMultiBlockDataSet* output) = 0;
216
222 const char* fileName, const char* description, int timeStep, vtkMultiBlockDataSet* output) = 0;
223
228 virtual int ReadScalarsPerElement(const char* fileName, const char* description, int timeStep,
229 vtkMultiBlockDataSet* output, int numberOfComponents = 1, int component = 0) = 0;
230
236 const char* fileName, const char* description, int timeStep, vtkMultiBlockDataSet* output) = 0;
237
243 const char* fileName, const char* description, int timeStep, vtkMultiBlockDataSet* output) = 0;
244
250 const char* fileName, const char* description, int timeStep, vtkMultiBlockDataSet* output) = 0;
251
257 int partId, char line[80], const char* name, vtkMultiBlockDataSet* output) = 0;
258
264 int partId, char line[80], const char* name, vtkMultiBlockDataSet* output) = 0;
265
269 void AddVariableFileName(const char* fileName1, const char* fileName2 = nullptr);
270
274 void AddVariableDescription(const char* description);
275
280
285 int GetElementType(const char* line);
286
291 int GetSectionType(const char* line);
292
296 void RemoveLeadingBlanks(char* line);
297
298 // Get the vtkIdList for the given output index and cell type.
299 vtkIdList* GetCellIds(int index, int cellType);
300
305 void AddToBlock(vtkMultiBlockDataSet* output, unsigned int blockNo, vtkDataSet* dataset);
306
311 vtkDataSet* GetDataSetFromBlock(vtkMultiBlockDataSet* output, unsigned int blockNo);
312
316 void SetBlockName(vtkMultiBlockDataSet* output, unsigned int blockNo, const char* name);
317
319 char* MatchFileName; // may not actually be necessary to read this file
321
322 // pointer to lists of vtkIdLists (cell ids per element type per part)
323 vtkEnSightReaderCellIdsType* CellIds;
324
325 // part ids of unstructured outputs
327
329
330 // pointers to lists of filenames
331 char** VariableFileNames; // non-complex
333
334 // array of time sets
337
338 // array of file sets
341
342 // collection of filename numbers per time set
345
346 // collection of filename numbers per file set
349
350 // collection of number of steps per file per file set
352
353 // ids of the time and file sets
356
361
364
366 vtkSetMacro(UseTimeSets, vtkTypeBool);
367 vtkGetMacro(UseTimeSets, vtkTypeBool);
368 vtkBooleanMacro(UseTimeSets, vtkTypeBool);
369
371 vtkSetMacro(UseFileSets, vtkTypeBool);
372 vtkGetMacro(UseFileSets, vtkTypeBool);
373 vtkBooleanMacro(UseFileSets, vtkTypeBool);
374
376
377 // global list of points for measured geometry
379
382
384
386
387 // We support only version 2 of rigid body transform files for only ensight gold files,
388 // but it's implemented here, so we don't need to duplicate implementation for ASCII
389 // and binary readers (the erb and eet files are always in ASCII).
390 // For rigid body transforms, we need to track per part:
391 // 1. transforms to be applied before the Euler transformation
392 // 2. Information about which data to use in the Euler Transform file (eet file)
393 // 3. transforms to be applied after the Euler transformation
395 {
396 // Pre and post transforms do not change over time
397 // We have to track each transform separately, because some transforms need to be
398 // applied to geometry and vectors, while others should only be applied to the geometry
399 std::vector<vtkSmartPointer<vtkTransform>> PreTransforms;
401 std::vector<vtkSmartPointer<vtkTransform>> PostTransforms;
403
404 // EnSight format requires specifying the eet file per part, but according to the user manual
405 // use of different eet files for the same dataset is not actually allowed
406 std::string EETFilename;
407
408 // title is related to, but not necessarily a part name. for instance, if you have 4 wheel parts
409 // there may only be a single "wheel" title that all wheel parts use, applying the same Euler
410 // rotation to all wheels
411 std::string EETTransTitle;
412 };
413
414 // rigid body files allows for using either part names or part Ids to specify
415 // transforms for parts;
417
418 // keeps track of all transforms for each part
419 // if UsePartNamesRB == true, the key is the part name
420 // otherwise, the key name is the partId converted to a string
421 std::map<std::string, PartTransforms> RigidBodyTransforms;
422
423 // map time step to the Euler transform for a part
424 using TimeToEulerTransMapType = std::map<double, vtkSmartPointer<vtkTransform>>;
425
426 // map a title to all of its Euler transforms
427 using TitleToTimeStepMapType = std::map<std::string, TimeToEulerTransMapType>;
428
430
431 // It's possible for an EnSight dataset to not contain transient data, except for the
432 // Euler transforms. In this case, we will populate EulerTimeSteps so we can use it for
433 // time information, instead of the usual time set
436
437private:
438 vtkEnSightReader(const vtkEnSightReader&) = delete;
439 void operator=(const vtkEnSightReader&) = delete;
440};
441
442VTK_ABI_NAMESPACE_END
443#endif
maintain an unordered list of dataset objects
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
dynamic, self-adjusting array of double
superclass for EnSight file readers
int GetSectionType(const char *line)
Determine the section type from a line read a file.
vtkIdList * ComplexVariableFileSetIds
virtual int ReadTensorsPerElement(const char *fileName, const char *description, int timeStep, vtkMultiBlockDataSet *output)=0
Read tensors per element for this dataset.
vtkIdList * UnstructuredPartIds
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkTypeBool UseTimeSets
std::map< std::string, PartTransforms > RigidBodyTransforms
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
virtual int ReadVectorsPerElement(const char *fileName, const char *description, int timeStep, vtkMultiBlockDataSet *output)=0
Read vectors per element for this dataset.
TitleToTimeStepMapType EulerTransformsMap
vtkIdListCollection * FileSetFileNameNumbers
vtkTypeBool UseFileSets
void AddToBlock(vtkMultiBlockDataSet *output, unsigned int blockNo, vtkDataSet *dataset)
Convenience method use to convert the readers from VTK 5 multiblock API to the current composite data...
int GetElementType(const char *line)
Determine the element type from a line read a file.
virtual int CreateUnstructuredGridOutput(int partId, char line[80], const char *name, vtkMultiBlockDataSet *output)=0
Read an unstructured part (partId) from the geometry file and create a vtkUnstructuredGrid output.
virtual int ReadVectorsPerNode(const char *fileName, const char *description, int timeStep, vtkMultiBlockDataSet *output, int measured=0)=0
Read vectors per node for this dataset.
int ReadRigidBodyMatrixLines(char *line, vtkTransform *transform, bool &applyToVectors)
Helper method for reading matrices specified in rigid body files.
vtkSetFilePathMacro(RigidBodyFileName)
Set the rigid body file name.
int ReadRigidBodyGeometryFile()
Read the rigid body file.
void SetBlockName(vtkMultiBlockDataSet *output, unsigned int blockNo, const char *name)
Set the name of a block.
vtkGetFilePathMacro(MeasuredFileName)
Get the Measured file name.
void AddVariableType()
Record the variable type for the variable line just read.
vtkIdList * VariableTimeSetIds
vtkIdListCollection * FileSetNumberOfSteps
int ApplyRigidBodyTransforms(int partId, const char *name, vtkDataSet *output)
Apply rigid body transforms to the specified part, if there are any.
void AddVariableDescription(const char *description)
Add another description to the list for a particular variable type.
int ReadCaseFileTime(char *line)
Read the case file.
vtkIdList * FileSetsWithFilenameNumbers
vtkDataSet * GetDataSetFromBlock(vtkMultiBlockDataSet *output, unsigned int blockNo)
Convenience method use to convert the readers from VTK 5 multiblock API to the current composite data...
virtual int ReadAsymmetricTensorsPerNode(const char *fileName, const char *description, int timeStep, vtkMultiBlockDataSet *output)=0
Read asymmetric tensors per node for this dataset.
std::map< std::string, TimeToEulerTransMapType > TitleToTimeStepMapType
vtkEnSightReaderCellIdsType * CellIds
virtual int ReadAsymmetricTensorsPerElement(const char *fileName, const char *description, int timeStep, vtkMultiBlockDataSet *output)=0
Read asymmetric tensors per element for this dataset.
virtual int ReadScalarsPerElement(const char *fileName, const char *description, int timeStep, vtkMultiBlockDataSet *output, int numberOfComponents=1, int component=0)=0
Read scalars per element for this dataset.
int ReadCaseFileVariable(char *line)
Read the case file.
vtkSmartPointer< vtkDoubleArray > EulerTimeSteps
int CheckOutputConsistency()
virtual int CreateStructuredGridOutput(int partId, char line[80], const char *name, vtkMultiBlockDataSet *output)=0
Read a structured part from the geometry file and create a vtkStructuredGridOutput.
int ReadCaseFileScripts(char *line)
Read the case file.
vtkGetFilePathMacro(MatchFileName)
Get the Match file name.
vtkIdList * VariableFileSetIds
vtkGetFilePathMacro(RigidBodyFileName)
Get the rigid body file name.
virtual int ReadMeasuredGeometryFile(const char *fileName, int timeStep, vtkMultiBlockDataSet *output)=0
Read the measured geometry file.
int ReadCaseFile()
Read the case file.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSetFilePathMacro(MeasuredFileName)
Set the Measured file name.
char ** ComplexVariableFileNames
vtkIdList * ComplexVariableTimeSetIds
~vtkEnSightReader() override
vtkIdList * TimeSetsWithFilenameNumbers
virtual int ReadScalarsPerNode(const char *fileName, const char *description, int timeStep, vtkMultiBlockDataSet *output, int measured=0, int numberOfComponents=1, int component=0)=0
Read scalars per node for this dataset.
vtkIdListCollection * TimeSetFileNameNumbers
int ReadCaseFileFile(char *line)
Read the case file.
int ReadRigidBodyEulerParameterFile(const char *path)
Read the euler parameter file for rigid body transformations.
void ClearForNewCaseFileName() override
Clear data structures such that setting a new case file name works.
int ReadVariableFiles(vtkMultiBlockDataSet *output)
Read the variable files.
int ReadCaseFileGeometry(char *line)
Read the case file.
std::map< double, vtkSmartPointer< vtkTransform > > TimeToEulerTransMapType
vtkSetFilePathMacro(MatchFileName)
Set the Match file name.
void RemoveLeadingBlanks(char *line)
Remove leading blank spaces from a string.
virtual int ReadGeometryFile(const char *fileName, int timeStep, vtkMultiBlockDataSet *output)=0
Read the geometry file.
vtkIdList * GetCellIds(int index, int cellType)
virtual int ReadTensorsPerNode(const char *fileName, const char *description, int timeStep, vtkMultiBlockDataSet *output)=0
Read tensors per node for this dataset.
void AddVariableFileName(const char *fileName1, const char *fileName2=nullptr)
Add another file name to the list for a particular variable type.
class to read any type of EnSight files
maintain an ordered list of IdList objects
list of point or cell ids
Definition vtkIdList.h:133
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Composite dataset that organizes datasets into blocks.
Hold a reference to a vtkObjectBase instance.
describes linear transformations via a 4x4 matrix
std::vector< bool > PreTransformsApplyToVectors
std::vector< vtkSmartPointer< vtkTransform > > PreTransforms
std::vector< bool > PostTransformsApplyToVectors
std::vector< vtkSmartPointer< vtkTransform > > PostTransforms
int vtkTypeBool
Definition vtkABI.h:64