94 lines
2.0 KiB
C++
94 lines
2.0 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(
|
|
path_id_lookups& pose_list_lookup,
|
|
data_stores& stores
|
|
);
|
|
|
|
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:
|
|
path_id_lookups* m_pose_list_lookup;
|
|
data_stores* m_stores;
|
|
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 parse_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;
|
|
};
|
|
|
|
}
|