VTK
9.3.20240327
|
Implementation for the vtkHDFReader. More...
#include <vtkHDFReaderImplementation.h>
Classes | |
struct | TypeDescription |
Used to store HDF native types in a map. More... | |
Public Member Functions | |
Implementation (vtkHDFReader *reader) | |
virtual | ~Implementation () |
bool | Open (VTK_FILEPATH const char *fileName) |
Opens this VTK HDF file and checks if it is valid. More... | |
void | Close () |
Closes the VTK HDF file and releases any allocated resources. More... | |
int | GetDataSetType () |
Type of vtkDataSet stored by the HDF file, such as VTK_IMAGE_DATA or VTK_UNSTRUCTURED_GRID, from vtkTypes.h. More... | |
const std::array< int, 2 > & | GetVersion () |
Returns the version of the VTK HDF implementation. More... | |
template<typename T > | |
bool | GetAttribute (const char *attributeName, size_t numberOfElements, T *value) |
Reads an attribute from the /VTKHDF group. More... | |
template<typename T > | |
bool | GetAttribute (hid_t group, const char *attributeName, size_t numberOfElements, T *value) |
Reads an attribute from the group passed to it. More... | |
int | GetNumberOfPieces (vtkIdType step=-1) |
Returns the number of partitions for this dataset at the time step step if applicable. More... | |
bool | GetPartitionExtent (hsize_t partitionIndex, int *extent) |
For an ImageData, sets the extent for 'partitionIndex'. More... | |
std::vector< std::string > | GetArrayNames (int attributeType) |
Returns the names of arrays for 'attributeType' (point or cell). More... | |
std::vector< std::string > | GetOrderedChildrenOfGroup (const std::string &path) |
Return the name of all children of an HDF group given its path. More... | |
std::vector< hsize_t > | GetDimensions (const char *dataset) |
Returns the dimensions of a HDF dataset. More... | |
bool | IsPathSoftLink (const std::string &path) |
Return true if current root path is a soft link. More... | |
bool | FillAMR (vtkOverlappingAMR *data, unsigned int maximumLevelsToReadByDefault, double origin[3], vtkDataArraySelection *dataArraySelection[3]) |
Fills the given AMR data with the content of the opened HDF file. More... | |
vtkIdType | GetArrayOffset (vtkIdType step, int attributeType, std::string name) |
Methods to query for array offsets when steps are present. More... | |
bool | OpenGroupAsVTKGroup (const std::string &groupPath) |
Open a sub group of the current file and consider it as the new root file. More... | |
bool | RetrieveHDFInformation (const std::string &rootName) |
Initialize meta information of the implementation based on root name specified. More... | |
vtkDataArray * | NewArray (int attributeType, const char *name, const std::vector< hsize_t > &fileExtent) |
Reads and returns a new vtkDataArray. More... | |
vtkDataArray * | NewArray (int attributeType, const char *name, hsize_t offset, hsize_t size) |
Reads and returns a new vtkDataArray. More... | |
vtkAbstractArray * | NewFieldArray (const char *name, vtkIdType offset=-1, vtkIdType size=-1) |
Reads and returns a new vtkDataArray. More... | |
vtkDataArray * | NewMetadataArray (const char *name, hsize_t offset, hsize_t size) |
Reads a 1D metadata array in a DataArray or a vector of vtkIdType. More... | |
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. More... | |
bool | FillAssembly (vtkDataAssembly *data) |
Fills the given Assembly with the content of the opened HDF file. More... | |
bool | FillAssembly (vtkDataAssembly *data, hid_t assemblyHandle, int assemblyID, std::string path) |
Fills the given Assembly with the content of the opened HDF file. More... | |
std::size_t | GetNumberOfSteps () |
Read the number of steps from the opened file. More... | |
std::size_t | GetNumberOfSteps (hid_t group) |
Read the number of steps from the opened file. More... | |
vtkDataArray * | GetStepValues () |
Read the values of the steps from the open file. More... | |
vtkDataArray * | GetStepValues (hid_t group) |
Read the values of the steps from the open file. More... | |
Protected Member Functions | |
hid_t | OpenDataSet (hid_t group, const char *name, hid_t *nativeType, std::vector< hsize_t > &dims) |
Opens the hdf5 dataset given the 'group' and 'name'. More... | |
template<typename T > | |
hid_t | TemplateTypeToHdfNativeType () |
Convert C++ template type T to HDF5 native type this can be constexpr in C++17 standard. More... | |
template<typename T > | |
vtkDataArray * | NewVtkDataArray () |
Create a vtkDataArray based on the C++ template type T. More... | |
void | BuildTypeReaderMap () |
Builds a map between native types and GetArray routines for that type. More... | |
TypeDescription | GetTypeDescription (hid_t type) |
Associates a struct of three integers with HDF type. More... | |
vtkDataArray * | NewArrayForGroup (hid_t group, const char *name, const std::vector< hsize_t > &fileExtent) |
Reads a vtkDataArray of type T from the attributeType, dataset The array has type 'T' and 'numberOfComponents'. More... | |
vtkDataArray * | NewArrayForGroup (hid_t dataset, hid_t nativeType, const std::vector< hsize_t > &dims, const std::vector< hsize_t > &fileExtent) |
Reads a vtkDataArray of type T from the attributeType, dataset The array has type 'T' and 'numberOfComponents'. More... | |
template<typename T > | |
vtkDataArray * | NewArray (hid_t dataset, const std::vector< hsize_t > &fileExtent, hsize_t numberOfComponents) |
Reads a vtkDataArray of type T from the attributeType, dataset The array has type 'T' and 'numberOfComponents'. More... | |
template<typename T > | |
bool | NewArray (hid_t dataset, const std::vector< hsize_t > &fileExtent, hsize_t numberOfComponents, T *data) |
Reads a vtkDataArray of type T from the attributeType, dataset The array has type 'T' and 'numberOfComponents'. More... | |
vtkStringArray * | NewStringArray (hid_t dataset, hsize_t size) |
Reads a vtkDataArray of type T from the attributeType, dataset The array has type 'T' and 'numberOfComponents'. More... | |
Implementation for the vtkHDFReader.
Opens, closes and reads information from a VTK HDF file.
Definition at line 30 of file vtkHDFReaderImplementation.h.
vtkHDFReader::Implementation::Implementation | ( | vtkHDFReader * | reader | ) |
|
virtual |
bool vtkHDFReader::Implementation::Open | ( | VTK_FILEPATH const char * | fileName | ) |
Opens this VTK HDF file and checks if it is valid.
void vtkHDFReader::Implementation::Close | ( | ) |
Closes the VTK HDF file and releases any allocated resources.
|
inline |
Type of vtkDataSet stored by the HDF file, such as VTK_IMAGE_DATA or VTK_UNSTRUCTURED_GRID, from vtkTypes.h.
Definition at line 47 of file vtkHDFReaderImplementation.h.
|
inline |
Returns the version of the VTK HDF implementation.
Definition at line 51 of file vtkHDFReaderImplementation.h.
bool vtkHDFReader::Implementation::GetAttribute | ( | const char * | attributeName, |
size_t | numberOfElements, | ||
T * | value | ||
) |
Reads an attribute from the /VTKHDF group.
bool vtkHDFReader::Implementation::GetAttribute | ( | hid_t | group, |
const char * | attributeName, | ||
size_t | numberOfElements, | ||
T * | value | ||
) |
Reads an attribute from the group passed to it.
int vtkHDFReader::Implementation::GetNumberOfPieces | ( | vtkIdType | step = -1 | ) |
Returns the number of partitions for this dataset at the time step step
if applicable.
bool vtkHDFReader::Implementation::GetPartitionExtent | ( | hsize_t | partitionIndex, |
int * | extent | ||
) |
For an ImageData, sets the extent for 'partitionIndex'.
Returns true for success and false otherwise.
std::vector<std::string> vtkHDFReader::Implementation::GetArrayNames | ( | int | attributeType | ) |
Returns the names of arrays for 'attributeType' (point or cell).
std::vector<std::string> vtkHDFReader::Implementation::GetOrderedChildrenOfGroup | ( | const std::string & | path | ) |
Return the name of all children of an HDF group given its path.
vtkDataArray* vtkHDFReader::Implementation::NewArray | ( | int | attributeType, |
const char * | name, | ||
const std::vector< hsize_t > & | fileExtent | ||
) |
Reads and returns a new vtkDataArray.
The actual type of the array depends on the type of the HDF array. The array is read from the PointData or CellData groups depending on the 'attributeType' parameter. There are two versions: a first one that reads from a 3D array using a fileExtent, and a second one that reads from a linear array using an offset and size. The array has to be deleted by the user.
vtkDataArray* vtkHDFReader::Implementation::NewArray | ( | int | attributeType, |
const char * | name, | ||
hsize_t | offset, | ||
hsize_t | size | ||
) |
Reads and returns a new vtkDataArray.
The actual type of the array depends on the type of the HDF array. The array is read from the PointData or CellData groups depending on the 'attributeType' parameter. There are two versions: a first one that reads from a 3D array using a fileExtent, and a second one that reads from a linear array using an offset and size. The array has to be deleted by the user.
vtkAbstractArray* vtkHDFReader::Implementation::NewFieldArray | ( | const char * | name, |
vtkIdType | offset = -1 , |
||
vtkIdType | size = -1 |
||
) |
Reads and returns a new vtkDataArray.
The actual type of the array depends on the type of the HDF array. The array is read from the PointData or CellData groups depending on the 'attributeType' parameter. There are two versions: a first one that reads from a 3D array using a fileExtent, and a second one that reads from a linear array using an offset and size. The array has to be deleted by the user.
vtkDataArray* vtkHDFReader::Implementation::NewMetadataArray | ( | const char * | name, |
hsize_t | offset, | ||
hsize_t | size | ||
) |
Reads a 1D metadata array in a DataArray or a vector of vtkIdType.
We read either the whole array for the vector version or a slice specified with (offset, size). For an error we return nullptr or an empty vector.
std::vector<vtkIdType> vtkHDFReader::Implementation::GetMetadata | ( | const char * | name, |
hsize_t | size, | ||
hsize_t | offset = 0 |
||
) |
Reads a 1D metadata array in a DataArray or a vector of vtkIdType.
We read either the whole array for the vector version or a slice specified with (offset, size). For an error we return nullptr or an empty vector.
std::vector<hsize_t> vtkHDFReader::Implementation::GetDimensions | ( | const char * | dataset | ) |
Returns the dimensions of a HDF dataset.
bool vtkHDFReader::Implementation::IsPathSoftLink | ( | const std::string & | path | ) |
Return true if current root path is a soft link.
bool vtkHDFReader::Implementation::FillAMR | ( | vtkOverlappingAMR * | data, |
unsigned int | maximumLevelsToReadByDefault, | ||
double | origin[3], | ||
vtkDataArraySelection * | dataArraySelection[3] | ||
) |
Fills the given AMR data with the content of the opened HDF file.
The number of level to read is limited by the maximumLevelsToReadByDefault argument. maximumLevelsToReadByDefault == 0 means to read all levels (no limit). Only the selected data array in dataArraySelection are added to the AMR data. Returns true on success.
bool vtkHDFReader::Implementation::FillAssembly | ( | vtkDataAssembly * | data | ) |
Fills the given Assembly with the content of the opened HDF file.
Return true on success, false if the HDF File isn't a composite or the 'Assembly' is missing.
bool vtkHDFReader::Implementation::FillAssembly | ( | vtkDataAssembly * | data, |
hid_t | assemblyHandle, | ||
int | assemblyID, | ||
std::string | path | ||
) |
Fills the given Assembly with the content of the opened HDF file.
Return true on success, false if the HDF File isn't a composite or the 'Assembly' is missing.
std::size_t vtkHDFReader::Implementation::GetNumberOfSteps | ( | ) |
Read the number of steps from the opened file.
std::size_t vtkHDFReader::Implementation::GetNumberOfSteps | ( | hid_t | group | ) |
Read the number of steps from the opened file.
vtkDataArray* vtkHDFReader::Implementation::GetStepValues | ( | ) |
Read the values of the steps from the open file.
vtkDataArray* vtkHDFReader::Implementation::GetStepValues | ( | hid_t | group | ) |
Read the values of the steps from the open file.
vtkIdType vtkHDFReader::Implementation::GetArrayOffset | ( | vtkIdType | step, |
int | attributeType, | ||
std::string | name | ||
) |
Methods to query for array offsets when steps are present.
bool vtkHDFReader::Implementation::OpenGroupAsVTKGroup | ( | const std::string & | groupPath | ) |
Open a sub group of the current file and consider it as the new root file.
bool vtkHDFReader::Implementation::RetrieveHDFInformation | ( | const std::string & | rootName | ) |
Initialize meta information of the implementation based on root name specified.
|
protected |
Opens the hdf5 dataset given the 'group' and 'name'.
Returns the hdf dataset and sets 'nativeType' and 'dims'. The caller needs to close the returned hid_t manually using H5Dclose or a Scoped Handle if it is not an invalid hid.
|
protected |
Convert C++ template type T to HDF5 native type this can be constexpr in C++17 standard.
|
protected |
Create a vtkDataArray based on the C++ template type T.
For instance, for a float we create a vtkFloatArray. this can be constexpr in C++17 standard
|
protected |
Reads a vtkDataArray of type T from the attributeType, dataset The array has type 'T' and 'numberOfComponents'.
We are reading fileExtent slab from the array. It returns the array or nullptr in case of an error. There are three cases for fileExtent: fileExtent.size() == 0 - in this case we expect a 1D array and we read the whole array. Used for field arrays. fileExtent.size()>>1 == ndims - in this case we read a scalar fileExtent.size()>>1 + 1 == ndims - in this case we read an array with the number of components > 1.
|
protected |
Reads a vtkDataArray of type T from the attributeType, dataset The array has type 'T' and 'numberOfComponents'.
We are reading fileExtent slab from the array. It returns the array or nullptr in case of an error. There are three cases for fileExtent: fileExtent.size() == 0 - in this case we expect a 1D array and we read the whole array. Used for field arrays. fileExtent.size()>>1 == ndims - in this case we read a scalar fileExtent.size()>>1 + 1 == ndims - in this case we read an array with the number of components > 1.
|
protected |
Reads a vtkDataArray of type T from the attributeType, dataset The array has type 'T' and 'numberOfComponents'.
We are reading fileExtent slab from the array. It returns the array or nullptr in case of an error. There are three cases for fileExtent: fileExtent.size() == 0 - in this case we expect a 1D array and we read the whole array. Used for field arrays. fileExtent.size()>>1 == ndims - in this case we read a scalar fileExtent.size()>>1 + 1 == ndims - in this case we read an array with the number of components > 1.
|
protected |
Reads a vtkDataArray of type T from the attributeType, dataset The array has type 'T' and 'numberOfComponents'.
We are reading fileExtent slab from the array. It returns the array or nullptr in case of an error. There are three cases for fileExtent: fileExtent.size() == 0 - in this case we expect a 1D array and we read the whole array. Used for field arrays. fileExtent.size()>>1 == ndims - in this case we read a scalar fileExtent.size()>>1 + 1 == ndims - in this case we read an array with the number of components > 1.
|
protected |
Reads a vtkDataArray of type T from the attributeType, dataset The array has type 'T' and 'numberOfComponents'.
We are reading fileExtent slab from the array. It returns the array or nullptr in case of an error. There are three cases for fileExtent: fileExtent.size() == 0 - in this case we expect a 1D array and we read the whole array. Used for field arrays. fileExtent.size()>>1 == ndims - in this case we read a scalar fileExtent.size()>>1 + 1 == ndims - in this case we read an array with the number of components > 1.
|
protected |
Builds a map between native types and GetArray routines for that type.
|
protected |
Associates a struct of three integers with HDF type.
This can be used as key in a map.