UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
alpha_interval.hpp
1
42#ifndef UFO_MAP_COLOR_PREDICATE_ALPHA_INTERVAL_HPP
43#define UFO_MAP_COLOR_PREDICATE_ALPHA_INTERVAL_HPP
44
45// UFO
46#include <ufo/map/color/predicate/alpha.hpp>
47
48namespace ufo::pred
49{
50template <bool Negated = false>
52 AlphaMin min;
53 AlphaMax max;
54
55 AlphaInterval(color_t min, color_t max) : min(min), max(max) {}
56
57 float minAlphaf() const { return min.alphaf(); }
58
59 void minAlphaf(float v) { min.alphaf(v); }
60
61 float maxAlphaf() const { return max.alphaf(); }
62
63 void maxAlphaf(float v) { max.alphaf(v); }
64};
65
66template <bool Negated>
68{
69 return {p.min, p.max};
70}
71
72template <bool Negated>
73struct Init<AlphaInterval<Negated>> {
75
76 template <class Map>
77 static inline void apply(Pred& p, Map const& m)
78 {
79 Init<std::decay_t<decltype(p.min)>>::apply(p.min, m);
80 Init<std::decay_t<decltype(p.max)>>::apply(p.max, m);
81 }
82};
83
84template <bool Negated>
85struct InnerCheck<AlphaInterval<Negated>> {
87
88 template <class Map, class Node>
89 static constexpr bool apply(Pred const& p, Map const& m, Node const& n)
90 {
91 if constexpr (Negated) {
92 return true;
93 } else {
94 return InnerCheck<std::decay_t<decltype(p.min)>>::apply(p.min, m, n) &&
95 InnerCheck<std::decay_t<decltype(p.max)>>::apply(p.max, m, n);
96 }
97 }
98};
99
100template <bool Negated>
101struct ValueCheck<AlphaInterval<Negated>> {
103
104 template <class Map, class Node>
105 static inline bool apply(Pred const& p, Map const& m, Node const& n)
106 {
107 if constexpr (Negated) {
108 return !ValueCheck<std::decay_t<decltype(p.min)>>::apply(p.min, m, n) ||
109 !ValueCheck<std::decay_t<decltype(p.max)>>::apply(p.max, m, n);
110 } else {
111 return ValueCheck<std::decay_t<decltype(p.min)>>::apply(p.min, m, n) &&
112 ValueCheck<std::decay_t<decltype(p.max)>>::apply(p.max, m, n);
113 }
114 }
115};
116} // namespace ufo::pred
117
118#endif // UFO_MAP_COLOR_PREDICATE_ALPHA_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