UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
cost_interval.hpp
1
42#ifndef UFO_MAP_COST_PREDICATE_COST_INTERVAL_HPP
43#define UFO_MAP_COST_PREDICATE_COST_INTERVAL_HPP
44
45// UFO
46#include <ufo/container/tree/index.hpp>
47#include <ufo/container/tree/predicate/filter.hpp>
48#include <ufo/map/cost/predicate/cost.hpp>
49
50namespace ufo::pred
51{
52template <bool Negated = false>
54 using cost_t = float;
55
56 constexpr CostInterval(cost_t min, cost_t max) : min(min), max(max) {}
57
60};
61
62template <bool Negated>
64{
65 return {p.min, p.max};
66}
67
68template <bool Negated>
69struct Filter<CostInterval<Negated>> {
71
72 template <class Tree>
73 static constexpr void init(Pred& p, Tree const& t)
74 {
75 }
76
77 template <class Tree>
78 [[nodiscard]] static constexpr bool returnable(Pred const& p, Tree const& t,
79 TreeIndex const& n)
80 {
81 if constexpr (Negated) {
82 return !Filter<CostGE>::returnable(p.min, t, n) ||
83 !Filter<CostLE>::returnable(p.max, t, n);
84 } else {
85 return Filter<CostGE>::returnable(p.min, t, n) &&
86 Filter<CostLE>::returnable(p.max, t, n);
87 }
88 }
89
90 template <class Tree>
91 [[nodiscard]] static constexpr bool traversable(Pred const& p, Tree const& t,
92 TreeIndex const& n)
93 {
94 if constexpr (Negated) {
95 return true;
96 } else {
97 return Filter<CostGE>::traversable(p.min, t, n) &&
98 Filter<CostLE>::traversable(p.max, t, n);
99 }
100 }
101};
102} // namespace ufo::pred
103
104#endif // UFO_MAP_COST_PREDICATE_COST_INTERVAL_HPP
Utilizing curiously recurring template pattern (CRTP)
Definition tree.hpp:104
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