VTK  9.7.1
vtkERFReader.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
3 #ifndef vtkERFReader_h
4 #define vtkERFReader_h
5 
6 #include "vtkIOERFModule.h" // For export macro
7 #include "vtkNew.h" // For vtkNew
9 #include "vtkSmartPointer.h" // For smart pointer
10 
11 #include <map> // for std::map
12 #include <vector> // for std::vector
13 
14 VTK_ABI_NAMESPACE_BEGIN
15 
16 class vtkDataAssembly;
18 class vtkIntArray;
20 class vtkCellArray;
22 
87 {
88 public:
89  static vtkERFReader* New();
91  void PrintSelf(ostream& os, vtkIndent indent) override;
92 
93  typedef int64_t hid_t;
94 
96 
99  vtkSetMacro(FileName, std::string);
100  vtkGetMacro(FileName, std::string);
102 
104 
108  vtkGetNewMacro(StagesSelection, vtkDataArraySelection);
109  vtkGetNewMacro(VariablesSelection, vtkDataArraySelection);
110  vtkGetNewMacro(BlocksSelection, vtkDataArraySelection);
112 
114 
118  void EnableAllVariables();
119  void EnableAllBlocks();
121 
123 
127  void SetVariablesStatus(const char* name, int status);
128  void SetStagesStatus(const char* name, int status);
129  void SetBlocksStatus(const char* name, int status);
131 
135  std::string GetStage() const;
136 
137 protected:
138  vtkERFReader();
139  ~vtkERFReader() override;
140 
150  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
151  vtkInformationVector* outputVector) override;
152 
161  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
162  vtkInformationVector* outputVector) override;
163 
164 private:
165  vtkERFReader(const vtkERFReader&) = delete;
166  void operator=(const vtkERFReader&) = delete;
167 
174  bool IsValidERFDataset(const hid_t& fileId) const;
175 
182  bool ExtractTemporalData(const hid_t& rootIdx);
183 
187  void AddTemporalInformation(vtkInformation* info);
188 
194  void AddTemporalInformationAsFieldData(vtkPartitionedDataSetCollection* pdc);
195 
199  int TraverseStage(vtkPartitionedDataSetCollection* pdc);
200 
204  void AppendConstantGroupData(vtkPartitionedDataSetCollection* pdc, hid_t fileId);
205 
209  void AppendSinglestateGroupData(hid_t fileId);
210 
212 
215  void AppendMandatoryBlock(vtkPartitionedDataSetCollection* output, const hid_t& fileId);
216  void AppendSystemBlock(vtkPartitionedDataSetCollection* output, const hid_t& fileId);
217  void AppendERFHeaderBlock(vtkPartitionedDataSetCollection* output, const hid_t& fileId);
219 
223  void AppendSinglestateBlock(const hid_t& fileId);
224 
228  void AppendFieldDataByName(
229  vtkPartitionedDataSetCollection* pdc, const hid_t& id, const std::string& name);
230 
232 
235  void BuildMesh(const hid_t& fileId);
236  void AppendPoints(
237  vtkUnstructuredGrid* output, const std::string& nodeAttributePath, const hid_t& fileId);
238  void AppendCells(
239  vtkUnstructuredGrid* output, const std::string& shellAttributePath, const hid_t& fileId);
241 
245  void AppendMeshs(vtkPartitionedDataSetCollection* pdc, vtkDataAssembly* hierarchy,
246  int& streamNodeId, int& meshNodeId, int& meshStartId);
247 
251  int GetTimeValuesIndex();
252 
254 
257  std::string GetAttributeValueAsStr(const hid_t& erfIdx, const std::string& attributeName) const;
258  int GetAttributeValueAsInt(const hid_t& erfIdx, const std::string& attributeName) const;
260 
262 
277  bool IsCellSupported(int ndim, int npelem);
278  bool Is0DCellSupported(int npelem);
279  bool Is1DCellSupported(int npelem);
280  bool Is2DCellSupported(int npelem);
281  bool Is3DCellSupported(int npelem);
283 
287  void FillCellsByType(vtkCellArray* cellArray, vtkUnsignedCharArray* cellType, hid_t shellDataType,
288  hid_t arrayId, vtkIntArray* entid, int numberOfDimensions, int numberOfIndicePerCell,
289  int numberOfCell);
290 
292 
295  void Fill0DCellType(vtkCellArray* cellArray, vtkUnsignedCharArray* cellTypes, vtkIntArray* entid,
296  const std::vector<int>& resData, int numberOfIndicePerCell, int numberOfCell);
297  void Fill1DCellType(vtkCellArray* cellArray, vtkUnsignedCharArray* cellTypes, vtkIntArray* entid,
298  const std::vector<int>& resData, int numberOfIndicePerCell, int numberOfCell);
299  void Fill2DCellType(vtkCellArray* cellArray, vtkUnsignedCharArray* cellTypes, vtkIntArray* entid,
300  const std::vector<int>& resData, int numberOfIndicePerCell, int numberOfCell);
301  void Fill3DCellType(vtkCellArray* cellArray, vtkUnsignedCharArray* cellTypes, vtkIntArray* entid,
302  const std::vector<int>& resData, int numberOfIndicePerCell, int numberOfCell);
304 
305  std::string FileName;
306  std::string CurrentName;
307 
308  vtkNew<vtkDataArraySelection> StagesSelection;
309  vtkNew<vtkDataArraySelection> VariablesSelection;
310  vtkNew<vtkDataArraySelection> BlocksSelection;
311  vtkNew<vtkDataArraySelection> ConstantGroupSelection;
312  vtkNew<vtkDataArraySelection> MultistateGroupSelection;
313  vtkNew<vtkDataArraySelection> SinglestateGroupSelection;
314 
315  std::vector<int> States;
316  std::vector<double> TimeValues;
317  double TimeRanges[2] = { 0.0, 0.0 };
318  double CurrentTimeValue = 0.0;
319 
320  std::map<std::string, vtkSmartPointer<vtkUnstructuredGrid>> MeshPoints;
321  std::map<std::string, vtkSmartPointer<vtkUnstructuredGrid>> Meshs;
322 };
323 
324 VTK_ABI_NAMESPACE_END
325 #endif
int64_t hid_t
Definition: vtkERFReader.h:93
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Store vtkAlgorithm input/output information.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Methods for subclasses to override to handle different pipeline requests.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:35
Read ERF-HDF5 files.
Definition: vtkERFReader.h:86
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Methods for subclasses to override to handle different pipeline requests.
a simple class to control print indentation
Definition: vtkIndent.h:28
Store on/off settings for data arrays, etc.
dataset represents arbitrary combinations of all possible cell types
Superclass for algorithms that produce vtkPartitionedDataSetCollectionAlgorithm.
dynamic, self-adjusting array of unsigned char
object to represent cell connectivity
Definition: vtkCellArray.h:177
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
hierarchical representation to use with vtkPartitionedDataSetCollection
Composite dataset that groups datasets as a collection.