VTK  9.4.20241108
vtkHDFReaderImplementation.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
9#ifndef vtkHDFReaderImplementation_h
10#define vtkHDFReaderImplementation_h
11
12#include "vtkHDFReader.h"
13#include "vtk_hdf5.h"
14#include <array>
15#include <map>
16#include <string>
17#include <vector>
18
19VTK_ABI_NAMESPACE_BEGIN
21class vtkDataArray;
22class vtkStringArray;
23class vtkDataAssembly;
24
30{
31public:
33 virtual ~Implementation();
37 bool Open(VTK_FILEPATH const char* fileName);
41 void Close();
46 int GetDataSetType() { return this->DataSetType; }
50 const std::array<int, 2>& GetVersion() { return this->Version; }
54 template <typename T>
55 bool GetAttribute(const char* attributeName, size_t numberOfElements, T* value);
65 bool GetPartitionExtent(hsize_t partitionIndex, int* extent);
69 std::vector<std::string> GetArrayNames(int attributeType);
73 std::vector<std::string> GetOrderedChildrenOfGroup(const std::string& path);
75
84 int attributeType, const char* name, const std::vector<hsize_t>& fileExtent);
85 vtkDataArray* NewArray(int attributeType, const char* name, hsize_t offset, hsize_t size);
87 const char* name, vtkIdType offset = -1, vtkIdType size = -1, vtkIdType dimMaxSize = -1);
89
91
97 vtkDataArray* NewMetadataArray(const char* name, hsize_t offset, hsize_t size);
98 std::vector<vtkIdType> GetMetadata(const char* name, hsize_t size, hsize_t offset = 0);
100
103 std::vector<hsize_t> GetDimensions(const char* dataset);
104
108 bool IsPathSoftLink(const std::string& path);
109
111
116 bool FillAssembly(vtkDataAssembly* data, hid_t assemblyHandle, int assemblyID, std::string path);
118
122 std::size_t GetNumberOfSteps();
123
125
131
135 vtkIdType GetArrayOffset(vtkIdType step, int attributeType, std::string name);
136
142 std::array<vtkIdType, 2> GetFieldArraySize(vtkIdType step, std::string name);
143
147 bool OpenGroupAsVTKGroup(const std::string& groupPath);
148
152 bool RetrieveHDFInformation(const std::string& rootName);
153
155
161 bool ComputeAMRBlocksPerLevels(unsigned int maxLevel);
162
167 vtkDataArraySelection* dataArraySelection[3], vtkIdType step, unsigned int maxLevel);
168
172 bool ReadAMRTopology(vtkOverlappingAMR* data, unsigned int level, unsigned int maxLevel,
173 double origin[3], bool isTemporalData);
174
178 bool ReadAMRData(vtkOverlappingAMR* data, unsigned int level, unsigned int maxLevel,
179 vtkDataArraySelection* dataArraySelection[3], bool isTemporalData);
181
182private:
183 std::string FileName;
184 hid_t File;
185 hid_t VTKGroup;
186 // in the same order as vtkDataObject::AttributeTypes: POINT, CELL, FIELD
187 std::array<hid_t, 3> AttributeDataGroup;
188 int DataSetType;
189 int NumberOfPieces;
190 std::array<int, 2> Version;
191 vtkHDFReader* Reader;
192
194
197 struct AMRBlocksInformation
198 {
199 std::vector<int> BlocksPerLevel;
200 std::vector<vtkIdType> BlockOffsetsPerLevel;
201 std::map<std::string, std::vector<vtkIdType>> CellOffsetsPerLevel;
202 std::map<std::string, std::vector<vtkIdType>> PointOffsetsPerLevel;
203 std::map<std::string, std::vector<vtkIdType>> FieldOffsetsPerLevel;
204 std::map<std::string, std::vector<vtkIdType>> FieldSizesPerLevel;
205
206 void Clear()
207 {
208 this->BlocksPerLevel.clear();
209 this->BlockOffsetsPerLevel.clear();
210 this->PointOffsetsPerLevel.clear();
211 this->CellOffsetsPerLevel.clear();
212 this->FieldOffsetsPerLevel.clear();
213 this->FieldSizesPerLevel.clear();
214 }
215 };
216
217 AMRBlocksInformation AMRInformation;
218
219 bool ReadLevelSpacing(hid_t levelGroupID, double* spacing);
220 bool ReadAMRBoxRawValues(
221 hid_t levelGroupID, std::vector<int>& amrBoxRawData, int level, bool isTemporalData);
222 bool ReadLevelTopology(unsigned int level, const std::string& levelGroupName,
223 vtkOverlappingAMR* data, double origin[3], bool isTemporalData);
224 bool ReadLevelData(unsigned int level, const std::string& levelGroupName, vtkOverlappingAMR* data,
225 vtkDataArraySelection* dataArraySelection[3], bool isTemporalData);
227};
228
229VTK_ABI_NAMESPACE_END
230#endif
231// VTK-HeaderTest-Exclude: vtkHDFReaderImplementation.h
Abstract superclass for all arrays.
Store on/off settings for data arrays, etc.
abstract superclass for arrays of numeric data
hierarchical representation to use with vtkPartitionedDataSetCollection
Implementation for the vtkHDFReader.
vtkDataArray * NewMetadataArray(const char *name, hsize_t offset, hsize_t size)
Reads a 1D metadata array in a DataArray or a vector of vtkIdType.
bool GetPartitionExtent(hsize_t partitionIndex, int *extent)
For an ImageData, sets the extent for 'partitionIndex'.
bool OpenGroupAsVTKGroup(const std::string &groupPath)
Open a sub group of the current file and consider it as the new root file.
bool IsPathSoftLink(const std::string &path)
Return true if current root path is a soft link.
const std::array< int, 2 > & GetVersion()
Returns the version of the VTK HDF implementation.
bool Open(VTK_FILEPATH const char *fileName)
Opens this VTK HDF file and checks if it is valid.
Implementation(vtkHDFReader *reader)
vtkDataArray * NewArray(int attributeType, const char *name, const std::vector< hsize_t > &fileExtent)
Reads and returns a new vtkDataArray.
vtkIdType GetArrayOffset(vtkIdType step, int attributeType, std::string name)
Methods to query for array offsets when steps are present.
std::vector< hsize_t > GetDimensions(const char *dataset)
Returns the dimensions of a HDF dataset.
vtkAbstractArray * NewFieldArray(const char *name, vtkIdType offset=-1, vtkIdType size=-1, vtkIdType dimMaxSize=-1)
Reads and returns a new vtkDataArray.
bool ComputeAMROffsetsPerLevels(vtkDataArraySelection *dataArraySelection[3], vtkIdType step, unsigned int maxLevel)
Retrieve offset for AMRBox, point/cell/field arrays for each level.
bool RetrieveHDFInformation(const std::string &rootName)
Initialize meta information of the implementation based on root name specified.
std::vector< std::string > GetArrayNames(int attributeType)
Returns the names of arrays for 'attributeType' (point or cell).
vtkDataArray * GetStepValues()
Read the values of the steps from the open file.
std::array< vtkIdType, 2 > GetFieldArraySize(vtkIdType step, std::string name)
Return the field array size (components, tuples) for the current step.
int GetDataSetType()
Type of vtkDataSet stored by the HDF file, such as VTK_IMAGE_DATA or VTK_UNSTRUCTURED_GRID,...
int GetNumberOfPieces(vtkIdType step=-1)
Returns the number of partitions for this dataset at the time step step if applicable.
bool FillAssembly(vtkDataAssembly *data)
Fills the given Assembly with the content of the opened HDF file.
vtkDataArray * GetStepValues(hid_t group)
Read the values of the steps from the open file.
bool ReadAMRData(vtkOverlappingAMR *data, unsigned int level, unsigned int maxLevel, vtkDataArraySelection *dataArraySelection[3], bool isTemporalData)
Read the AMR data based on offset on point/cell/field datas.
void Close()
Closes the VTK HDF file and releases any allocated resources.
bool GetAttribute(const char *attributeName, size_t numberOfElements, T *value)
Reads an attribute from the /VTKHDF group.
bool ComputeAMRBlocksPerLevels(unsigned int maxLevel)
Specific public API for AMR supports.
std::size_t GetNumberOfSteps()
Read the number of steps from the opened file.
bool ReadAMRTopology(vtkOverlappingAMR *data, unsigned int level, unsigned int maxLevel, double origin[3], bool isTemporalData)
Read the AMR topology based on offset data on AMRBlocks.
bool FillAssembly(vtkDataAssembly *data, hid_t assemblyHandle, int assemblyID, std::string path)
Fills the given Assembly with the content of the opened HDF file.
std::vector< std::string > GetOrderedChildrenOfGroup(const std::string &path)
Return the name of all children of an HDF group given its path.
std::vector< vtkIdType > GetMetadata(const char *name, hsize_t size, hsize_t offset=0)
Reads a 1D metadata array in a DataArray or a vector of vtkIdType.
vtkDataArray * NewArray(int attributeType, const char *name, hsize_t offset, hsize_t size)
Reads and returns a new vtkDataArray.
Reads data saved using the VTK HDF format which supports all vtkDataSet types (image data,...
hierarchical dataset of vtkUniformGrids
a vtkAbstractArray subclass for strings
int64_t hid_t
int vtkIdType
Definition vtkType.h:315
#define VTK_FILEPATH