VTK  9.4.20241123
Classes | Functions | Variables
vtkHDFUtilities Namespace Reference

Common utility variables and functions for reader and writer of vtkHDF. More...

Classes

struct  TemporalGeometryOffsets
 
struct  TransientGeometryOffsets
 

Functions

static constexpr int GetNumberOfAttributeTypes ()
 
static constexpr int GetNumberOfDataArrayTypes ()
 
VTKIOHDF_EXPORT void MakeObjectNameValid (std::string &objectName)
 
VTKIOHDF_EXPORT hid_t getH5TypeFromVtkType (int dataType)
 
VTKIOHDF_EXPORT bool Open (const char *fileName, hid_t &fileID)
 Open a VTK HDF file and checks if it is valid.
 
template<typename T >
VTKIOHDF_EXPORT hid_t TemplateTypeToHdfNativeType ()
 Convert C++ template type T to HDF5 native type this can be constexpr in C++17 standard.
 
template<typename T >
VTKIOHDF_EXPORT bool GetAttribute (hid_t group, const char *attributeName, size_t numberOfElements, T *value)
 Reads an attribute from the group passed to it.
 
VTKIOHDF_EXPORT std::size_t GetNumberOfSteps (hid_t groupID)
 Read the number of steps of an HDF group.
 
VTKIOHDF_EXPORT std::vector< hsize_t > GetDimensions (hid_t fileID, const char *datasetName)
 Returns the dimensions of a HDF dataset of a file.
 
VTKIOHDF_EXPORT bool RetrieveHDFInformation (hid_t &fileID, hid_t &groupID, const std::string &rootName, std::array< int, 2 > &version, int &dataSetType, int &numberOfPieces, std::array< hid_t, 3 > &attributeDataGroup)
 Initialize meta information of the file.
 
VTKIOHDF_EXPORT herr_t FileInfoCallBack (hid_t loc_id, const char *name, const H5L_info_t *info, void *opdata)
 Convenient callback method to retrieve a name when calling a H5Giterate()
 
VTKIOHDF_EXPORT std::vector< std::string > GetArrayNames (const std::array< hid_t, 3 > &attributeDataGroup, int attributeType)
 Returns the names of arrays for 'attributeType' (point or cell).
 
VTKIOHDF_EXPORT std::vector< std::string > GetOrderedChildrenOfGroup (hid_t groupID, const std::string &path)
 Return the name of all children of an HDF group given its path.
 
VTKIOHDF_EXPORT 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'.
 
VTKIOHDF_EXPORT std::vector< vtkIdTypeGetMetadata (hid_t group, const char *name, hsize_t size, hsize_t offset)
 Reads a 1D metadata array in a DataArray or a vector of vtkIdType.
 
VTKIOHDF_EXPORT std::array< vtkIdType, 2 > GetFieldArraySize (hid_t group, vtkIdType step, std::string name)
 Return the field array size (components, tuples) for the HDF group.
 
VTKIOHDF_EXPORT vtkIdType GetArrayOffset (hid_t group, vtkIdType step, int attributeType, std::string name)
 Methods to query for array offsets for the HDF group when steps are present.
 
VTKIOHDF_EXPORT vtkAbstractArrayNewFieldArray (const std::array< hid_t, 3 > &attributeDataGroup, const char *name, vtkIdType offset, vtkIdType size, vtkIdType dimMaxSize)
 Reads and returns a new vtkAbstractArray.
 
VTKIOHDF_EXPORT vtkStringArrayNewStringArray (hid_t dataset, std::vector< hsize_t > dims, std::vector< hsize_t > fileExtent)
 
VTKIOHDF_EXPORT vtkDataArrayNewArrayForGroup (hid_t dataset, hid_t nativeType, const std::vector< hsize_t > &dims, const std::vector< hsize_t > &parameterExtent)
 Reads a vtkDataArray of type T from the attributeType, dataset The array has type 'T' and 'numberOfComponents'.
 
VTKIOHDF_EXPORT vtkDataArrayNewArrayForGroup (hid_t group, const char *name, const std::vector< hsize_t > &parameterExtent)
 Reads a vtkDataArray of type T from the attributeType, dataset The array has type 'T' and 'numberOfComponents'.
 

Variables

const std::string VTKHDF_ROOT_PATH = "/VTKHDF"
 
constexpr std::size_t NUM_POLY_DATA_TOPOS = 4
 
const std::vector< std::string > POLY_DATA_TOPOS { "Vertices", "Lines", "Polygons", "Strips" }
 
constexpr int GEOMETRY_ATTRIBUTE_TAG = -42
 

Detailed Description

Common utility variables and functions for reader and writer of vtkHDF.

Function Documentation

◆ GetNumberOfAttributeTypes()

static constexpr int vtkHDFUtilities::GetNumberOfAttributeTypes ( )
staticconstexpr

Definition at line 62 of file vtkHDFUtilities.h.

◆ GetNumberOfDataArrayTypes()

static constexpr int vtkHDFUtilities::GetNumberOfDataArrayTypes ( )
staticconstexpr

Definition at line 70 of file vtkHDFUtilities.h.

◆ MakeObjectNameValid()

VTKIOHDF_EXPORT void vtkHDFUtilities::MakeObjectNameValid ( std::string &  objectName)

◆ getH5TypeFromVtkType()

VTKIOHDF_EXPORT hid_t vtkHDFUtilities::getH5TypeFromVtkType ( int  dataType)

◆ Open()

VTKIOHDF_EXPORT bool vtkHDFUtilities::Open ( const char *  fileName,
hid_t fileID 
)

Open a VTK HDF file and checks if it is valid.

On succeed fileID is set to a valid hid.

◆ TemplateTypeToHdfNativeType()

template<typename T >
VTKIOHDF_EXPORT hid_t vtkHDFUtilities::TemplateTypeToHdfNativeType ( )

Convert C++ template type T to HDF5 native type this can be constexpr in C++17 standard.

◆ GetAttribute()

template<typename T >
VTKIOHDF_EXPORT bool vtkHDFUtilities::GetAttribute ( hid_t  group,
const char *  attributeName,
size_t  numberOfElements,
T *  value 
)

Reads an attribute from the group passed to it.

◆ GetNumberOfSteps()

VTKIOHDF_EXPORT std::size_t vtkHDFUtilities::GetNumberOfSteps ( hid_t  groupID)

Read the number of steps of an HDF group.

◆ GetDimensions()

VTKIOHDF_EXPORT std::vector< hsize_t > vtkHDFUtilities::GetDimensions ( hid_t  fileID,
const char *  datasetName 
)

Returns the dimensions of a HDF dataset of a file.

◆ RetrieveHDFInformation()

VTKIOHDF_EXPORT bool vtkHDFUtilities::RetrieveHDFInformation ( hid_t fileID,
hid_t groupID,
const std::string &  rootName,
std::array< int, 2 > &  version,
int &  dataSetType,
int &  numberOfPieces,
std::array< hid_t, 3 > &  attributeDataGroup 
)

Initialize meta information of the file.

◆ FileInfoCallBack()

VTKIOHDF_EXPORT herr_t vtkHDFUtilities::FileInfoCallBack ( hid_t  loc_id,
const char *  name,
const H5L_info_t *  info,
void *  opdata 
)

Convenient callback method to retrieve a name when calling a H5Giterate()

◆ GetArrayNames()

VTKIOHDF_EXPORT std::vector< std::string > vtkHDFUtilities::GetArrayNames ( const std::array< hid_t, 3 > &  attributeDataGroup,
int  attributeType 
)

Returns the names of arrays for 'attributeType' (point or cell).

◆ GetOrderedChildrenOfGroup()

VTKIOHDF_EXPORT std::vector< std::string > vtkHDFUtilities::GetOrderedChildrenOfGroup ( hid_t  groupID,
const std::string &  path 
)

Return the name of all children of an HDF group given its path.

◆ OpenDataSet()

VTKIOHDF_EXPORT hid_t vtkHDFUtilities::OpenDataSet ( hid_t  group,
const char *  name,
hid_t nativeType,
std::vector< hsize_t > &  dims 
)

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.

◆ NewArrayForGroup() [1/2]

VTKIOHDF_EXPORT vtkDataArray * vtkHDFUtilities::NewArrayForGroup ( hid_t  dataset,
hid_t  nativeType,
const std::vector< hsize_t > &  dims,
const std::vector< hsize_t > &  parameterExtent 
)

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.

◆ NewArrayForGroup() [2/2]

VTKIOHDF_EXPORT vtkDataArray * vtkHDFUtilities::NewArrayForGroup ( hid_t  group,
const char *  name,
const std::vector< hsize_t > &  parameterExtent 
)

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.

◆ GetMetadata()

VTKIOHDF_EXPORT std::vector< vtkIdType > vtkHDFUtilities::GetMetadata ( hid_t  group,
const char *  name,
hsize_t  size,
hsize_t  offset 
)

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.

◆ GetFieldArraySize()

VTKIOHDF_EXPORT std::array< vtkIdType, 2 > vtkHDFUtilities::GetFieldArraySize ( hid_t  group,
vtkIdType  step,
std::string  name 
)

Return the field array size (components, tuples) for the HDF group.

By default it returns {-1,1} which means to have as many components as necessary and one tuple per step.

◆ GetArrayOffset()

VTKIOHDF_EXPORT vtkIdType vtkHDFUtilities::GetArrayOffset ( hid_t  group,
vtkIdType  step,
int  attributeType,
std::string  name 
)

Methods to query for array offsets for the HDF group when steps are present.

◆ NewFieldArray()

VTKIOHDF_EXPORT vtkAbstractArray * vtkHDFUtilities::NewFieldArray ( const std::array< hid_t, 3 > &  attributeDataGroup,
const char *  name,
vtkIdType  offset,
vtkIdType  size,
vtkIdType  dimMaxSize 
)

Reads and returns a new vtkAbstractArray.

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.

◆ NewStringArray()

VTKIOHDF_EXPORT vtkStringArray * vtkHDFUtilities::NewStringArray ( hid_t  dataset,
std::vector< hsize_t >  dims,
std::vector< hsize_t >  fileExtent 
)

Variable Documentation

◆ VTKHDF_ROOT_PATH

const std::string vtkHDFUtilities::VTKHDF_ROOT_PATH = "/VTKHDF"

Definition at line 39 of file vtkHDFUtilities.h.

◆ NUM_POLY_DATA_TOPOS

constexpr std::size_t vtkHDFUtilities::NUM_POLY_DATA_TOPOS = 4
constexpr

Definition at line 44 of file vtkHDFUtilities.h.

◆ POLY_DATA_TOPOS

const std::vector<std::string> vtkHDFUtilities::POLY_DATA_TOPOS { "Vertices", "Lines", "Polygons", "Strips" }

Definition at line 50 of file vtkHDFUtilities.h.

◆ GEOMETRY_ATTRIBUTE_TAG

constexpr int vtkHDFUtilities::GEOMETRY_ATTRIBUTE_TAG = -42
constexpr

Definition at line 56 of file vtkHDFUtilities.h.