UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
hits_interval.hpp
1
42#ifndef UFO_MAP_HITS_PREDICATE_HITS_INTERVAL_HPP
43#define UFO_MAP_HITS_PREDICATE_HITS_INTERVAL_HPP
44
45// UFO
46#include <ufo/map/predicate/predicate.hpp>
47#include <ufo/map/reflection/predicate/hits.hpp>
48
49namespace ufo::pred
50{
51template <bool Negated = false>
53 HitsMin min;
54 HitsMax max;
55
56 HitsInterval(count_t min, count_t max) : min(min), max(max) {}
57};
58
59template <bool Negated>
61{
62 return {p.min, p.max};
63}
64
65template <bool Negated>
66struct Init<HitsInterval<Negated>> {
68
69 template <class Map>
70 static inline void apply(Pred& p, Map const& m)
71 {
72 Init<std::decay_t<decltype(p.min)>>::apply(p.min, m);
73 Init<std::decay_t<decltype(p.max)>>::apply(p.max, m);
74 }
75};
76
77template <bool Negated>
78struct InnerCheck<HitsInterval<Negated>> {
80
81 template <class Map, class Node>
82 static constexpr bool apply(Pred const& p, Map const& m, Node const& n)
83 {
84 if constexpr (Negated) {
85 return true;
86 } else {
87 return InnerCheck<std::decay_t<decltype(p.min)>>::apply(p.min, m, n) &&
88 InnerCheck<std::decay_t<decltype(p.max)>>::apply(p.max, m, n);
89 }
90 }
91};
92
93template <bool Negated>
94struct ValueCheck<HitsInterval<Negated>> {
96
97 template <class Map, class Node>
98 static inline bool apply(Pred const& p, Map const& m, Node const& n)
99 {
100 if constexpr (Negated) {
101 return !ValueCheck<std::decay_t<decltype(p.min)>>::apply(p.min, m, n) &&
102 !ValueCheck<std::decay_t<decltype(p.max)>>::apply(p.max, m, n);
103 } else {
104 return ValueCheck<std::decay_t<decltype(p.min)>>::apply(p.min, m, n) &&
105 ValueCheck<std::decay_t<decltype(p.max)>>::apply(p.max, m, n);
106 }
107 }
108};
109} // namespace ufo::pred
110
111#endif // UFO_MAP_HITS_PREDICATE_HITS_INTERVAL_HPP
constexpr Vec< Geometry::dimension(), typename Geometry::value_type > max(Geometry const &g)
Returns the maximum coordinate of the minimum spanning axis-aligned bounding box of a geometry.
Definition fun.hpp:72
constexpr Vec< Geometry::dimension(), typename Geometry::value_type > min(Geometry const &g)
Returns the minimum coordinate of the minimum spanning axis-aligned bounding box of a geometry.
Definition fun.hpp:58