Class PlutoMapIO
Defined in File PlutoMapIO.hpp
Class Documentation
-
class PlutoMapIO
This class if responsible for the Pluto 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.
Public Functions
-
PlutoMapIO(string filename)
Opens a Pluto map file for reading and writing.
-
PlutoMapIO(string filename, const vector<float> &vertices, const vector<uint32_t> &face_ids)
Creates a Pluto map file (or truncates if the file already exists).
-
~PlutoMapIO()
Closes main groups and makes sure all buffers are flushed to the file on disc.
-
vector<float> getVertices()
Returns vertices vector.
-
vector<uint32_t> getFaceIds()
Returns face ids vector.
-
vector<float> getVertexNormals()
Returns vertex normals vector.
-
vector<uint8_t> getVertexColors()
Returns vertex colors vector.
-
vector<PlutoMapImage> getTextures()
Returns textures vector.
-
unordered_map<Vec, 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.
-
vector<PlutoMapMaterial> getMaterials()
Returns materials as PlutoMapMaterial.
-
vector<uint32_t> getMaterialFaceIndices()
Returns material <-> face indices.
-
vector<float> getVertexTextureCoords()
Returns vertex texture coordinates.
-
vector<string> getLabelGroups()
Returns all available label groups.
-
vector<string> getAllLabelsOfGroup(string groupName)
Returns all labels inside the given group.
-
vector<uint32_t> getFaceIdsOfLabel(string groupName, string labelName)
Returns face ids for the given label inside the group. E.g: label=tree_1 -> groupName=tree; labelName=1.
-
vector<float> getRoughness()
Returns the roughness as float vector.
-
vector<float> getHeightDifference()
Returns the height difference as float vector.
-
PlutoMapImage getImage(hf::Group group, string name)
Returns the image in the group, if it exists. If not an empty struct is returned.
-
hf::DataSet addVertexNormals(vector<float> &normals)
Add normals to the attributes group.
-
hf::DataSet addVertexColors(vector<uint8_t> &colors)
Add vertex colors to the attributes group.
-
void 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
-
void addMaterials(vector<PlutoMapMaterial> &materials, vector<uint32_t> &matFaceIndices)
Add materials as PlutoMapMaterial and the corresponding material <-> face indices.
-
void addVertexTextureCoords(vector<float> &coords)
Add vertex texture coordinates to the textures group.
-
void addLabel(string groupName, string labelName, 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 ‘_’.
-
template<typename BaseVecT>
void addTextureKeypointsMap(unordered_map<BaseVecT, 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’.
-
void addRoughness(vector<float> &roughness)
Adds the roughness to the attributes group.
-
void addHeightDifference(vector<float> &diff)
Adds the height difference to the attributes group.
-
void addImage(hf::Group group, 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.
-
bool 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.
- Returns:
true if removing all labels successfully.
-
void flush()
Flushes the file. All opened buffers are saved to disc.
-
PlutoMapIO(string filename)