forked from sammy-tri/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
point_cloud_flags.cc
49 lines (40 loc) · 1.19 KB
/
point_cloud_flags.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "drake/perception/point_cloud_flags.h"
#include <sstream>
#include <vector>
namespace drake {
namespace perception {
namespace {
// Utility for `ToString`.
// TODO(eric.cousineau): Move to `drake/common`, consider using `infix_iterator`
// per Soonho's suggestion: https://codereview.stackexchange.com/a/13209
std::ostream& join(std::ostream& os,
const std::vector<std::string>& elements,
const std::string& delim) {
for (size_t i = 0; i < elements.size(); ++i) {
os << elements[i];
if (i + 1 < elements.size())
os << delim;
}
return os;
}
} // namespace
namespace pc_flags {
std::ostream& operator<<(std::ostream& os, const Fields& fields) {
DRAKE_DEMAND(internal::kMaxBitInUse == kRGBs);
std::vector<std::string> values;
if (fields.contains(kXYZs))
values.push_back("kXYZs");
if (fields.contains(kNormals))
values.push_back("kNormals");
if (fields.contains(kRGBs))
values.push_back("kRGBs");
if (fields.has_descriptor()) {
values.push_back(fields.descriptor_type().name());
}
os << "(";
join(os, values, " | ");
return os << ")";
}
} // namespace pc_flags
} // namespace perception
} // namespace drake