In the middle of multithreading parsers.
This commit is contained in:
98
include/assets/file_parsers/kitti_parser.hpp
Normal file
98
include/assets/file_parsers/kitti_parser.hpp
Normal file
@@ -0,0 +1,98 @@
|
||||
#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,
|
||||
std::mutex& m_store_mutex
|
||||
);
|
||||
|
||||
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;
|
||||
std::mutex* m_store_mutex;
|
||||
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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user