UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
modified.hpp
1
42#ifndef UFO_CONTAINER_TREE_PREDICATE_MODIFIED_HPP
43#define UFO_CONTAINER_TREE_PREDICATE_MODIFIED_HPP
44
45// UFO
46#include <ufo/container/tree/predicate/filter.hpp>
47
48namespace ufo::pred
49{
50template <bool Negated = false>
51struct Modified {
52};
53
54template <bool Negated>
55[[nodiscard]] constexpr Modified<!Negated> operator!(Modified<Negated> const&) noexcept
56{
57 return Modified<!Negated>{};
58}
59
60static constexpr inline Modified<false> const modified;
61
62template <bool Negated>
63struct Filter<Modified<Negated>> {
64 using Pred = Modified<Negated>;
65
66 template <class Tree>
67 static constexpr void init(Pred&, Tree const&) noexcept
68 {
69 }
70
71 template <class Value>
72 [[nodiscard]] static constexpr bool returnableValue(Pred const&, Value const&) noexcept
73 {
74 return true;
75 }
76
77 template <class Tree>
78 [[nodiscard]] static constexpr bool returnable(Pred const&, Tree const& t,
79 typename Tree::Node const& n) noexcept
80 {
81 if constexpr (Negated) {
82 return !t.modified(n.index);
83 } else {
84 return t.modified(n.index);
85 }
86 }
87
88 template <class Tree>
89 [[nodiscard]] static constexpr bool traversable(Pred const&, Tree const& t,
90 typename Tree::Node const& n) noexcept
91 {
92 if constexpr (Negated) {
93 return true;
94 } else {
95 return t.modified(n.index);
96 }
97 }
98
99 template <class Tree>
100 [[nodiscard]] static constexpr bool returnableRay(Pred const& p, Tree const& t,
101 typename Tree::Node const& n,
102 typename Tree::Ray const&) noexcept
103 {
104 return returnable(p, t, n);
105 }
106
107 template <class Tree>
108 [[nodiscard]] static constexpr bool traversableRay(Pred const& p, Tree const& t,
109 typename Tree::Node const& n,
110 typename Tree::Ray const&) noexcept
111 {
112 return traversable(p, t, n);
113 }
114};
115} // namespace ufo::pred
116
117#endif // UFO_CONTAINER_TREE_PREDICATE_MODIFIED_HPP
Utilizing curiously recurring template pattern (CRTP)
Definition tree.hpp:104
bool modified() const
Check if the root of the tree is modified.
Definition tree.hpp:981