UFO
1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
offset.hpp
1
42
#ifndef UFO_CONTAINER_TREE_PREDICATE_OFFSET_HPP
43
#define UFO_CONTAINER_TREE_PREDICATE_OFFSET_HPP
44
45
// UFO
46
#include <ufo/container/tree/predicate/filter.hpp>
47
48
namespace
ufo::pred
49
{
50
template
<
bool
Negated = false>
51
struct
Offset
{
52
std::size_t offset;
53
54
constexpr
Offset
(std::size_t offset = 0) noexcept : offset(offset) {}
55
};
56
57
template
<
bool
Negated>
58
[[nodiscard]]
Offset<!Negated>
operator!(
Offset<Negated>
const
& p)
59
{
60
return
Offset<!Negated>
(p.offset);
61
}
62
63
static
constexpr
inline
Offset<false>
const
offset;
64
65
template
<
bool
Negated>
66
struct
Filter
<
Offset
<Negated>> {
67
using
Pred
=
Offset<Negated>
;
68
69
template
<
class
Tree>
70
static
constexpr
void
init(
Pred
&,
Tree
const
&)
noexcept
71
{
72
}
73
74
template
<
class
Value>
75
[[nodiscard]]
static
constexpr
bool
returnableValue(
Pred
const
&, Value
const
&)
noexcept
76
{
77
return
true
;
78
}
79
80
template
<
class
Tree>
81
[[nodiscard]]
static
constexpr
bool
returnable(
Pred
const
& p,
Tree
const
&,
82
typename
Tree::Node
const
& n)
noexcept
83
{
84
if
constexpr
(Negated) {
85
return
p.offset != n.code.offset();
86
}
else
{
87
return
p.offset == n.code.offset();
88
}
89
}
90
91
template
<
class
Tree>
92
[[nodiscard]]
static
constexpr
bool
traversable(
Pred
const
&,
Tree
const
&,
93
typename
Tree::Node
const
&)
noexcept
94
{
95
return
true
;
96
}
97
98
template
<
class
Tree>
99
[[nodiscard]]
static
constexpr
bool
returnableRay(
Pred
const
& p,
Tree
const
& t,
100
typename
Tree::Node
const
& n,
101
typename
Tree::Ray
const
&)
noexcept
102
{
103
return
returnable(p, t, n);
104
}
105
106
template
<
class
Tree>
107
[[nodiscard]]
static
constexpr
bool
traversableRay(
Pred
const
& p,
Tree
const
& t,
108
typename
Tree::Node
const
& n,
109
typename
Tree::Ray
const
&)
noexcept
110
{
111
return
traversable(p, t, n);
112
}
113
};
114
}
// namespace ufo::pred
115
116
#endif
// UFO_CONTAINER_TREE_PREDICATE_OFFSET_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::Offset
Definition
offset.hpp:51
lib
container
include
ufo
container
tree
predicate
offset.hpp
Generated by
1.9.8