supereight
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
14
15#define CAST_STACK_DEPTH 23
16
17namespace se {
18
19
20
21template<typename MapT>
23 typedef typename MapT::OctreeType::NodeType NodeType;
24 typedef typename MapT::OctreeType::BlockType BlockType;
25
26 public:
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 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
77
78 private:
79 struct StackEntry {
80 int scale;
81 NodeType* parent;
82 float t_max;
83 };
84
85
86 enum STATE { INIT, ADVANCE, FINISHED };
87
88
89 MapT& map_;
90 const typename MapT::OctreeType& octree_;
91 Eigen::Vector3f ray_origin_M_;
92 Eigen::Vector3f ray_dir_M_;
93 Eigen::Vector3f pos_;
94 Eigen::Vector3f t_coef_;
95 Eigen::Vector3f t_bias_;
96 Eigen::Vector3f t_corner_;
97 StackEntry stack_[CAST_STACK_DEPTH];
98 NodeType* parent_ptr_;
99 se::OctantBase* child_ptr_;
100 int idx_;
101 int scale_;
102 float scaling_;
103 int min_scale_;
104 int octant_mask_;
105 float scale_exp2_;
106 float t_min_;
107 float t_min_init_;
108 float t_max_;
109 float t_max_init_;
110 float tc_max_;
111 float h_;
112 STATE state_;
113
114
118 static inline int floatAsInt(const float value)
119 {
120 union float_as_int {
121 float f;
122 int i;
123 };
124
125 float_as_int u;
126 u.f = value;
127 return u.i;
128 }
129
130
134 static inline float intAsFloat(const int value)
135 {
136 union int_as_float {
137 int i;
138 float f;
139 };
140
141 int_as_float u;
142 u.i = value;
143 return u.f;
144 }
145
148 inline void advance_ray();
149
153 inline void descend();
154};
155
156
157
158} // namespace se
159
160
161
162#include "impl/voxel_block_ray_iterator_impl.hpp"
163
164
165
166#endif // SE_VOXEL_BLOCK_RAY_ITERATOR_HPP
Definition image.hpp:19
The base class of all octants (se::Node and se::Block) in an se::Octree.
Definition octant.hpp:19
Definition voxel_block_ray_iterator.hpp:22
float tmin() const
The distance along the ray until the octree 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)
float tcmax() const
The distance along the ray until the current se::VoxelBlock is exited.
BlockType * next()
Return a pointer to the next se::VoxelBlock along the ray.
float tcmin() const
The distance along the ray until the current se::VoxelBlock 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 bounded_vector.hpp:14
#define CAST_STACK_DEPTH
Definition voxel_block_ray_iterator.hpp:15