UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
disjoint.hpp
1
42#ifndef UFO_CONTAINER_TREE_PREDICATE_DISJOINT_HPP
43#define UFO_CONTAINER_TREE_PREDICATE_DISJOINT_HPP
44
45// UFO
46#include <ufo/container/tree/predicate/filter.hpp>
47#include <ufo/container/tree/predicate/spatial.hpp>
48#include <ufo/geometry/disjoint.hpp>
49#include <ufo/geometry/inside.hpp>
50
51// STL
52#include <type_traits>
53
54namespace ufo::pred
55{
56template <class Geometry>
57struct Disjoint {
58 Geometry geometry;
59};
60
61template <class Geometry>
62struct Filter<Disjoint<Geometry>> {
64
65 template <class Tree>
66 static constexpr void init(Pred&, Tree const&) noexcept
67 {
68 }
69
70 template <class Value>
71 [[nodiscard]] static constexpr bool returnableValue(Pred const& p,
72 Value const& v) noexcept
73 {
74 if constexpr (is_pair_v<std::remove_cvref_t<Value>>) {
75 return disjoint(v.first, p.geometry);
76 } else {
77 return disjoint(v, p.geometry);
78 }
79 }
80
81 template <class Tree>
82 [[nodiscard]] static constexpr bool returnable(Pred const& p, Tree const& t,
83 typename Tree::Node const& n) noexcept
84 {
85 return disjoint(t.bounds(n), p.geometry);
86 }
87
88 template <class Tree>
89 [[nodiscard]] static constexpr bool traversable(Pred const& p, Tree const& t,
90 typename Tree::Node const& n) noexcept
91 {
92 return !inside(t.bounds(n), p.geometry);
93 }
94
95 template <class Tree>
96 [[nodiscard]] static constexpr bool returnableRay(Pred const& p, Tree const& t,
97 typename Tree::Node const& n,
98 typename Tree::Ray const&) noexcept
99 {
100 return returnable(p, t, n);
101 }
102
103 template <class Tree>
104 [[nodiscard]] static constexpr bool traversableRay(Pred const& p, Tree const& t,
105 typename Tree::Node const& n,
106 typename Tree::Ray const&) noexcept
107 {
108 return traversable(p, t, n);
109 }
110};
111
112namespace detail
113{
114template <class Geometry>
115struct is_spatial_pred<Disjoint<Geometry>> : std::true_type {
116};
117} // namespace detail
118} // namespace ufo::pred
119
120#endif // UFO_CONTAINER_TREE_PREDICATE_DISJOINT_HPP
Utilizing curiously recurring template pattern (CRTP)
Definition tree.hpp:104
Bounds bounds() const
Returns the bounds of the tree (/ root node).
Definition tree.hpp:567
constexpr bool inside(A const &a, B const &b)
Checks if a shape is inside another shape.
Definition inside.hpp:62
constexpr bool disjoint(A const &a, B const &b)
Checks if two shapes are disjoint.
Definition disjoint.hpp:62