supereight
visitor.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2016-2019 Emanuele Vespa
3  * SPDX-FileCopyrightText: 2019-2023 Smart Robotics Lab, Imperial College London, Technical University of Munich
4  * SPDX-FileCopyrightText: 2019-2023 Nils Funk
5  * SPDX-FileCopyrightText: 2021-2023 Sotiris Papatheodorou
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef SE_VISITOR_HPP
10 #define SE_VISITOR_HPP
11 
12 #include <optional>
13 
14 #include "octree.hpp"
15 #include "se/map/data.hpp"
18 
22 namespace se {
23 namespace visitor {
24 
25 
26 
28 
40 template<typename OctreeT>
41 inline typename OctreeT::DataType getData(const OctreeT& octree,
42  const Eigen::Vector3i& voxel_coord);
43 
58 template<typename OctreeT, typename BlockT>
59 inline typename OctreeT::DataType
60 getData(const OctreeT& octree, BlockT* block_ptr, const Eigen::Vector3i& voxel_coord);
61 
62 
63 
65 
78 template<typename OctreeT>
79 inline typename std::enable_if_t<OctreeT::res_ == se::Res::Multi, typename OctreeT::DataType>
80 getData(const OctreeT& octree,
81  const Eigen::Vector3i& voxel_coord,
82  const int scale_desired,
83  int& scale_returned);
84 
100 template<typename OctreeT, typename BlockT>
101 inline typename std::enable_if_t<OctreeT::res_ == se::Res::Multi, typename OctreeT::DataType>
102 getData(const OctreeT& octree,
103  BlockT* block_ptr,
104  const Eigen::Vector3i& voxel_coord,
105  const int scale_desired,
106  int& scale_returned);
107 
117 template<typename OctreeT>
118 inline typename std::enable_if_t<OctreeT::DataType::fld_ == se::Field::Occupancy,
119  typename OctreeT::DataType>
120 getMaxData(const OctreeT& octree, const Eigen::Vector3i& voxel_coord, const int scale_desired);
121 
122 // TODO: Reduce getField functions for single and multi-res to one
123 
125 
136 template<typename OctreeT>
137 inline std::optional<se::field_t> getField(const OctreeT& octree,
138  const Eigen::Vector3i& voxel_coord);
139 
153 template<typename OctreeT, typename BlockT>
154 inline std::optional<se::field_t>
155 getField(const OctreeT& octree, BlockT* block_ptr, const Eigen::Vector3i& voxel_coord);
156 
157 
158 
160 
173 template<typename OctreeT>
174 inline typename std::enable_if_t<OctreeT::res_ == se::Res::Multi, std::optional<se::field_t>>
175 getField(const OctreeT& octree,
176  const Eigen::Vector3i& voxel_coord,
177  const int scale_desired,
178  int& scale_returned);
179 
195 template<typename OctreeT, typename BlockT>
196 inline typename std::enable_if_t<OctreeT::res_ == se::Res::Multi, std::optional<se::field_t>>
197 getField(const OctreeT& octree,
198  BlockT* block_ptr,
199  const Eigen::Vector3i& voxel_coord,
200  const int scale_desired,
201  int& scale_returned);
202 
203 
204 
206 
217 template<typename OctreeT>
218 inline typename std::enable_if_t<OctreeT::res_ == se::Res::Single, std::optional<se::field_t>>
219 getFieldInterp(const OctreeT& octree, const Eigen::Vector3f& voxel_coord_f);
220 
221 
222 
224 
236 template<typename OctreeT>
237 inline typename std::enable_if_t<OctreeT::res_ == se::Res::Multi, std::optional<se::field_t>>
238 getFieldInterp(const OctreeT& octree, const Eigen::Vector3f& voxel_coord_f);
239 
252 template<typename OctreeT>
253 inline typename std::enable_if_t<OctreeT::res_ == se::Res::Multi, std::optional<se::field_t>>
254 getFieldInterp(const OctreeT& octree, const Eigen::Vector3f& voxel_coord_f, int& scale_returned);
255 
269 template<typename OctreeT>
270 inline
271  typename std::enable_if_t<(OctreeT::fld_ == se::Field::TSDF && OctreeT::res_ == se::Res::Multi),
272  std::optional<se::field_t>>
273  getFieldInterp(const OctreeT& octree,
274  const Eigen::Vector3f& voxel_coord_f,
275  const int scale_desired,
276  int& scale_returned);
277 
291 template<typename OctreeT>
292 inline typename std::enable_if_t<OctreeT::fld_ == se::Field::Occupancy
293  && OctreeT::res_ == se::Res::Multi,
294  std::optional<se::field_t>>
295 getFieldInterp(const OctreeT& octree,
296  const Eigen::Vector3f& voxel_coord_f,
297  const int scale_desired,
298  int& scale_returned);
299 
300 
301 
303 
314 template<typename OctreeT>
315 inline typename std::enable_if_t<OctreeT::res_ == se::Res::Single, std::optional<se::field_vec_t>>
316 getFieldGrad(const OctreeT& octree, const Eigen::Vector3f& voxel_coord_f);
317 
318 
319 
321 
332 template<typename OctreeT>
333 inline typename std::enable_if_t<OctreeT::res_ == se::Res::Multi, std::optional<se::field_vec_t>>
334 getFieldGrad(const OctreeT& octree, const Eigen::Vector3f& voxel_coord_f);
335 
347 template<typename OctreeT>
348 inline typename std::enable_if_t<OctreeT::res_ == se::Res::Multi, std::optional<se::field_vec_t>>
349 getFieldGrad(const OctreeT& octree, const Eigen::Vector3f& voxel_coord_f, int& scale_returned);
350 
363 template<typename OctreeT>
364 inline typename std::enable_if_t<OctreeT::res_ == se::Res::Multi, std::optional<se::field_vec_t>>
365 getFieldGrad(const OctreeT& octree,
366  const Eigen::Vector3f& voxel_coord_f,
367  const int scale_desired,
368  int& scale_returned);
369 
370 } // namespace visitor
371 } // namespace se
372 
373 #include "impl/visitor_impl.hpp"
374 
375 #endif // SE_VISITOR_HPP
std::optional< se::field_t > getField(const OctreeT &octree, const Eigen::Vector3i &voxel_coord)
Single/Multi-res get field functions.
OctreeT::DataType getData(const OctreeT &octree, const Eigen::Vector3i &voxel_coord)
Single/multi-res get data functions.
std::enable_if_t<(OctreeT::fld_==se::Field::TSDF &&OctreeT::res_==se::Res::Multi), std::optional< se::field_t > > getFieldInterp(const OctreeT &octree, const Eigen::Vector3f &voxel_coord_f, const int scale_desired, int &scale_returned)
Get the interplated field value for a given coordinate [float voxel coordinates] and desired scale...
Definition: visitor.hpp:273
std::enable_if_t< OctreeT::DataType::fld_==se::Field::Occupancy, typename OctreeT::DataType > getMaxData(const OctreeT &octree, const Eigen::Vector3i &voxel_coord, const int scale_desired)
Get the max occupancy data at a given scale.
std::enable_if_t< OctreeT::res_==se::Res::Single, std::optional< se::field_vec_t > > getFieldGrad(const OctreeT &octree, const Eigen::Vector3f &voxel_coord_f)
Single-res get gradient functions.
Helper wrapper to allocate and de-allocate octants in the octree.
Definition: colour_utils.hpp:17