supereight
voxel_block_ray_iterator.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2009-2011 NVIDIA Corporation
3  * SPDX-FileCopyrightText: 2016-2019 Emanuele Vespa
4  * SPDX-FileCopyrightText: 2021 Smart Robotics Lab, Imperial College London, Technical University of Munich
5  * SPDX-FileCopyrightText: 2021 Nils Funk
6  * SPDX-FileCopyrightText: 2021 Sotiris Papatheodorou
7  * SPDX-License-Identifier: BSD-3-Clause
8  */
9 
10 #ifndef SE_VOXEL_BLOCK_RAY_ITERATOR_HPP
11 #define SE_VOXEL_BLOCK_RAY_ITERATOR_HPP
12 
13 #include "se/map/octree/octree.hpp"
14 
15 #define CAST_STACK_DEPTH 23
16 
17 namespace se {
18 
19 
20 
21 template<typename MapT>
23  typedef typename MapT::OctreeType::NodeType NodeType;
24  typedef typename MapT::OctreeType::BlockType BlockType;
25 
26  public:
27  VoxelBlockRayIterator(const MapT& map,
28  const Eigen::Vector3f& ray_origin_M,
29  const Eigen::Vector3f& ray_dir_M,
30  const float near_plane,
31  const float far_plane);
32 
38  BlockType* next();
39 
45  float tmin() const;
46 
52  float tmax() const;
53 
63  float tcmin() const;
64 
74  float tcmax() const;
75 
76 
77  private:
78  struct StackEntry {
79  int scale;
80  NodeType* parent;
81  float t_max;
82  };
83 
84 
85  enum STATE { INIT, ADVANCE, FINISHED };
86 
87 
88  MapT& map_;
89  const typename MapT::OctreeType& octree_;
90  Eigen::Vector3f ray_origin_M_;
91  Eigen::Vector3f ray_dir_M_;
92  Eigen::Vector3f pos_;
93  Eigen::Vector3f t_coef_;
94  Eigen::Vector3f t_bias_;
95  Eigen::Vector3f t_corner_;
96  StackEntry stack_[CAST_STACK_DEPTH];
97  NodeType* parent_ptr_;
98  se::OctantBase* child_ptr_;
99  int idx_;
100  int scale_;
101  float scaling_;
102  int min_scale_;
103  int octant_mask_;
104  float scale_exp2_;
105  float t_min_;
106  float t_min_init_;
107  float t_max_;
108  float t_max_init_;
109  float tc_max_;
110  float h_;
111  STATE state_;
112 
113 
117  static inline int floatAsInt(const float value)
118  {
119  union float_as_int {
120  float f;
121  int i;
122  };
123 
124  float_as_int u;
125  u.f = value;
126  return u.i;
127  }
128 
129 
133  static inline float intAsFloat(const int value)
134  {
135  union int_as_float {
136  int i;
137  float f;
138  };
139 
140  int_as_float u;
141  u.i = value;
142  return u.f;
143  }
144 
147  inline void advance_ray();
148 
152  inline void descend();
153 };
154 
155 
156 
157 } // namespace se
158 
159 
160 
161 #include "impl/voxel_block_ray_iterator_impl.hpp"
162 
163 
164 
165 #endif // SE_VOXEL_BLOCK_RAY_ITERATOR_HPP
#define CAST_STACK_DEPTH
Definition: voxel_block_ray_iterator.hpp:15
float tcmax() const
The distance along the ray until the current se::VoxelBlock is exited.
float tcmin() const
The distance along the ray until the current se::VoxelBlock is entered.
VoxelBlockRayIterator(const MapT &map, const Eigen::Vector3f &ray_origin_M, const Eigen::Vector3f &ray_dir_M, const float near_plane, const float far_plane)
Definition: voxel_block_ray_iterator.hpp:22
This class only helps to dynamic cast the octant to the right type and builds the base of nodes and b...
Definition: octant.hpp:24
BlockType * next()
Return a pointer to the next se::VoxelBlock along the ray.
float tmin() const
The distance along the ray until the octree is entered.
float tmax() const
The distance along the ray until the octree is exited.
Helper wrapper to allocate and de-allocate octants in the octree.
Definition: colour_utils.hpp:17
static const std::vector< Eigen::Vector3f, Eigen::aligned_allocator< Eigen::Vector3f > > scale
The colours used for the various integration scales.
Definition: colour_utils.hpp:22