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_
hf::Group m_labelsGroup
Definition: PlutoMapIO.hpp:279
vector< uint8_t > data
Definition: PlutoMapIO.hpp:66
hf::Group m_clusterSetsGroup
Definition: PlutoMapIO.hpp:277
hf::Group m_attributesGroup
Definition: PlutoMapIO.hpp:276
File class.
Definition: H5File.hpp:25
hf::Group m_geometryGroup
Definition: PlutoMapIO.hpp:275
create an HDF5 DataType from a C++ type
Definition: H5DataType.hpp:41
hf::Group m_texturesGroup
Definition: PlutoMapIO.hpp:278
BaseVector< float > Vec


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 Mon Feb 28 2022 22:46:08