Files
Z3D/include/assets/file_parsers/kitti_parser.hpp
2025-03-31 21:41:24 +02:00

97 lines
2.1 KiB
C++

#pragma once
#include <filesystem>
#include "assets/data_stores.hpp"
#include "assets/path_id_lookups.hpp"
#include "assets/components/point_cloud_vertex_components.hpp"
#include "assets/data/point_cloud_data.hpp"
#include "assets/data/pose_data.hpp"
#include "assets/data_stores/point_cloud_store.hpp"
#include "assets/data_stores/pose_list_store.hpp"
#include "assets/data_views/pose_list_view.hpp"
#include "util/result.hpp"
namespace assets
{
struct kitti_parser
{
static constexpr auto name = std::string_view("kitti");
using data_type = point_cloud_data;
using store_type = point_cloud_store;
using lookup_type = point_cloud_id_lookup;
[[nodiscard]] std::error_code prefetch(
path_id_lookups& lookups
);
[[nodiscard]] std::error_code load(
path_id_lookups& lookups,
data_stores& stores,
bool pedantic = false
);
protected:
static constexpr auto frame_folder = "frames";
class parser_context
{
public:
parser_context(
const pose_list_id_lookup& pose_list_lookup,
const pose_list_store& pose_list_store,
store_type& m_store,
);
void operator()(lookup_type::const_pointer entry) noexcept;
protected:
void reset();
void tokenize_declarations();
[[nodiscard]] bool parse_metadata_from_tokens();
void remove_metadata_declarations();
private:
pose_list_id_lookup const* m_pose_list_lookup;
pose_list_store const* m_pose_list_store;
store_type* m_store;
data_type m_buffer{};
std::filesystem::path m_last_pose_path{};
pose_list_view m_last_pose_list{};
};
[[nodiscard]] static ztu::result<std::size_t> frame_id_from_filename(
std::string_view filename
);
[[nodiscard]] static std::error_code load_point_file(
const std::filesystem::path& filename,
data_type& point_cloud
);
static void transform_point_cloud(
z3d::array_view<point_cloud_vertex_components::position> points,
const pose_data& pose
);
[[nodiscard]] static ztu::result<std::filesystem::path> parent_directory(
const std::filesystem::path& path
);
#
[[nodiscard]] static ztu::result<std::filesystem::path> get_pose_path(
const std::filesystem::path& path
);
private:
std::vector<lookup_type::const_pointer> m_path_buffer;
};
}