UFO
1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
contains.hpp
1
42
#ifndef UFO_CONTAINER_TREE_PREDICATE_CONTAINS_HPP
43
#define UFO_CONTAINER_TREE_PREDICATE_CONTAINS_HPP
44
45
// UFO
46
#include <ufo/container/tree/predicate/filter.hpp>
47
#include <ufo/container/tree/predicate/spatial.hpp>
48
#include <ufo/geometry/contains.hpp>
49
50
// STL
51
#include <type_traits>
52
53
namespace
ufo::pred
54
{
55
template
<
class
Geometry,
bool
Negated = false>
56
struct
Contains
{
57
Geometry geometry;
58
};
59
60
template
<
class
Geometry,
bool
Negated>
61
[[nodiscard]]
constexpr
Contains<Geometry, !Negated>
operator!(
62
Contains<Geometry, Negated>
const
& p)
noexcept
63
{
64
return
Contains<Geometry, !Negated>
{p.geometry};
65
}
66
67
template
<
class
Geometry,
bool
Negated>
68
struct
Filter
<
Contains
<Geometry, Negated>> {
69
using
Pred
=
Contains<Geometry, Negated>
;
70
71
template
<
class
Tree>
72
static
constexpr
void
init(
Pred
&,
Tree
const
&)
noexcept
73
{
74
}
75
76
template
<
class
Value>
77
[[nodiscard]]
static
constexpr
bool
returnableValue(
Pred
const
& p,
78
Value
const
& v)
noexcept
79
{
80
if
constexpr
(Negated) {
81
if
constexpr
(is_pair_v<std::remove_cvref_t<Value>>) {
82
return
!
contains
(v.first, p.geometry);
83
}
else
{
84
return
!
contains
(v, p.geometry);
85
}
86
}
else
{
87
if
constexpr
(is_pair_v<std::remove_cvref_t<Value>>) {
88
return
contains
(v.first, p.geometry);
89
}
else
{
90
return
contains
(v, p.geometry);
91
}
92
}
93
}
94
95
template
<
class
Tree>
96
[[nodiscard]]
static
constexpr
bool
returnable(
Pred
const
& p,
Tree
const
& t,
97
typename
Tree::Node
const
& n)
noexcept
98
{
99
if
constexpr
(Negated) {
100
return
!
contains
(t.
bounds
(n), p.geometry);
101
}
else
{
102
return
contains
(t.
bounds
(n), p.geometry);
103
}
104
}
105
106
template
<
class
Tree>
107
[[nodiscard]]
static
constexpr
bool
traversable(
Pred
const
& p,
Tree
const
& t,
108
typename
Tree::Node
const
& n)
noexcept
109
{
110
if
constexpr
(Negated) {
111
return
true
;
112
}
else
{
113
return
contains
(t.
bounds
(n), p.geometry);
114
}
115
}
116
117
template
<
class
Tree>
118
[[nodiscard]]
static
constexpr
bool
returnableRay(
Pred
const
& p,
Tree
const
& t,
119
typename
Tree::Node
const
& n,
120
typename
Tree::Ray
const
&)
noexcept
121
{
122
return
returnable(p, t, n);
123
}
124
125
template
<
class
Tree>
126
[[nodiscard]]
static
constexpr
bool
traversableRay(
Pred
const
& p,
Tree
const
& t,
127
typename
Tree::Node
const
& n,
128
typename
Tree::Ray
const
&)
noexcept
129
{
130
return
traversable(p, t, n);
131
}
132
};
133
134
namespace
detail
135
{
136
template
<
class
Geometry,
bool
Negated>
137
struct
is_spatial_pred
<
Contains
<Geometry, Negated>> : std::true_type {
138
};
139
}
// namespace detail
140
}
// namespace ufo::pred
141
142
#endif
// UFO_CONTAINER_TREE_PREDICATE_CONTAINS_HPP
ufo::Tree
Utilizing curiously recurring template pattern (CRTP)
Definition
tree.hpp:104
ufo::Tree::bounds
Bounds bounds() const
Returns the bounds of the tree (/ root node).
Definition
tree.hpp:567
ufo::pred
Definition
predicate.hpp:74
ufo::contains
constexpr bool contains(A const &a, B const &b)
Checks if a shape contains another shape.
Definition
contains.hpp:63
ufo::Ray< Dim, coord_type >
ufo::TreeNode
Definition
node.hpp:57
ufo::pred::Contains
Definition
contains.hpp:56
ufo::pred::Filter
Definition
filter.hpp:51
ufo::pred::detail::is_spatial_pred
Definition
spatial.hpp:66
lib
container
include
ufo
container
tree
predicate
contains.hpp
Generated by
1.9.8