2#include <ufo/io/file_handler.hpp>
3#include <ufo/io/pcd.hpp>
14void pcdSplit(std::vector<std::string>& result, std::string
const& in,
15 char const*
const delimiters)
19 auto const len = in.length();
20 std::size_t token_start = 0;
23 while (token_start < len) {
25 token_start = in.find_first_not_of(delimiters, token_start);
26 if (token_start == std::string::npos) {
31 auto const token_end = in.find_first_of(delimiters, token_start);
34 if (token_end == std::string::npos) {
35 result.emplace_back(in.data() + token_start, len - token_start);
38 result.emplace_back(in.data() + token_start, token_end - token_start);
42 token_start = token_end + 1;
47CloudProperties cloudPropertiesPCD(std::filesystem::path
const& file)
49 FileHandler fp(file.c_str(),
"rb");
52 throw std::runtime_error(std::format(
53 "[UFO | Cloud Properties PCD] Failed to open file: {}", file.string()));
58 std::vector<std::string> st;
59 for (
char* buf = fp.readline();
nullptr != buf; buf = fp.readline()) {
60 std::string line(buf);
66 detail::pcdSplit(st, line,
"\t\r ");
68 std::stringstream sstream(line);
69 sstream.imbue(std::locale::classic());
71 std::string line_type;
74 if (
"#" == line_type.substr(0, 1)) {
78 if ((
"FIELDS" == line_type.substr(0, 6)) || (
"COLUMNS" == line_type.substr(0, 7))) {
79 int specified_channel_count =
static_cast<int>(st.size() - 1);
81 for (
int i = 0; i < specified_channel_count; ++i) {
82 if (
"rgb" == st.at(i + 1)) {
84 }
else if (
"rgba" == st.at(i + 1)) {
87 }
else if (
"intensity" == st.at(i + 1)) {
88 prop.intensity =
true;
89 }
else if (
"normal_x" == st.at(i + 1) ||
"normal_y" == st.at(i + 1) ||
90 "normal_z" == st.at(i + 1)) {
94 }
else if (
"DATA" == line_type.substr(0, 4)) {
All vision-related classes and functions.