Finally refactored all stores!

This commit is contained in:
zy4n
2025-04-02 17:45:41 +02:00
parent 27977c1738
commit 835c645da4
11 changed files with 469 additions and 648 deletions

View File

@@ -14,13 +14,11 @@
assets::kitti_parser::parser_context::parser_context(
const pose_list_id_lookup& pose_list_lookup,
const pose_list_store& pose_list_store,
store_type& m_store
path_id_lookups& pose_list_lookup,
data_stores& stores
) :
m_pose_list_lookup{ &pose_list_lookup },
m_pose_list_store{ &pose_list_store },
m_store{ &m_store }
m_stores{ &stores }
{
constexpr auto expected_vertex_count = 8192;
m_buffer.positions().reserve(expected_vertex_count);
@@ -37,20 +35,28 @@ void assets::kitti_parser::parser_context::operator()(lookup_type::const_pointer
{
const auto& [ filename, id ] = *entry;
pose_data pose;
if (const auto pose_path = get_pose_path(filename); not pose_path)
std::size_t pose_index;
if (const auto res = frame_id_from_filename(filename.c_str()))
{
if (pose_path != m_last_pose_path)
pose_index = res.value;
}
else
{
ztu::logger::error("Could not parse frame id from kitti filename %: %", filename, res.error());
return;
}
if (const auto pose_path = get_pose_path(filename))
{
if (*pose_path != m_last_pose_path)
{
if (const auto pose_list_id_it = m_pose_list_lookup->find(*pose_path); pose_list_id_it != m_pose_list_lookup->end())
if (const auto pose_list_id_it = m_pose_list_lookup->pose_lists.find(*pose_path); pose_list_id_it != m_pose_list_lookup->pose_lists.end())
{
m_last_pose_path = *pose_path;
const auto pose_list_id = pose_list_id_it->second;
if (const auto [ pose_list_it, found ] = m_pose_list_store->find(pose_list_id); found)
if (const auto [ pose_list_it, found ] = m_pose_list_lookup->poses.find(pose_list_id); found)
{
m_last_pose_path = *pose_path;
m_last_pose_list = pose_list_it->second;
}
else
@@ -74,15 +80,32 @@ void assets::kitti_parser::parser_context::operator()(lookup_type::const_pointer
reset();
if (const auto e = load_point_file(filename, m_buffer))
pose_data pose;
if (pose_index < m_last_pose_list.size())
{
ztu::logger::error("Could not load kitti file %: %", filename, e.message());
pose = m_last_pose_list[pose_index];
}
else
{
ztu::logger::error(
"Pose index % of kitti file % is out of range for its pose file %. Proceeding with identity pose.",
pose_index,
filename,
m_last_pose_path
);
pose = glm::identity<pose_data>();
}
if (const auto e = parse_file(filename, m_buffer))
{
ztu::logger::error("Could not parse kitti file %: %", filename, e.message());
return;
}
transform_point_cloud(m_buffer.positions(), pose);
m_store->insert(id, m_buffer);
m_stores->point_clouds.insert(id, m_buffer);
}
ztu::result<std::filesystem::path> assets::kitti_parser::parent_directory(
@@ -138,8 +161,6 @@ std::error_code assets::kitti_parser::load(
data_stores& stores,
bool pedantic
) {
namespace fs = std::filesystem;
m_path_buffer.clear();
lookups.point_clouds.by_extension(".bin", m_path_buffer);
@@ -148,9 +169,8 @@ std::error_code assets::kitti_parser::load(
m_path_buffer.begin(),
m_path_buffer.end(),
parser_context{
lookups.pose_lists,
stores.pose_lists,
stores.point_clouds
lookups,
stores
}
);
@@ -167,7 +187,7 @@ void assets::kitti_parser::transform_point_cloud(
}
}
std::error_code assets::kitti_parser::load_point_file(
std::error_code assets::kitti_parser::parse_file(
const std::filesystem::path& filename,
point_cloud_data& point_cloud
) {