Workspace 6.21.5
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Hdf5MeshSerializer Class Reference

Helper class for writing a single Mesh::MeshModelInterface to a HDF5 format. More...

#include <HDF5/hdf5meshserializer.h>

Public Types

using int_type = Mesh::MeshModelInterface::int_type
 
typedef Mesh::MeshModelInterface::size_type size_type
 
using StateTypeMap = QMap< QString, const DataExecution::DataFactory * >
 
enum  UnsupportedStateControl : bool { AbortOnUnsupportedState = false , SkipUnsupportedState = true }
 

Public Member Functions

 Hdf5MeshSerializer (hid_t &file, const QString &meshName)
 
bool readBounds (Mesh::BoundingBoxMinimal &bounds) const
 
bool readElementIndices (int lod, Hdf5MeshElementsInterface &elements) const
 
bool readElementState (int lod, const QString &stateName, Hdf5MeshElementsInterface &elements) const
 
bool readElementStateNames (int lod, const Mesh::ElementType::Type &type, QStringList &stateNames) const
 
bool readElementStateTypes (int lod, const Mesh::ElementType::Type &type, StateTypeMap &states) const
 
bool readElementTypes (int lod, QList< const Mesh::ElementType::Type * > &types) const
 
bool readLodDistance (int lod, double &dist) const
 
bool readNodePositions (int lod, Hdf5MeshNodesInterface &nodes) const
 
bool readNodeState (int lod, const QString &stateName, Hdf5MeshNodesInterface &nodes) const
 
bool readNodeStateNames (int lod, QStringList &names) const
 
bool readNodeStateTypes (int lod, StateTypeMap &states) const
 
bool readNumLods (size_type &n) const
 
bool readNumNodes (int lod, size_type &n) const
 
bool readVersion (size_type &version) const
 
bool writeBounds (const Mesh::BoundingBoxMinimal &bounds)
 
bool writeCompleteMeshLod (int lod, const Mesh::MeshModelInterface &meshModel, double lodDistance, UnsupportedStateControl control=AbortOnUnsupportedState)
 
bool writeElementIndices (int lod, const Mesh::MeshElementsInterface &elements)
 
bool writeElementState (int lod, const Mesh::ElementStateHandle &state, const Mesh::MeshElementsInterface &elements, UnsupportedStateControl control=AbortOnUnsupportedState)
 
bool writeLodDistance (int lod, double distance)
 
bool writeNodePositions (int lod, const Mesh::HierarchicalReferenceMeshNodesInterface &nodes)
 
bool writeNodePositions (int lod, const Mesh::MeshNodesInterface &nodes)
 
bool writeNodeState (int lod, const Mesh::NodeStateHandle &state, const Mesh::MeshNodesInterface &nodes, UnsupportedStateControl control=AbortOnUnsupportedState)
 
bool writeVersion ()
 

Static Public Member Functions

static QStringList readMeshNames (hid_t &file)
 

Static Public Attributes

static const size_t MAX_NAME_LENGTH = 1024
 
static const hid_t STRING_DATATYPE = H5Tcopy(H5T_C_S1)
 
static const int STRING_DATATYPE_LENGTH = 50
 
static const Mesh::MeshModelInterface::size_type VERSION = 1
 

Detailed Description

See also
CSIRO::Mesh::Hdf5SceneSerializer

The format is capable of storing multiple meshes in the same file, and multiple levels of detail for each mesh. The Hdf5MeshSerializer provides methods for serialising mesh data for each LOD associated with the mesh.

The Workspace Binary Hdf5 Mesh v1 Format is as follows:

a = attribute g = group d = dataset

g: root/ a: format_version (int) g: meshes/ g: mesh_name/ a: bounds_min (double[3]) a: bounds_max (double[3]) g: lods/ g: lod_num/ a: distance (double) a: node_count (uint32) d: positions (double) // for lods 1+, this will be a link to lods/0/positions if dataset is hierarchical g: node_states/ // for lods 1+, this will be a link to lods/0/node_states if dataset is hierarchical g: state_name/ a: type (int) d: state_data (double / int / double[3]) g: element_type/ d: indices (uint32) g: element_states/ g: state_name/ a: type (int) d: state_data (double / int / double[3]) g: instances/ (see Hdf5SceneSerializer) ...

Member Typedef Documentation

◆ int_type

◆ size_type

◆ StateTypeMap

using StateTypeMap = QMap<QString, const DataExecution::DataFactory*>

Member Enumeration Documentation

◆ UnsupportedStateControl

Enumerator
AbortOnUnsupportedState 
SkipUnsupportedState 

Constructor & Destructor Documentation

◆ Hdf5MeshSerializer()

Hdf5MeshSerializer ( hid_t &  file,
const QString &  meshName 
)
Parameters
fileThe Hdf5 file to read from or write to.
meshNameThe name of the mesh to read / write.

Constructs a new Hdf5MeshSerializer object for reading / writing to HDF5 mesh models.

Member Function Documentation

◆ readBounds()

bool readBounds ( Mesh::BoundingBoxMinimal bounds) const
Parameters
bounds(out) The bounds data to be read from the file. A succesful readBounds call will overwrite any data in the passed in bounds parameter.
Returns
true if the data was able to be read successfully. False if a HDF5 error occurs.

◆ readElementIndices()

bool readElementIndices ( int  lod,
Hdf5MeshElementsInterface elements 
) const
Parameters
lodThe level of detail from which to read the distance data.
elements(out) MeshElementsInterface into which element index data will be read.
Returns
true if the data was able to be read successfully. False if a HDF5 error occurs.

◆ readElementState()

bool readElementState ( int  lod,
const QString &  stateName,
Hdf5MeshElementsInterface elements 
) const
Parameters
lodThe level of detail from which to read the distance data.
stateNameThe name of the state to read.
elements(out) MeshElementsInterface into which state data will be read.
Returns
true if the data was able to be read successfully. False if a HDF5 error occurs.

◆ readElementStateNames()

bool readElementStateNames ( int  lod,
const Mesh::ElementType::Type type,
QStringList stateNames 
) const
Parameters
lodThe level of detail from which to read the distance data.
typeThe element type from which to retrieve state names.
stateNames(out) QStringList into which state names will be read.
Returns
true if the data was able to be read successfully. False if a HDF5 error occurs.

◆ readElementStateTypes()

bool readElementStateTypes ( int  lod,
const Mesh::ElementType::Type type,
StateTypeMap states 
) const
Parameters
lodThe level of detail from which to read the distance data.
typeElement type for which state data will be read.
states(out) StateTypeMap into which state names and associated state types will be read.
Returns
true if the data was able to be read successfully. False if a HDF5 error occurs.

◆ readElementTypes()

bool readElementTypes ( int  lod,
QList< const Mesh::ElementType::Type * > &  types 
) const
Parameters
lodThe level of detail from which to read the distance data.
types(out) QList of element types into which the list of element types available in this LOD will be read.
Returns
true if the data was able to be read successfully. False if a HDF5 error occurs.

◆ readLodDistance()

bool readLodDistance ( int  lod,
double &  dist 
) const
Parameters
lodThe level of detail from which to read the distance data.
dist(out) The distance data will be stored here upon successful execution of the method.
Returns
true if the data was able to be read successfully. False if a HDF5 error occurs.

◆ readMeshNames()

QStringList readMeshNames ( hid_t &  file)
static
Parameters
fileFile to read from
Returns
QStringList containing all of the mesh names available in the specified file.

◆ readNodePositions()

bool readNodePositions ( int  lod,
Hdf5MeshNodesInterface nodes 
) const
Parameters
lodThe level of detail from which to read the distance data.
nodes(out) MeshNodesInterface into which position data will be read.
Returns
true if the data was able to be read successfully. False if a HDF5 error occurs.

◆ readNodeState()

bool readNodeState ( int  lod,
const QString &  stateName,
Hdf5MeshNodesInterface nodes 
) const
Parameters
lodThe level of detail from which to read the distance data.
stateNameThe name of the state to read.
nodes(out) MeshNodesInterface into which state data will be read.
Returns
true if the data was able to be read successfully. False if a HDF5 error occurs.

◆ readNodeStateNames()

bool readNodeStateNames ( int  lod,
QStringList stateNames 
) const
Parameters
lodThe level of detail from which to read the distance data.
stateNames(out) QStringList into which node state names will be read.
Returns
true if the data was able to be read successfully. False if a HDF5 error occurs.

◆ readNodeStateTypes()

bool readNodeStateTypes ( int  lod,
StateTypeMap states 
) const
Parameters
lodThe level of detail from which to read the distance data.
states(out) StateTypeMap into which state names and types will be read.
Returns
true if the data was able to be read successfully. False if a HDF5 error occurs.

◆ readNumLods()

bool readNumLods ( size_type n) const
Parameters
n(out) The number of LODs that exist in the file for this mesh.
Returns
true if the data was able to be read successfully. False if a HDF5 error occurs.

◆ readNumNodes()

bool readNumNodes ( int  lod,
size_type n 
) const
Parameters
lodThe level of detail from which to read the distance data.
n(out) The number of nodes that exist for the specific LOD.
Returns
true if the data was able to be read successfully. False if a HDF5 error occurs.

◆ readVersion()

bool readVersion ( size_type version) const
Parameters
version(out) Version data read from file.
Returns
true if the version was able to be read successfully. False if a HDF5 error occurs.

◆ writeBounds()

bool writeBounds ( const Mesh::BoundingBoxMinimal bounds)
Parameters
boundsBounding box of the mesh containing its min and max extents.
Returns
true if the bounds were able to be written to the HDF5 file successfully, false if a HDF5 error occurs, such as not being able to open the file for writing.

◆ writeCompleteMeshLod()

bool writeCompleteMeshLod ( int  lod,
const Mesh::MeshModelInterface meshModel,
double  lodDistance,
UnsupportedStateControl  control = AbortOnUnsupportedState 
)
Parameters
lodThe level of detail of the mesh to write to.
meshModelThe mesh data to write to file.
lodDistanceThe distance to associate with this LOD.
controlSkip or abort on the states that are not supported, i.e. cannot be written.
Returns
true if all components of the mesh (with supported states, if control=SkipUnsupportedState) were able to be written successfully. False if a HDF5 error occurs.

Writes a complete mesh to a HDF5 file, storing its nodes, elements and state data as a specific level of detail (LOD) associated with the named mesh.

Note
If the particularly MeshModelInterface implementation is HierarchicalReferenceMeshModelInterface, then the serializer will optimise the output format taking its hierarchical nature into account.

◆ writeElementIndices()

bool writeElementIndices ( int  lod,
const Mesh::MeshElementsInterface elements 
)
Parameters
lodThe level of detail of the mesh to write to.
elementsThe elements to write to the specified level of detail.
Returns
true if the elements were able to be written successfully. False if a HDF5 error occurs.

◆ writeElementState()

bool writeElementState ( int  lod,
const Mesh::ElementStateHandle state,
const Mesh::MeshElementsInterface elements,
UnsupportedStateControl  control = AbortOnUnsupportedState 
)
Parameters
lodThe level of detail of the mesh to write to.
stateThe handle of the state to write.
elementsThe elements to write to the specified level of detail.
controlSkip or abort on the states that are not supported, i.e. cannot be written.
Returns
true if the state was written to file successfully or control is SkipUnsupportedState and the state is not supported. False if a HDF5 error occurs.

◆ writeLodDistance()

bool writeLodDistance ( int  lod,
double  distance 
)
Parameters
lodThe level of detail of the mesh to write to.
distanceThe distance associated with the specified level of detail.
Returns
true if the distance associated with the specified LOD was able to be written to the HDF5 file successfully. False if a HDF5 error occurs, such as being unable to write to the file.

◆ writeNodePositions() [1/2]

bool writeNodePositions ( int  lod,
const Mesh::HierarchicalReferenceMeshNodesInterface nodes 
)
Parameters
lodThe level of detail of the mesh to write to.
nodesThe hierarchy of nodes to write to the specified level of detail.
Returns
true if the node positions were able to be written successfully. False if a HDF5 error occurs.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This overload of the writeNodePositions method is to cater for hierarchical mesh model structures. In this case, the Hdf5MeshSerializer knows to avoid duplicating the node data for LODS 1+ and instead simply link to LOD 0's data, since it is essentially sorted hierarchically.

◆ writeNodePositions() [2/2]

bool writeNodePositions ( int  lod,
const Mesh::MeshNodesInterface nodes 
)
Parameters
lodThe level of detail of the mesh to write to.
nodesThe nodes containing the position data to write to the HDF5 file.
Returns
true if the node positions were able to be written successfully. False if a HDF5 error occurs.

◆ writeNodeState()

bool writeNodeState ( int  lod,
const Mesh::NodeStateHandle state,
const Mesh::MeshNodesInterface nodes,
UnsupportedStateControl  control = AbortOnUnsupportedState 
)
Parameters
lodThe level of detail of the mesh to write to.
stateThe handle of the state to write.
nodesThe nodes to write to the specified level of detail.
controlSkip or abort on the states that are not supported, i.e. cannot be written.
Returns
true if the state was written to file successfully or control is SkipUnsupportedState and the state is not supported. False if a HDF5 error occurs.

◆ writeVersion()

bool writeVersion ( )
Returns
true if the version number is written to file successfully. False if a HDF5 error occurs, such as not being able to write to file.

Member Data Documentation

◆ MAX_NAME_LENGTH

const size_t MAX_NAME_LENGTH = 1024
static

Maximum name length

◆ STRING_DATATYPE

const hid_t STRING_DATATYPE = H5Tcopy(H5T_C_S1)
static

String datatype used to store state names and other string identifiers. Length is quite short so as to minimise the storage used.

◆ STRING_DATATYPE_LENGTH

const int STRING_DATATYPE_LENGTH = 50
static

String datatype length

◆ VERSION

const MeshModelInterface::size_type VERSION = 1
static

Version number of the file. Should be incremented when significant changes are made.