46#include <ufo/cloud/point_cloud.hpp>
47#include <ufo/io/cloud_properties.hpp>
48#include <ufo/io/file_handler.hpp>
49#include <ufo/numeric/vec.hpp>
58[[nodiscard]] CloudProperties cloudPropertiesXYZ(std::filesystem::path
const& file);
60template <std::size_t Dim,
class T,
class... Ts>
61bool readXYZ(std::filesystem::path
const& file, PointCloud<Dim, T, Ts...>& pc)
63 FileHandler fp(file.c_str(),
"rb");
66 std::println(stderr,
"[UFO | Read XYZ] Failed to open file: {}", file.string());
72 for (
char* line = fp.readline();
nullptr != line; line = fp.readline()) {
74 if (3 == std::sscanf(line,
"%lf %lf %lf", &p.x, &p.y, &p.z)) {
75 pc.push_back(
convert<Vec<Dim, T>>(p));
82template <std::size_t Dim,
class T,
class... Ts>
83bool writeXYZ(std::filesystem::path
const& file, PointCloud<Dim, T, Ts...>
const& pc)
85 FileHandler fp(file.c_str(),
"wb");
88 std::println(stderr,
"[UFO | Write XYZ] Failed to create file: {}", file.string());
92 for (
auto points = view<Vec<Dim, T>>(pc);
auto const& point : points) {
93 auto p = convert<Vec<3, T>>(point);
94 if constexpr (std::is_same_v<T, float>) {
95 std::println(fp.get(),
"{:.6} {:.6} {:.6}", p.x, p.y, p.z);
96 }
else if constexpr (std::is_floating_point_v<T>) {
97 std::println(fp.get(),
"{:.10} {:.10} {:.10}", p.x, p.y, p.z);
99 std::println(fp.get(),
"{} {} {}", p.x, p.y, p.z);
All vision-related classes and functions.
constexpr To convert(Vec< Dim, U > const &v) noexcept
Converts a vector to a different Vec type, truncating or zero-padding dimensions.