UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
has_label.hpp
1
42#ifndef UFO_MAP_LABELS_PREDICATE_HAS_LABEL_HPP
43#define UFO_MAP_LABELS_PREDICATE_HAS_LABEL_HPP
44
45// UFO
46#include <ufo/container/tree/predicate/filter.hpp>
47#include <ufo/container/tree/predicate/predicate_compare.hpp>
48#include <ufo/map/labels/propagation_criteria.hpp>
49
50namespace ufo::pred
51{
52template <bool Negated = false>
53struct HasLabel {
54};
55
56template <bool Negated>
58{
59 return {};
60}
61
62template <bool Negated>
63struct Filter<HasLabel<Negated>> {
64 using Pred = HasLabel<Negated>;
65
66 template <class Tree>
67 static constexpr void init(Pred& p, Tree const& t)
68 {
69 }
70
71 template <class Tree, class Node>
72 [[nodiscard]] static constexpr bool returnable(Pred const& p, Tree const& t,
73 Node const& n)
74 {
75 if constexpr (Negated) {
76 return t.labels(n.index).empty();
77 } else {
78 return !t.labels(n.index).empty();
79 }
80 }
81
82 template <class Tree, class Node>
83 [[nodiscard]] static constexpr bool traversable(Pred const& p, Tree const& t,
84 Node const& n)
85 {
86 if constexpr (Negated) {
87 return true;
88 } else {
89 switch (t.labelsPropagationCriteria()) {
90 case LabelsPropagationCriteria::ALL: {
91 return !t.labels(n.index).empty();
92 }
93 case LabelsPropagationCriteria::SUMMARY: {
94 return !t.labels(n.index).empty();
95 }
96 case LabelsPropagationCriteria::MIN: {
97 return !t.labels(n.index).empty();
98 }
99 case LabelsPropagationCriteria::MAX: {
100 return !t.labels(n.index).empty();
101 }
102 case LabelsPropagationCriteria::NONE: {
103 return true;
104 }
105 }
106 }
107 return true;
108 }
109};
110
111} // namespace ufo::pred
112
113#endif // UFO_MAP_LABELS_PREDICATE_HAS_LABEL_HPP
Utilizing curiously recurring template pattern (CRTP)
Definition tree.hpp:104