PlutoMapIO.hpp
Go to the documentation of this file.
1 
33 #ifndef __LVR2_PLUTOMAPIO_HPP_
34 #define __LVR2_PLUTOMAPIO_HPP_
35 
36 
37 #include <string>
38 #include <vector>
39 #include <iostream>
40 #include <unordered_map>
41 
42 #include <H5Tpublic.h>
43 #include <highfive/H5File.hpp>
44 
46 
47 namespace hf = HighFive;
48 
49 using std::string;
50 using std::vector;
51 using std::unordered_map;
52 
53 namespace lvr2
54 {
55 
56 using Vec = BaseVector<float>;
57 
61 struct PlutoMapImage {
62  string name;
63  uint32_t width;
64  uint32_t height;
65  uint32_t channels;
66  vector<uint8_t> data;
67 };
68 
75  int32_t textureIndex;
76  uint8_t r;
77  uint8_t g;
78  uint8_t b;
79 };
80 
91 {
92 public:
96  PlutoMapIO(string filename);
97 
101  PlutoMapIO(
102  string filename,
103  const vector<float>& vertices,
104  const vector<uint32_t>& face_ids
105  );
106 
110  ~PlutoMapIO();
111 
115  vector<float> getVertices();
116 
120  vector<uint32_t> getFaceIds();
121 
125  vector<float> getVertexNormals();
126 
130  vector<uint8_t> getVertexColors();
131 
135  // TODO: replace PlutoMapImage with lvr2::Texture?
136  vector<PlutoMapImage> getTextures();
137 
142  unordered_map<Vec, vector<float>> getFeatures();
143 
147  vector<PlutoMapMaterial> getMaterials();
148 
152  vector<uint32_t> getMaterialFaceIndices();
153 
157  vector<float> getVertexTextureCoords();
158 
162  vector<string> getLabelGroups();
163 
167  vector<string> getAllLabelsOfGroup(string groupName);
168 
173  vector<uint32_t> getFaceIdsOfLabel(string groupName, string labelName);
174 
178  vector<float> getRoughness();
179 
183  vector<float> getHeightDifference();
184 
188  PlutoMapImage getImage(hf::Group group, string name);
189 
193  hf::DataSet addVertexNormals(vector<float>& normals);
194 
198  hf::DataSet addVertexColors(vector<uint8_t>& colors);
199 
203  void addTexture(int index, uint32_t width, uint32_t height, uint8_t* data);
204 
208  void addMaterials(vector<PlutoMapMaterial>& materials, vector<uint32_t>& matFaceIndices);
209 
213  void addVertexTextureCoords(vector<float>& coords);
214 
219  void addLabel(string groupName, string labelName, vector<uint32_t>& faceIds);
220 
225  template<typename BaseVecT>
226  void addTextureKeypointsMap(unordered_map<BaseVecT, std::vector<float>>& keypoints_map);
227 
231  void addRoughness(vector<float>& roughness);
232 
236  void addHeightDifference(vector<float>& diff);
237 
241  void addImage(hf::Group group,
242  string name,
243  const uint32_t width,
244  const uint32_t height,
245  const uint8_t* pixelBuffer
246  );
247 
256  bool removeAllLabels();
257 
261  void flush();
262 
263 private:
265 
266  // group names
267 
268  static constexpr const char* GEOMETRY_GROUP = "/geometry";
269  static constexpr const char* ATTRIBUTES_GROUP = "/attributes";
270  static constexpr const char* CLUSTERSETS_GROUP = "/clustersets";
271  static constexpr const char* TEXTURES_GROUP = "/textures";
272  static constexpr const char* LABELS_GROUP = "/labels";
273 
274  // main groups for reference
280 };
281 } // namespace lvr2
282 
283 
284 namespace HighFive {
285 
289 template <>
291 {
292  hid_t materialHid = H5Tcreate(H5T_COMPOUND, sizeof(lvr2::PlutoMapMaterial));
293 
294  H5Tinsert(materialHid, "textureIndex", offsetof(lvr2::PlutoMapMaterial, textureIndex), H5T_NATIVE_INT);
295  H5Tinsert(materialHid, "r", offsetof(lvr2::PlutoMapMaterial, r), H5T_NATIVE_UCHAR);
296  H5Tinsert(materialHid, "g", offsetof(lvr2::PlutoMapMaterial, g), H5T_NATIVE_UCHAR);
297  H5Tinsert(materialHid, "b", offsetof(lvr2::PlutoMapMaterial, b), H5T_NATIVE_UCHAR);
298 
299  _hid = H5Tcopy(materialHid);
300 }
301 
302 }
303 
304 #include "PlutoMapIO.tcc"
305 
306 #endif // __LVR2_PLUTOMAPIO_HPP_
lvr2::PlutoMapIO::m_texturesGroup
hf::Group m_texturesGroup
Definition: PlutoMapIO.hpp:278
BaseVector.hpp
lvr2::PlutoMapImage::data
vector< uint8_t > data
Definition: PlutoMapIO.hpp:66
lvr2::PlutoMapIO::addVertexNormals
hf::DataSet addVertexNormals(vector< float > &normals)
Add normals to the attributes group.
lvr2::PlutoMapMaterial
Definition: PlutoMapIO.hpp:74
lvr2::PlutoMapIO::getMaterials
vector< PlutoMapMaterial > getMaterials()
Returns materials as PlutoMapMaterial.
lvr2::PlutoMapIO::ATTRIBUTES_GROUP
static constexpr const char * ATTRIBUTES_GROUP
Definition: PlutoMapIO.hpp:269
lvr2::PlutoMapIO::LABELS_GROUP
static constexpr const char * LABELS_GROUP
Definition: PlutoMapIO.hpp:272
lvr2::PlutoMapIO::TEXTURES_GROUP
static constexpr const char * TEXTURES_GROUP
Definition: PlutoMapIO.hpp:271
H5File.hpp
lvr2::PlutoMapIO::addHeightDifference
void addHeightDifference(vector< float > &diff)
Adds the height difference to the attributes group.
lvr2::PlutoMapIO::CLUSTERSETS_GROUP
static constexpr const char * CLUSTERSETS_GROUP
Definition: PlutoMapIO.hpp:270
lvr2::PlutoMapImage::width
uint32_t width
Definition: PlutoMapIO.hpp:63
lvr2::PlutoMapMaterial::textureIndex
int32_t textureIndex
Definition: PlutoMapIO.hpp:75
lvr2::PlutoMapIO::getMaterialFaceIndices
vector< uint32_t > getMaterialFaceIndices()
Returns material <-> face indices.
lvr2::PlutoMapImage::name
string name
Definition: PlutoMapIO.hpp:62
lvr2::PlutoMapImage
Definition: PlutoMapIO.hpp:61
lvr2::PlutoMapIO::getFeatures
unordered_map< Vec, vector< float > > getFeatures()
Returns an map which keys are representing the features point in space and the values are an vector o...
lvr2::PlutoMapIO::addVertexColors
hf::DataSet addVertexColors(vector< uint8_t > &colors)
Add vertex colors to the attributes group.
lvr2::PlutoMapIO::getRoughness
vector< float > getRoughness()
Returns the roughness as float vector.
lvr2::PlutoMapImage::channels
uint32_t channels
Definition: PlutoMapIO.hpp:65
lvr2::PlutoMapMaterial::b
uint8_t b
Definition: PlutoMapIO.hpp:78
lvr2::PlutoMapIO::addTexture
void addTexture(int index, uint32_t width, uint32_t height, uint8_t *data)
lvr2::PlutoMapIO::m_attributesGroup
hf::Group m_attributesGroup
Definition: PlutoMapIO.hpp:276
lvr2::PlutoMapIO::addLabel
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; l...
lvr2::PlutoMapMaterial::r
uint8_t r
Definition: PlutoMapIO.hpp:76
lvr2::PlutoMapMaterial::g
uint8_t g
Definition: PlutoMapIO.hpp:77
HighFive::AtomicType::AtomicType
AtomicType()
lvr2::PlutoMapIO::addVertexTextureCoords
void addVertexTextureCoords(vector< float > &coords)
Add vertex texture coordinates to the textures group.
lvr2::PlutoMapIO::getHeightDifference
vector< float > getHeightDifference()
Returns the height difference as float vector.
lvr2::PlutoMapIO::m_labelsGroup
hf::Group m_labelsGroup
Definition: PlutoMapIO.hpp:279
lvr2::PlutoMapIO::getVertices
vector< float > getVertices()
Returns vertices vector.
lvr2::PlutoMapIO::addTextureKeypointsMap
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 ...
HighFive::Group
Definition: H5Group.hpp:20
scripts.normalize_multiple.filename
filename
Definition: normalize_multiple.py:60
lvr2::PlutoMapIO::m_geometryGroup
hf::Group m_geometryGroup
Definition: PlutoMapIO.hpp:275
Vec
BaseVector< float > Vec
Definition: src/tools/lvr2_cuda_normals/Main.cpp:57
lvr2::PlutoMapIO::addMaterials
void addMaterials(vector< PlutoMapMaterial > &materials, vector< uint32_t > &matFaceIndices)
Add materials as PlutoMapMaterial and the corresponding material <-> face indices.
lvr2::PlutoMapIO::getVertexNormals
vector< float > getVertexNormals()
Returns vertex normals vector.
lvr2::PlutoMapIO::m_file
hf::File m_file
Definition: PlutoMapIO.hpp:264
HighFive::File
File class.
Definition: H5File.hpp:25
scripts.create_png.colors
colors
Definition: create_png.py:41
lvr2::PlutoMapIO::getTextures
vector< PlutoMapImage > getTextures()
Returns textures vector.
lvr2::PlutoMapIO::getFaceIds
vector< uint32_t > getFaceIds()
Returns face ids vector.
lvr2::PlutoMapIO::GEOMETRY_GROUP
static constexpr const char * GEOMETRY_GROUP
Definition: PlutoMapIO.hpp:268
lvr2::PlutoMapIO::addRoughness
void addRoughness(vector< float > &roughness)
Adds the roughness to the attributes group.
lvr2::PlutoMapIO::~PlutoMapIO
~PlutoMapIO()
Closes main groups and makes sure all buffers are flushed to the file on disc.
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::PlutoMapIO::getVertexTextureCoords
vector< float > getVertexTextureCoords()
Returns vertex texture coordinates.
lvr2::PlutoMapIO::flush
void flush()
Flushes the file. All opened buffers are saved to disc.
lvr2::PlutoMapIO::PlutoMapIO
PlutoMapIO(string filename)
Opens a Pluto map file for reading and writing.
lvr2::PlutoMapIO::getVertexColors
vector< uint8_t > getVertexColors()
Returns vertex colors vector.
lvr2::PlutoMapIO::addImage
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.
lvr2::PlutoMapIO::getImage
PlutoMapImage getImage(hf::Group group, string name)
Returns the image in the group, if it exists. If not an empty struct is returned.
lvr2::PlutoMapIO
Definition: PlutoMapIO.hpp:90
lvr2::PlutoMapIO::getLabelGroups
vector< string > getLabelGroups()
Returns all available label groups.
HighFive::DataSet
Definition: H5DataSet.hpp:27
lvr2::PlutoMapImage::height
uint32_t height
Definition: PlutoMapIO.hpp:64
lvr2::PlutoMapIO::getFaceIdsOfLabel
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...
lvr2::PlutoMapIO::getAllLabelsOfGroup
vector< string > getAllLabelsOfGroup(string groupName)
Returns all labels inside the given group.
HighFive
Definition: H5Annotate_traits.hpp:14
lvr2::PlutoMapIO::removeAllLabels
bool removeAllLabels()
lvr2::PlutoMapIO::m_clusterSetsGroup
hf::Group m_clusterSetsGroup
Definition: PlutoMapIO.hpp:277


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:24