#include <hdf5_map_io.h>
Public Member Functions | |
void | addHeightDifference (std::vector< float > &diff) |
Adds the height difference to the attributes group. More... | |
void | addImage (hf::Group group, std::string name, const uint32_t width, const uint32_t height, const uint8_t *pixelBuffer) |
Adds an image with given data set name to the given group. More... | |
void | addLabel (std::string groupName, std::string labelName, std::vector< uint32_t > &faceIds) |
Adds the label (labelName) to the label group with the given faces. E.g.: tree_1 -> groupName=tree; labelName=1; separated by the '_'. More... | |
void | addMaterials (std::vector< MapMaterial > &materials, std::vector< uint32_t > &matFaceIndices) |
Add materials as MapMaterial and the corresponding material <-> face indices. More... | |
void | addOrUpdateLabel (std::string groupName, std::string labelName, std::vector< uint32_t > &faceIds) |
Adds or updates the label (labelName) to the label group with the given faces. E.g.: tree_1 -> groupName=tree; labelName=1; separated by the '_'. More... | |
void | addRoughness (std::vector< float > &roughness) |
Adds the roughness to the attributes group. More... | |
void | addTexture (int index, uint32_t width, uint32_t height, uint8_t *data) |
void | addTextureKeypointsMap (std::unordered_map< MapVertex, std::vector< float >> &keypoints_map) |
Adds the keypoints with their corresponding positions to the attributes_group. The position is saved to the entry via an attribute called 'vector'. More... | |
hf::DataSet | addVertexColors (std::vector< uint8_t > &colors) |
Add vertex colors to the attributes group. More... | |
hf::DataSet | addVertexNormals (std::vector< float > &normals) |
Add normals to the attributes group. More... | |
void | addVertexTextureCoords (std::vector< float > &coords) |
Add vertex texture coordinates to the textures group. More... | |
void | flush () |
Flushes the file. All opened buffers are saved to disc. More... | |
std::vector< std::string > | getAllLabelsOfGroup (std::string groupName) |
Returns all labels inside the given group. More... | |
std::vector< std::string > | getCostLayers () |
returns the names of all available costlayers More... | |
std::vector< uint32_t > | getFaceIds () |
Returns face ids vector. More... | |
std::vector< uint32_t > | getFaceIdsOfLabel (std::string groupName, std::string labelName) |
Returns face ids for the given label inside the group. E.g: label=tree_1 -> groupName=tree; labelName=1. More... | |
std::unordered_map< MapVertex, std::vector< float > > | getFeatures () |
Returns an map which keys are representing the features point in space and the values are an vector of floats representing the keypoints. More... | |
std::vector< float > | getHeightDifference () |
Returns the height difference as float vector. More... | |
MapImage | getImage (hf::Group group, std::string name) |
Returns the image in the group, if it exists. If not an empty struct is returned. More... | |
std::vector< std::string > | getLabelGroups () |
Returns all available label groups. More... | |
std::vector< uint32_t > | getMaterialFaceIndices () |
Returns material <-> face indices. More... | |
std::vector< MapMaterial > | getMaterials () |
Returns materials as MapMaterial. More... | |
std::vector< float > | getRoughness () |
Returns the roughness as float vector. More... | |
std::vector< MapImage > | getTextures () |
Returns textures vector. More... | |
std::vector< uint8_t > | getVertexColors () |
Returns vertex colors vector. More... | |
std::vector< float > | getVertexCosts (std::string costlayer) |
Returns one costlayer as float vector. More... | |
std::vector< float > | getVertexNormals () |
Returns vertex normals vector. More... | |
std::vector< float > | getVertexTextureCoords () |
Returns vertex texture coordinates. More... | |
std::vector< float > | getVertices () |
Returns vertices vector. More... | |
HDF5MapIO (std::string filename) | |
Opens a map file for reading and writing. More... | |
HDF5MapIO (std::string filename, const std::vector< float > &vertices, const std::vector< uint32_t > &face_ids) | |
Creates a map file (or truncates if the file already exists). More... | |
bool | removeAllLabels () |
~HDF5MapIO () | |
Closes main groups and makes sure all buffers are flushed to the file on disc. More... | |
Private Member Functions | |
void | creatOrGetGroups () |
size_t | getSize (hf::DataSet &data_set) |
Private Attributes | |
hf::Group | m_channelsGroup |
hf::Group | m_clusterSetsGroup |
hf::File | m_file |
hf::Group | m_labelsGroup |
hf::Group | m_texturesGroup |
Static Private Attributes | |
static constexpr const char * | CHANNELS_GROUP = "/mesh/channels" |
static constexpr const char * | CLUSTERSETS_GROUP = "/mesh/clustersets" |
static constexpr const char * | LABELS_GROUP = "/mesh/labels" |
static constexpr const char * | TEXTURES_GROUP = "/mesh/textures" |
This class if responsible for the map format. It tries to abstract most if not all calls to the underlying HDF5 API and the HighFive wrapper. Furthermore it ensures the defined map format is always in place and not tinkered with.
NOTE: the map file is held open for the whole live time of this object. Thus it is possible that some data is only written to disc if the destructor is called or the program has ended. Also make sure the map file is not opened in any other way. (i.e. with the HDF5 Viewer). This will always lead to errors trying to access the file.
Definition at line 59 of file hdf5_map_io.h.
hdf5_map_io::HDF5MapIO::HDF5MapIO | ( | std::string | filename | ) |
Opens a map file for reading and writing.
Definition at line 31 of file hdf5_map_io.cpp.
hdf5_map_io::HDF5MapIO::HDF5MapIO | ( | std::string | filename, |
const std::vector< float > & | vertices, | ||
const std::vector< uint32_t > & | face_ids | ||
) |
Creates a map file (or truncates if the file already exists).
Definition at line 37 of file hdf5_map_io.cpp.
hdf5_map_io::HDF5MapIO::~HDF5MapIO | ( | ) |
Closes main groups and makes sure all buffers are flushed to the file on disc.
Definition at line 59 of file hdf5_map_io.cpp.
void hdf5_map_io::HDF5MapIO::addHeightDifference | ( | std::vector< float > & | diff | ) |
Adds the height difference to the attributes group.
Definition at line 436 of file hdf5_map_io.cpp.
void hdf5_map_io::HDF5MapIO::addImage | ( | hf::Group | group, |
std::string | name, | ||
const uint32_t | width, | ||
const uint32_t | height, | ||
const uint8_t * | pixelBuffer | ||
) |
Adds an image with given data set name to the given group.
Definition at line 442 of file hdf5_map_io.cpp.
void hdf5_map_io::HDF5MapIO::addLabel | ( | std::string | groupName, |
std::string | labelName, | ||
std::vector< uint32_t > & | faceIds | ||
) |
Adds the label (labelName) to the label group with the given faces. E.g.: tree_1 -> groupName=tree; labelName=1; separated by the '_'.
Definition at line 395 of file hdf5_map_io.cpp.
void hdf5_map_io::HDF5MapIO::addMaterials | ( | std::vector< MapMaterial > & | materials, |
std::vector< uint32_t > & | matFaceIndices | ||
) |
Add materials as MapMaterial and the corresponding material <-> face indices.
Definition at line 354 of file hdf5_map_io.cpp.
void hdf5_map_io::HDF5MapIO::addOrUpdateLabel | ( | std::string | groupName, |
std::string | labelName, | ||
std::vector< uint32_t > & | faceIds | ||
) |
Adds or updates the label (labelName) to the label group with the given faces. E.g.: tree_1 -> groupName=tree; labelName=1; separated by the '_'.
Definition at line 372 of file hdf5_map_io.cpp.
void hdf5_map_io::HDF5MapIO::addRoughness | ( | std::vector< float > & | roughness | ) |
Adds the roughness to the attributes group.
Definition at line 430 of file hdf5_map_io.cpp.
void hdf5_map_io::HDF5MapIO::addTexture | ( | int | index, |
uint32_t | width, | ||
uint32_t | height, | ||
uint8_t * | data | ||
) |
Add texture img with given index to the textures group. Texture CAN NOT be overridden
Definition at line 336 of file hdf5_map_io.cpp.
void hdf5_map_io::HDF5MapIO::addTextureKeypointsMap | ( | std::unordered_map< MapVertex, std::vector< float >> & | keypoints_map | ) |
Adds the keypoints with their corresponding positions to the attributes_group. The position is saved to the entry via an attribute called 'vector'.
Definition at line 407 of file hdf5_map_io.cpp.
hf::DataSet hdf5_map_io::HDF5MapIO::addVertexColors | ( | std::vector< uint8_t > & | colors | ) |
Add vertex colors to the attributes group.
Definition at line 328 of file hdf5_map_io.cpp.
hf::DataSet hdf5_map_io::HDF5MapIO::addVertexNormals | ( | std::vector< float > & | normals | ) |
Add normals to the attributes group.
Definition at line 319 of file hdf5_map_io.cpp.
void hdf5_map_io::HDF5MapIO::addVertexTextureCoords | ( | std::vector< float > & | coords | ) |
Add vertex texture coordinates to the textures group.
Definition at line 365 of file hdf5_map_io.cpp.
|
private |
Definition at line 8 of file hdf5_map_io.cpp.
void hdf5_map_io::HDF5MapIO::flush | ( | ) |
Flushes the file. All opened buffers are saved to disc.
Definition at line 460 of file hdf5_map_io.cpp.
std::vector< std::string > hdf5_map_io::HDF5MapIO::getAllLabelsOfGroup | ( | std::string | groupName | ) |
Returns all labels inside the given group.
Definition at line 227 of file hdf5_map_io.cpp.
std::vector< std::string > hdf5_map_io::HDF5MapIO::getCostLayers | ( | ) |
returns the names of all available costlayers
Definition at line 283 of file hdf5_map_io.cpp.
std::vector< uint32_t > hdf5_map_io::HDF5MapIO::getFaceIds | ( | ) |
Returns face ids vector.
Definition at line 91 of file hdf5_map_io.cpp.
std::vector< uint32_t > hdf5_map_io::HDF5MapIO::getFaceIdsOfLabel | ( | std::string | groupName, |
std::string | labelName | ||
) |
Returns face ids for the given label inside the group. E.g: label=tree_1 -> groupName=tree; labelName=1.
Definition at line 237 of file hdf5_map_io.cpp.
std::unordered_map< MapVertex, std::vector< float > > hdf5_map_io::HDF5MapIO::getFeatures | ( | ) |
Returns an map which keys are representing the features point in space and the values are an vector of floats representing the keypoints.
Definition at line 142 of file hdf5_map_io.cpp.
std::vector< float > hdf5_map_io::HDF5MapIO::getHeightDifference | ( | ) |
Returns the height difference as float vector.
Definition at line 263 of file hdf5_map_io.cpp.
Returns the image in the group, if it exists. If not an empty struct is returned.
Definition at line 288 of file hdf5_map_io.cpp.
std::vector< std::string > hdf5_map_io::HDF5MapIO::getLabelGroups | ( | ) |
Returns all available label groups.
Definition at line 222 of file hdf5_map_io.cpp.
std::vector< uint32_t > hdf5_map_io::HDF5MapIO::getMaterialFaceIndices | ( | ) |
Returns material <-> face indices.
Definition at line 192 of file hdf5_map_io.cpp.
std::vector< MapMaterial > hdf5_map_io::HDF5MapIO::getMaterials | ( | ) |
Returns materials as MapMaterial.
Definition at line 177 of file hdf5_map_io.cpp.
std::vector< float > hdf5_map_io::HDF5MapIO::getRoughness | ( | ) |
Returns the roughness as float vector.
Definition at line 258 of file hdf5_map_io.cpp.
|
private |
Definition at line 74 of file hdf5_map_io.cpp.
std::vector< MapImage > hdf5_map_io::HDF5MapIO::getTextures | ( | ) |
Returns textures vector.
Definition at line 125 of file hdf5_map_io.cpp.
std::vector< uint8_t > hdf5_map_io::HDF5MapIO::getVertexColors | ( | ) |
Returns vertex colors vector.
Definition at line 113 of file hdf5_map_io.cpp.
std::vector< float > hdf5_map_io::HDF5MapIO::getVertexCosts | ( | std::string | costlayer | ) |
Returns one costlayer as float vector.
Definition at line 268 of file hdf5_map_io.cpp.
std::vector< float > hdf5_map_io::HDF5MapIO::getVertexNormals | ( | ) |
Returns vertex normals vector.
Definition at line 102 of file hdf5_map_io.cpp.
std::vector< float > hdf5_map_io::HDF5MapIO::getVertexTextureCoords | ( | ) |
Returns vertex texture coordinates.
Definition at line 207 of file hdf5_map_io.cpp.
std::vector< float > hdf5_map_io::HDF5MapIO::getVertices | ( | ) |
Returns vertices vector.
Definition at line 80 of file hdf5_map_io.cpp.
bool hdf5_map_io::HDF5MapIO::removeAllLabels | ( | ) |
Removes all labels from the file.
Be careful, this does not clear up the space of the labels. Use the cli tool 'h5repack' manually to clear up all wasted space if this method was used multiple times.
Definition at line 448 of file hdf5_map_io.cpp.
|
staticconstexprprivate |
Definition at line 253 of file hdf5_map_io.h.
|
staticconstexprprivate |
Definition at line 254 of file hdf5_map_io.h.
|
staticconstexprprivate |
Definition at line 256 of file hdf5_map_io.h.
|
private |
Definition at line 259 of file hdf5_map_io.h.
|
private |
Definition at line 260 of file hdf5_map_io.h.
|
private |
Definition at line 247 of file hdf5_map_io.h.
|
private |
Definition at line 262 of file hdf5_map_io.h.
|
private |
Definition at line 261 of file hdf5_map_io.h.
|
staticconstexprprivate |
Definition at line 255 of file hdf5_map_io.h.