UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
obj.cpp
1// UFO
2#include <ufo/io/file_handler.hpp>
3#include <ufo/io/obj.hpp>
4
5// STL
6#include <filesystem>
7#include <format>
8#include <stdexcept>
9
10namespace ufo
11{
12CloudProperties cloudPropertiesOBJ(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 OBJ] Failed to open file: {}", file.string()));
19 }
20
21 CloudProperties prop;
22 prop.alpha = false;
23 prop.intensity = false;
24
25 for (char line[1024]; nullptr != std::fgets(line, sizeof line, fp.get());) {
26 Vec3d p;
27 FineRGB c;
28 Normal n;
29 if (3 == std::sscanf(line, "vn %f %f %f", &n.x, &n.y, &n.z)) {
30 prop.normal = true;
31 } else if (6 == std::sscanf(line, "v %lf %lf %lf %f %f %f", &p.x, &p.y, &p.z, &c.red,
32 &c.green, &c.blue)) {
33 prop.color = true;
34 }
35
36 if (prop.color && prop.normal) {
37 break;
38 }
39 }
40
41 return prop;
42}
43} // namespace ufo
All vision-related classes and functions.
Definition cloud.hpp:49