UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
type.hpp
1
42#ifndef UFO_MAP_TYPE
43#define UFO_MAP_TYPE
44
45// UFO
46#include <ufo/utility/enum.hpp>
47
48// STL
49#include <cstdint>
50#include <limits>
51#include <ostream>
52#include <string>
53#include <string_view>
54#include <vector>
55
56namespace ufo
57{
58enum class MapType : std::uint64_t {
59 NONE = std::uint64_t(0),
60 TREE = NONE,
61 ALL = ~std::uint64_t(0),
62 OCCUPANCY = std::uint64_t(1) << 0,
63 COLOR = std::uint64_t(1) << 1,
64 TIME = std::uint64_t(1) << 2,
65 COUNT = std::uint64_t(1) << 3,
66 REFLECTION = std::uint64_t(1) << 4,
67 INTENSITY = std::uint64_t(1) << 5,
68 SURFEL = std::uint64_t(1) << 6,
69 VOID_REGION = std::uint64_t(1) << 7,
70 DISTANCE = std::uint64_t(1) << 8,
71 LABEL = std::uint64_t(1) << 9,
72 SEMANTIC = std::uint64_t(1) << 10,
73 LABEL_SET = std::uint64_t(1) << 11,
74 SEMANTIC_SET = std::uint64_t(1) << 12,
75 COST = std::uint64_t(1) << 13,
76};
77
78[[nodiscard]] constexpr MapType operator|(MapType a, MapType b) noexcept
79{
80 return MapType(to_underlying(a) | to_underlying(b));
81}
82
83[[nodiscard]] constexpr MapType operator&(MapType a, MapType b) noexcept
84{
85 return MapType(to_underlying(a) & to_underlying(b));
86}
87
88[[nodiscard]] constexpr std::string_view to_string(MapType mt)
89{
90 switch (mt) {
91 case MapType::ALL: return std::string_view{"all"};
92 case MapType::NONE: return std::string_view{"none"};
93 case MapType::OCCUPANCY: return std::string_view{"occupancy"};
94 case MapType::COLOR: return std::string_view{"color"};
95 case MapType::TIME: return std::string_view{"time"};
96 case MapType::COUNT: return std::string_view{"count"};
97 case MapType::REFLECTION: return std::string_view{"reflection"};
98 case MapType::INTENSITY: return std::string_view{"intensity"};
99 case MapType::SURFEL: return std::string_view{"surfel"};
100 case MapType::VOID_REGION: return std::string_view{"void_region"};
101 case MapType::DISTANCE: return std::string_view{"distance"};
102 case MapType::LABEL: return std::string_view{"label"};
103 case MapType::SEMANTIC: return std::string_view{"semantic"};
104 case MapType::LABEL_SET: return std::string_view{"label_set"};
105 case MapType::SEMANTIC_SET: return std::string_view{"semantic_set"};
106 case MapType::COST: return std::string_view{"cost"};
107 default: return std::string_view{"unknown"};
108 }
109}
110
111[[nodiscard]] inline std::vector<std::string> mapTypes(MapType mt)
112{
113 constexpr std::size_t const max_num_map_types =
114 std::numeric_limits<std::uint64_t>::digits;
115
116 std::vector<std::string> res;
117 for (std::size_t i{}; max_num_map_types > i; ++i) {
118 auto name = to_string(mt & static_cast<MapType>(std::uint64_t(1) << i));
119 if (std::string_view{"none"} != name && std::string_view{"unknown"} != name) {
120 res.emplace_back(name);
121 }
122 }
123 return res;
124}
125
126inline std::ostream& operator<<(std::ostream& os, MapType mt)
127{
128 constexpr std::size_t const max_num_map_types =
129 std::numeric_limits<std::uint64_t>::digits;
130
131 std::string c;
132 for (std::size_t i{}; max_num_map_types > i; ++i) {
133 auto name = to_string(mt & static_cast<MapType>(std::uint64_t(1) << i));
134 if (std::string_view{"none"} != name && std::string_view{"unknown"} != name) {
135 os << c << name;
136 c = ", ";
137 }
138 }
139 return os;
140}
141} // namespace ufo
142
143#endif // UFO_MAP_TYPE
STL namespace.
All vision-related classes and functions.
Definition cloud.hpp:49
constexpr T b(Lab< T, Flags > color) noexcept
Returns the un-weighted blue–yellow axis value.
Definition lab.hpp:326
constexpr T a(Lab< T, Flags > color) noexcept
Returns the un-weighted green–red axis value.
Definition lab.hpp:310