UFO
1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
height.hpp
1
42
#ifndef UFO_CONTAINER_TREE_PREDICATE_HEIGHT_HPP
43
#define UFO_CONTAINER_TREE_PREDICATE_HEIGHT_HPP
44
45
// UFO
46
#include <ufo/container/tree/predicate/filter.hpp>
47
#include <ufo/container/tree/predicate/predicate_interval.hpp>
48
49
namespace
ufo::pred
50
{
51
namespace
detail
52
{
53
struct
Height
{
54
using
value_type = int;
55
};
56
}
// namespace detail
57
58
template
<
bool
Negated = false>
59
using
Height
=
PredicateInterval<detail::Height, Negated>
;
60
61
static
constexpr
inline
Height<false>
const
height;
62
63
template
<
bool
Negated>
64
struct
Filter
<
Height
<Negated>> {
65
using
Pred
=
Height<Negated>
;
66
67
template
<
class
Tree>
68
static
constexpr
void
init(
Pred
&,
Tree
const
&)
noexcept
69
{
70
}
71
72
template
<
class
Value>
73
[[nodiscard]]
static
constexpr
bool
returnableValue(
Pred
const
&, Value
const
&)
noexcept
74
{
75
return
true
;
76
}
77
78
template
<
class
Tree>
79
[[nodiscard]]
static
constexpr
bool
returnable(
Pred
const
& p,
Tree
const
& t,
80
typename
Tree::Node
const
& n)
noexcept
81
{
82
// Cast to int to prevent int to be promoted to unsigned
83
int
height =
static_cast<
int
>
(t.height(n));
84
bool
ret = p.min <= height && height <= p.max;
85
if
constexpr
(Negated) {
86
return
!ret;
87
}
else
{
88
return
ret;
89
}
90
}
91
92
template
<
class
Tree>
93
[[nodiscard]]
static
constexpr
bool
traversable(
Pred
const
& p,
Tree
const
& t,
94
typename
Tree::Node
const
& n)
noexcept
95
{
96
// Cast to int to prevent int to be promoted to unsigned
97
int
height =
static_cast<
int
>
(t.height(n));
98
if
constexpr
(Negated) {
99
return
0 < p.min || p.max + 1 < height;
100
}
else
{
101
return
p.min < height;
102
}
103
}
104
105
template
<
class
Tree>
106
[[nodiscard]]
static
constexpr
bool
returnableRay(
Pred
const
& p,
Tree
const
& t,
107
typename
Tree::Node
const
& n,
108
typename
Tree::Ray
const
&)
noexcept
109
{
110
return
returnable(p, t, n);
111
}
112
113
template
<
class
Tree>
114
[[nodiscard]]
static
constexpr
bool
traversableRay(
Pred
const
& p,
Tree
const
& t,
115
typename
Tree::Node
const
& n,
116
typename
Tree::Ray
const
&)
noexcept
117
{
118
return
traversable(p, t, n);
119
}
120
};
121
}
// namespace ufo::pred
122
123
#endif
// UFO_CONTAINER_TREE_PREDICATE_HEIGHT_HPP
ufo::Tree
Utilizing curiously recurring template pattern (CRTP)
Definition
tree.hpp:104
ufo::pred
Definition
predicate.hpp:74
ufo::Ray< Dim, coord_type >
ufo::TreeNode
Definition
node.hpp:57
ufo::pred::Filter
Definition
filter.hpp:51
ufo::pred::PredicateInterval
Definition
predicate_interval.hpp:58
ufo::pred::detail::Height
Definition
height.hpp:53
lib
container
include
ufo
container
tree
predicate
height.hpp
Generated by
1.9.8