|
Field3D
|
Classes | |
| class | Hdf5Util::H5Base |
| Base class for all scoped Hdf5 util classes. More... | |
| class | Hdf5Util::H5ScopedAget_space |
| Scoped object - opens an attribute data space on creation and closes it on destruction. More... | |
| class | Hdf5Util::H5ScopedAget_type |
| Scoped object - opens an attribute data type on creation and closes it on destruction. More... | |
| class | Hdf5Util::H5ScopedAopen |
| Scoped object - Opens attribute by name and closes it on destruction. More... | |
| class | Hdf5Util::H5ScopedAopenIdx |
| Scoped object - Opens attribute by index and closes it on destruction. More... | |
| class | Hdf5Util::H5ScopedDcreate |
| Scoped object - creates a dataset on creation and closes it on destruction. More... | |
| class | Hdf5Util::H5ScopedDget_space |
| Scoped object - opens a dataset on creation and closes it on destruction. More... | |
| class | Hdf5Util::H5ScopedDget_type |
| Scoped object - opens a dataset on creation and closes it on destruction. More... | |
| class | Hdf5Util::H5ScopedDopen |
| Scoped object - opens a dataset on creation and closes it on destruction. More... | |
| class | Hdf5Util::H5ScopedGcreate |
| Scoped object - creates a group on creation and closes it on destruction. More... | |
| class | Hdf5Util::H5ScopedGopen |
| Scoped object - opens a group on creation and closes it on destruction. More... | |
| class | Hdf5Util::H5ScopedScreate |
| Scoped object - creates a dataspace on creation and closes it on destruction. More... | |
| class | Hdf5Util::H5ScopedTget_native_type |
| Scoped object - opens an native type id on creation and closes it on destruction. More... | |
Namespaces | |
| namespace | Hdf5Util |
Contains utility functions and classes for Hdf5 files. | |
Functions | |
| bool | Hdf5Util::checkHdf5Gzip () |
| Checks whether gzip is available in the current hdf5 library. | |
Read/write simple data to hdf5 location | |
| template<typename T > | |
| void | Hdf5Util::writeSimpleData (hid_t location, const std::string &name, const std::vector< T > &data) |
| Writes a simple linear data set to the given location. | |
| template<typename T > | |
| void | Hdf5Util::readSimpleData (hid_t location, const std::string &name, std::vector< T > &data) |
| Reads a simple linear data set from the given location. | |
Attribute reading | |
| bool | Hdf5Util::readAttribute (hid_t location, const std::string &attrName, std::string &value) |
| Reads a string attribute. | |
| bool | Hdf5Util::readAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, int &value) |
| Reads an int attribute of arbitrary size. | |
| bool | Hdf5Util::readAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, float &value) |
| Reads a float attribute of arbitrary size. | |
| bool | Hdf5Util::readAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, double &value) |
| Reads a double attribute of arbitrary size. | |
| bool | Hdf5Util::readAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, int &value) |
| Reads a int attribute of arbitrary size and rank. | |
| bool | Hdf5Util::readAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, float &value) |
| Reads a float attribute of arbitrary size and rank. | |
| bool | Hdf5Util::readAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, double &value) |
| Reads a double attribute of arbitrary size and rank. | |
Attribute writing | |
| bool | Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, const std::string &value) |
| Writes a string attribute. | |
| bool | Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, const int &value) |
| Writes an int attribute of arbitrary size. | |
| bool | Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, const float &value) |
| Writes a float attribute of arbitrary size. | |
| bool | Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, unsigned int attrSize, const double &value) |
| Writes a double attribute of arbitrary size. | |
| bool | Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, const int &value) |
| Writes a float attribute of arbitrary size and rank. | |
| bool | Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, const float &value) |
| Writes a float attribute of arbitrary size and rank. | |
| bool | Hdf5Util::writeAttribute (hid_t location, const std::string &attrName, std::vector< unsigned int > &attrSize, const double &value) |
| Writes a double attribute of arbitrary size and rank. | |
| void Hdf5Util::writeSimpleData | ( | hid_t | location, |
| const std::string & | name, | ||
| const std::vector< T > & | data | ||
| ) |
Writes a simple linear data set to the given location.
Definition at line 530 of file Hdf5Util.h.
References Hdf5Util::H5Base::id().
{
using namespace Exc;
// Calculate the total number of entries. This factors in that
// V3f uses 3 components per value, etc.
hsize_t totalSize[1];
int components = FieldTraits<T>::dataDims();
totalSize[0] = data.size() * components;
// Get the internal data type
hid_t type = DataTypeTraits<T>::h5type();
H5ScopedScreate dataSpace(H5S_SIMPLE);
if (dataSpace.id() < 0)
throw WriteSimpleDataException("Couldn't create data space");
H5Sset_extent_simple(dataSpace.id(), 1, totalSize, NULL);
H5ScopedDcreate dataSet(location, name.c_str(), type, dataSpace.id(),
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
if (dataSet.id() < 0)
throw WriteSimpleDataException("Couldn't create data set");
hid_t err = H5Dwrite(dataSet.id(), type, H5S_ALL, H5S_ALL,
H5P_DEFAULT, &data[0]);
if (err < 0)
throw WriteSimpleDataException("Couldn't write data");
}
| void Hdf5Util::readSimpleData | ( | hid_t | location, |
| const std::string & | name, | ||
| std::vector< T > & | data | ||
| ) |
Reads a simple linear data set from the given location.
Definition at line 567 of file Hdf5Util.h.
{
using namespace Exc;
int components = FieldTraits<T>::dataDims();
hsize_t dims[1];
H5ScopedDopen dataSet(location, name.c_str(), H5P_DEFAULT);
if (dataSet.id() < 0)
throw OpenDataSetException("Couldn't open data set: " + name);
H5ScopedDget_space dataSpace(dataSet.id());
H5ScopedDget_type dataType(dataSet.id());
H5Sget_simple_extent_dims(dataSpace.id(), dims, NULL);
if (dataSpace.id() < 0)
throw GetDataSpaceException("Couldn't get data space");
if (dataType.id() < 0)
throw GetDataTypeException("Couldn't get data type");
int reportedSize = dims[0] / components;
// Resize target
data.clear();
data.resize(reportedSize);
// Get the internal data type
hid_t type = DataTypeTraits<T>::h5type();
if (H5Dread(dataSet.id(), type, H5S_ALL, H5S_ALL,
H5P_DEFAULT, &data[0]) < 0) {
throw Hdf5DataReadException("Couldn't read simple data");
}
}
| bool Hdf5Util::readAttribute | ( | hid_t | location, |
| const std::string & | attrName, | ||
| std::string & | value | ||
| ) |
Reads a string attribute.
Referenced by Field3DInputFile::parseLayer(), InputFile::parseLayers(), SparseFieldIO::read(), MACFieldIO::read(), FrustumFieldMappingIO::read(), MatrixFieldMappingIO::read(), NullFieldMappingIO::read(), DenseFieldIO::read(), SparseFieldIO::readData(), readFieldMapping(), Field3DInputFile::readGroupMembership(), Field3DInputFile::readLayer(), Field3DInputFile::readMetadata(), and Field3DInputFile::readProxyLayer().
| bool Hdf5Util::readAttribute | ( | hid_t | location, |
| const std::string & | attrName, | ||
| unsigned int | attrSize, | ||
| int & | value | ||
| ) |
Reads an int attribute of arbitrary size.
| bool Hdf5Util::readAttribute | ( | hid_t | location, |
| const std::string & | attrName, | ||
| unsigned int | attrSize, | ||
| float & | value | ||
| ) |
Reads a float attribute of arbitrary size.
| bool Hdf5Util::readAttribute | ( | hid_t | location, |
| const std::string & | attrName, | ||
| unsigned int | attrSize, | ||
| double & | value | ||
| ) |
Reads a double attribute of arbitrary size.
| bool Hdf5Util::readAttribute | ( | hid_t | location, |
| const std::string & | attrName, | ||
| std::vector< unsigned int > & | attrSize, | ||
| int & | value | ||
| ) |
Reads a int attribute of arbitrary size and rank.
| bool Hdf5Util::readAttribute | ( | hid_t | location, |
| const std::string & | attrName, | ||
| std::vector< unsigned int > & | attrSize, | ||
| float & | value | ||
| ) |
Reads a float attribute of arbitrary size and rank.
| bool Hdf5Util::readAttribute | ( | hid_t | location, |
| const std::string & | attrName, | ||
| std::vector< unsigned int > & | attrSize, | ||
| double & | value | ||
| ) |
Reads a double attribute of arbitrary size and rank.
| bool Hdf5Util::writeAttribute | ( | hid_t | location, |
| const std::string & | attrName, | ||
| const std::string & | value | ||
| ) |
Writes a string attribute.
Referenced by Field3DOutputFile::createNewPartition(), SparseFieldIO::write(), MACFieldIO::write(), FrustumFieldMappingIO::write(), MatrixFieldMappingIO::write(), NullFieldMappingIO::write(), DenseFieldIO::write(), writeField(), writeFieldMapping(), Field3DOutputFile::writeGroupMembership(), SparseFieldIO::writeInternal(), MACFieldIO::writeInternal(), DenseFieldIO::writeInternal(), Field3DOutputFile::writeLayer(), and Field3DOutputFile::writeMetadata().
| bool Hdf5Util::writeAttribute | ( | hid_t | location, |
| const std::string & | attrName, | ||
| unsigned int | attrSize, | ||
| const int & | value | ||
| ) |
Writes an int attribute of arbitrary size.
| bool Hdf5Util::writeAttribute | ( | hid_t | location, |
| const std::string & | attrName, | ||
| unsigned int | attrSize, | ||
| const float & | value | ||
| ) |
Writes a float attribute of arbitrary size.
| bool Hdf5Util::writeAttribute | ( | hid_t | location, |
| const std::string & | attrName, | ||
| unsigned int | attrSize, | ||
| const double & | value | ||
| ) |
Writes a double attribute of arbitrary size.
| bool Hdf5Util::writeAttribute | ( | hid_t | location, |
| const std::string & | attrName, | ||
| std::vector< unsigned int > & | attrSize, | ||
| const int & | value | ||
| ) |
Writes a float attribute of arbitrary size and rank.
| bool Hdf5Util::writeAttribute | ( | hid_t | location, |
| const std::string & | attrName, | ||
| std::vector< unsigned int > & | attrSize, | ||
| const float & | value | ||
| ) |
Writes a float attribute of arbitrary size and rank.
| bool Hdf5Util::writeAttribute | ( | hid_t | location, |
| const std::string & | attrName, | ||
| std::vector< unsigned int > & | attrSize, | ||
| const double & | value | ||
| ) |
Writes a double attribute of arbitrary size and rank.
| bool Hdf5Util::checkHdf5Gzip | ( | ) |
Checks whether gzip is available in the current hdf5 library.
Definition at line 680 of file Hdf5Util.cpp.
Referenced by MACFieldIO::writeData(), SparseFieldIO::writeInternal(), and DenseFieldIO::writeInternal().
{
htri_t avail = H5Zfilter_avail(H5Z_FILTER_DEFLATE);
if (!avail)
return false;
unsigned int filter_info;
herr_t status = H5Zget_filter_info (H5Z_FILTER_DEFLATE, &filter_info);
if (status < 0)
return false;
if (!(filter_info & H5Z_FILTER_CONFIG_ENCODE_ENABLED) ||
!(filter_info & H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
return false;
}
return true;
}