UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
contains_occupancy_states.hpp
1
42#ifndef UFO_MAP_OCCUPANCY_PREDICATE_CONTAINS_OCCUPANCY_STATES_HPP
43#define UFO_MAP_OCCUPANCY_PREDICATE_CONTAINS_OCCUPANCY_STATES_HPP
44
45// UFO
46#include <ufo/container/tree/index.hpp>
47#include <ufo/container/tree/predicate/filter.hpp>
48#include <ufo/map/occupancy/propagation_criteria.hpp>
49
50namespace ufo::pred
51{
53 constexpr ContainOccupancyStates(bool unknown, bool free, bool occupied)
54 : unknown(unknown), free(free), occupied(occupied)
55 {
56 }
57
58 bool unknown;
59 bool free;
60 bool occupied;
61};
62
63template <>
64struct Filter<ContainOccupancyStates> : public FilterBase<ContainOccupancyStates> {
66
67 template <class Tree>
68 static constexpr void init(Pred&, Tree const&)
69 {
70 }
71
72 template <class Tree>
73 [[nodiscard]] static constexpr bool returnable(Pred const& p, Tree const& t,
74 TreeIndex const& n)
75 {
76 return (p.unknown && t.containsUnknown(n)) || (p.free && t.containsFree(n)) ||
77 (p.occupied && t.containsOccupied(n));
78 }
79
80 template <class Tree>
81 [[nodiscard]] static constexpr bool traversable(Pred const& p, Tree const& t,
82 TreeIndex const& n)
83 {
84 if (OccupancyPropagationCriteria::NONE == t.occupancyPropagationCriteria()) {
85 return true;
86 }
87
88 return (p.unknown && t.containsUnknown(n)) || (p.free && t.containsFree(n)) ||
89 (p.occupied && t.containsOccupied(n));
90 }
91};
92} // namespace ufo::pred
93
94#endif // UFO_MAP_OCCUPANCY_PREDICATE_CONTAINS_OCCUPANCY_STATES_HPP
Utilizing curiously recurring template pattern (CRTP)
Definition tree.hpp:104