HDF5Kernel.hpp
Go to the documentation of this file.
1 #ifndef HDF5KERNEL_HPP
2 #define HDF5KERNEL_HPP
3 
4 #include <hdf5_hl.h>
5 #include <highfive/H5DataSet.hpp>
7 #include <highfive/H5File.hpp>
8 
9 #include "lvr2/types/Channel.hpp"
14 
15 #include <type_traits>
16 #include <tuple>
17 namespace lvr2
18 {
19 class HDF5Kernel : public FileKernel
20 {
21 public:
22 
23  HDF5Kernel() = delete;
24  HDF5Kernel(const std::string& hdf5file);
26 
27  virtual void saveMeshBuffer(
28  const std::string& group,
29  const std::string& container,
30  const MeshBufferPtr& buffer) const;
31 
32  virtual void savePointBuffer(
33  const std::string& group,
34  const std::string& container,
35  const PointBufferPtr& buffer) const;
36 
37  virtual void saveImage(
38  const std::string& group,
39  const std::string& container,
40  const cv::Mat& image) const;
41 
42  virtual void saveMetaYAML(
43  const std::string& group,
44  const std::string& metaName,
45  const YAML::Node& node) const;
46 
48  const std::string& group,
49  const std::string container) const;
50 
52  const std::string& group,
53  const std::string& container) const;
54 
55  virtual boost::optional<cv::Mat> loadImage(
56  const std::string& group,
57  const std::string& container) const;
58 
59  virtual void loadMetaYAML(
60  const std::string& group,
61  const std::string& container,
62  YAML::Node& node) const;
63 
64  virtual ucharArr loadUCharArray(
65  const std::string& group,
66  const std::string& container,
67  std::vector<size_t> &dims) const;
68 
69  virtual floatArr loadFloatArray(
70  const std::string& group,
71  const std::string& container,
72  std::vector<size_t> &dims) const;
73 
74  virtual doubleArr loadDoubleArray(
75  const std::string& group,
76  const std::string& container,
77  std::vector<size_t> &dims) const;
78 
79  virtual void saveFloatArray(
80  const std::string& groupName,
81  const std::string& datasetName,
82  const std::vector<size_t>& dimensions,
83  const boost::shared_array<float>& data) const;
84 
85  virtual void saveDoubleArray(
86  const std::string& groupName, const std::string& datasetName,
87  const std::vector<size_t>& dimensions,
88  const boost::shared_array<double>& data) const;
89 
90  virtual void saveUCharArray(
91  const std::string& groupName, const std::string& datasetName,
92  const std::vector<size_t>& dimensions,
93  const boost::shared_array<unsigned char>& data) const;
94 
95  virtual bool exists(const std::string& group) const;
96  virtual bool exists(const std::string& group, const std::string& container) const;
97 
98  virtual void subGroupNames(const std::string& group, std::vector<string>& subGroupNames) const;
99  virtual void subGroupNames(const std::string& group, const std::regex& filter, std::vector<string>& subGroupNames) const;
100 
101  template<typename T>
102  boost::shared_array<T> loadArray(
103  const std::string& groupName,
104  const std::string& datasetName,
105  size_t& size) const;
106 
107  template<typename T>
108  boost::shared_array<T> loadArray(
109  const std::string& groupName,
110  const std::string& datasetName,
111  std::vector<size_t>& dim) const;
112 
113  template<typename T>
114  void saveArray(
115  const std::string& groupName,
116  const std::string& datasetName,
117  const size_t& size,
118  const boost::shared_array<T> data) const;
119 
120  template<typename T>
121  void saveArray(
122  const std::string& groupName,
123  const std::string& datasetName,
124  const vector<size_t>& dim,
125  const boost::shared_array<T> data) const;
126 
127  template<typename T>
128  ChannelOptional<T> loadChannelOptional(HighFive::Group& g, const std::string& datasetName) const;
129 
130  template<typename T>
131  ChannelOptional<T> loadChannelOptional(const std::string& groupName, const std::string& datasetName) const;
132 
133  // template<typename T>
134  // ChannelOptional<T> load(
135  // HighFive::Group& g,
136  // std::string datasetName
137  // ) const;
138 
139  template<typename T>
140  void save(std::string groupName,
141  std::string datasetName,
142  const Channel<T>& channel) const;
143 
144  template<typename T>
145  void save(HighFive::Group& g,
146  std::string datasetName,
147  const Channel<T>& channel) const;
148 
149  template<typename T>
150  void save(HighFive::Group& g,
151  std::string datasetName,
152  const Channel<T>& channel,
153  std::vector<hsize_t>& chunkSize) const;
154 
162  bool getChannel(const std::string group, const std::string name, FloatChannelOptional& channel) const;
163 
171  bool getChannel(const std::string group, const std::string name, IndexChannelOptional& channel) const;
172 
180  bool getChannel(const std::string group, const std::string name, UCharChannelOptional& channel) const;
181 
182  template <typename T>
183  bool getChannel(const std::string group, const std::string name, boost::optional<AttributeChannel<T>>& channel) const;
184 
185  template <typename T>
186  bool addChannel(const std::string group, const std::string name, const AttributeChannel<T>& channel) const;
187 
195  bool addChannel(const std::string group, const std::string name, const FloatChannel& channel) const;
196 
204  bool addChannel(const std::string group, const std::string name, const IndexChannel& channel) const;
205 
213  bool addChannel(const std::string group, const std::string name, const UCharChannel& channel) const;
214 
215  template<typename ...Tp>
216  void save(std::string groupName, std::string datasetName, const VariantChannel<Tp...>& vchannel) const;
217 
218  template<typename ...Tp>
219  void save(HighFive::Group& group, std::string datasetName, const VariantChannel<Tp...>& vchannel) const;
220 
221  template<typename VariantChannelT>
222  boost::optional<VariantChannelT> load(std::string groupName, std::string datasetName) const;
223 
224  template<typename VariantChannelT>
225  boost::optional<VariantChannelT> load(HighFive::Group& group, std::string datasetName) const;
226 
227  template<typename VariantChannelT>
228  boost::optional<VariantChannelT> loadVariantChannel(std::string groupName, std::string datasetName) const;
229 
230  template<typename VariantChannelT>
231  boost::optional<VariantChannelT> loadDynamic(HighFive::DataType dtype,
232  HighFive::Group& group,
233  std::string name) const;
234 
235  template<typename ...Tp>
236  void saveDynamic(HighFive::Group& group,
237  std::string datasetName,
238  const VariantChannel<Tp...>& vchannel
239  ) const;
240 
241  template<typename T>
242  cv::Mat createMat(const std::vector<size_t>& dims) const;
243 
244  void loadMetaData(const YAML::Node& node);
245 
246  std::shared_ptr<HighFive::File> m_hdf5File;
247 
249 
250 };
251 
252 using HDF5KernelPtr = std::shared_ptr<HDF5Kernel>;
253 
254 } // namespace lvr2
255 
256 #include "lvr2/io/descriptions/HDF5Kernel.tcc"
257 
258 #endif
boost::optional< VariantChannelT > loadDynamic(HighFive::DataType dtype, HighFive::Group &group, std::string name) const
virtual void saveMeshBuffer(const std::string &group, const std::string &container, const MeshBufferPtr &buffer) const
Definition: HDF5Kernel.cpp:15
cv::Mat createMat(const std::vector< size_t > &dims) const
std::shared_ptr< MeshBuffer > MeshBufferPtr
Definition: MeshBuffer.hpp:217
boost::shared_array< T > loadArray(const std::string &groupName, const std::string &datasetName, size_t &size) const
virtual doubleArr loadDoubleArray(const std::string &group, const std::string &container, std::vector< size_t > &dims) const
Definition: HDF5Kernel.cpp:430
void loadMetaData(const YAML::Node &node)
Definition: HDF5Kernel.cpp:358
virtual void saveMetaYAML(const std::string &group, const std::string &metaName, const YAML::Node &node) const
Definition: HDF5Kernel.cpp:178
std::shared_ptr< HighFive::File > m_hdf5File
Definition: HDF5Kernel.hpp:246
virtual void saveDoubleArray(const std::string &groupName, const std::string &datasetName, const std::vector< size_t > &dimensions, const boost::shared_array< double > &data) const
Definition: HDF5Kernel.cpp:447
virtual void saveImage(const std::string &group, const std::string &container, const cv::Mat &image) const
Definition: HDF5Kernel.cpp:37
boost::optional< VariantChannelT > loadVariantChannel(std::string groupName, std::string datasetName) const
boost::shared_array< double > doubleArr
Definition: DataStruct.hpp:134
virtual void savePointBuffer(const std::string &group, const std::string &container, const PointBufferPtr &buffer) const
Definition: HDF5Kernel.cpp:23
bool getChannel(const std::string group, const std::string name, FloatChannelOptional &channel) const
getChannel Reads a float attribute channel in the given group with the given name ...
Definition: HDF5Kernel.cpp:486
boost::shared_array< unsigned char > ucharArr
Definition: DataStruct.hpp:137
boost::optional< VariantChannelT > load(std::string groupName, std::string datasetName) const
virtual void subGroupNames(const std::string &group, std::vector< string > &subGroupNames) const
Definition: HDF5Kernel.cpp:474
UCharChannel::Optional UCharChannelOptional
Definition: Channel.hpp:96
std::shared_ptr< PointBuffer > PointBufferPtr
virtual PointBufferPtr loadPointBuffer(const std::string &group, const std::string &container) const
Definition: HDF5Kernel.cpp:231
ChannelOptional< T > loadChannelOptional(HighFive::Group &g, const std::string &datasetName) const
virtual boost::optional< cv::Mat > loadImage(const std::string &group, const std::string &container) const
Definition: HDF5Kernel.cpp:282
HDF5Kernel()=delete
virtual void loadMetaYAML(const std::string &group, const std::string &container, YAML::Node &node) const
Definition: HDF5Kernel.cpp:363
virtual bool exists(const std::string &group) const
Definition: HDF5Kernel.cpp:463
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
HDF5 Data Type.
Definition: H5DataType.hpp:21
void filter(lvr2::PointBufferPtr &cloud, lvr2::indexArray &inlier, size_t j)
FloatChannel::Optional FloatChannelOptional
Definition: Channel.hpp:88
virtual floatArr loadFloatArray(const std::string &group, const std::string &container, std::vector< size_t > &dims) const
Definition: HDF5Kernel.cpp:422
virtual ucharArr loadUCharArray(const std::string &group, const std::string &container, std::vector< size_t > &dims) const
Definition: HDF5Kernel.cpp:414
virtual void saveFloatArray(const std::string &groupName, const std::string &datasetName, const std::vector< size_t > &dimensions, const boost::shared_array< float > &data) const
Definition: HDF5Kernel.cpp:438
virtual MeshBufferPtr loadMeshBuffer(const std::string &group, const std::string container) const
Definition: HDF5Kernel.cpp:224
IndexChannel::Optional IndexChannelOptional
Definition: Channel.hpp:100
std::shared_ptr< HDF5Kernel > HDF5KernelPtr
Definition: HDF5Kernel.hpp:252
bool addChannel(const std::string group, const std::string name, const AttributeChannel< T > &channel) const
virtual void saveUCharArray(const std::string &groupName, const std::string &datasetName, const std::vector< size_t > &dimensions, const boost::shared_array< unsigned char > &data) const
Definition: HDF5Kernel.cpp:455
void saveArray(const std::string &groupName, const std::string &datasetName, const size_t &size, const boost::shared_array< T > data) const
HDF5MetaDescriptionBase * m_metaDescription
Definition: HDF5Kernel.hpp:248
typename Channel< T >::Optional ChannelOptional
Definition: Channel.hpp:85
void save(std::string groupName, std::string datasetName, const Channel< T > &channel) const
void saveDynamic(HighFive::Group &group, std::string datasetName, const VariantChannel< Tp... > &vchannel) const


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:06