UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
pts.cpp
1// UFO
2#include <ufo/io/file_handler.hpp>
3#include <ufo/io/pts.hpp>
4
5// STL
6#include <filesystem>
7#include <format>
8#include <stdexcept>
9
10namespace ufo
11{
12CloudProperties cloudPropertiesPTS(std::filesystem::path const& file)
13{
14 FileHandler fp(file.c_str(), "rb");
15
16 if (!fp) {
17 throw std::runtime_error(std::format(
18 "[UFO | Cloud Properties PTS] Failed to open file: {}", file.string()));
19 }
20
21 char line[1024];
22 std::size_t size{};
23 if (nullptr != std::fgets(line, sizeof line, fp.get())) {
24 std::sscanf(line, "%zu", &size);
25 }
26
27 if (0 == size) {
28 throw std::runtime_error(std::format(
29 "[UFO | Cloud Properties PTS] Unable to read header of file: {}", file.string()));
30 }
31
32 std::array<double, 7> fields;
33 auto num_fields =
34 std::sscanf(line, "%lf %lf %lf %lf %lf %lf %lf", &fields[0], &fields[1], &fields[2],
35 &fields[3], &fields[4], &fields[5], &fields[6]);
36
37 CloudProperties prop;
38 prop.color = 6 == num_fields || 7 == num_fields;
39 prop.alpha = false;
40 prop.intensity = 4 == num_fields || 7 == num_fields;
41 prop.normal = false;
42
43 return prop;
44}
45} // namespace ufo
All vision-related classes and functions.
Definition cloud.hpp:49