1
0

feature: coordinate storage index

This commit is contained in:
2025-11-14 01:04:50 +02:00
parent 9d3452bea4
commit 7ae430ff4a
2 changed files with 122 additions and 58 deletions

View File

@@ -38,17 +38,6 @@ static void usage(const char* prog) {
return return_value; \
}
template<typename TargetType, typename SourceType, typename Function, std::size_t... Index>
inline void foreach_tuple_element(TargetType &target_tuple, const SourceType &source_tuple, Function function, std::index_sequence<Index...>) {
static_assert(std::tuple_size_v<TargetType> == std::tuple_size_v<SourceType>);
((
function(
std::get<Index>(target_tuple),
std::get<Index>(source_tuple)
)
), ...);
}
int main(int argc, char** argv) {
using namespace wavefront;
@@ -160,44 +149,9 @@ int main(int argc, char** argv) {
auto coordinate_index_data = create_coordinate_index<FloatType, IndexType>(coordinate_data, number_list);
coordinate_index_storage_t<IndexType, std::set> ndim_coordinate_storage_set;
append_coordinate_map_to_storage<IndexType, 3>(ndim_coordinate_storage_set, coordinate_index_data.position_coordinates);
append_coordinate_map_to_storage<IndexType, 3>(ndim_coordinate_storage_set, coordinate_index_data.normal_coordinates);
auto coordinate_storage = compile_coordinate_storage(coordinate_index_data);
std::visit([&](const auto &texture_coordinates) {
if constexpr (std::ranges::range<std::decay_t<decltype(texture_coordinates)>>) {
if constexpr (std::ranges::range<typename std::decay_t<decltype(texture_coordinates)>::mapped_type>) {
append_coordinate_map_to_storage<
IndexType,
std::tuple_size_v<typename std::decay_t<decltype(texture_coordinates)>::mapped_type>
>(ndim_coordinate_storage_set, texture_coordinates);
} else {
append_coordinate_map_to_storage<
IndexType,
1
>(ndim_coordinate_storage_set, texture_coordinates);
}
}
}, coordinate_index_data.texture_coordinates);
coordinate_index_storage_t<IndexType, std::vector> ndim_coordinate_storage;
foreach_tuple_element(
ndim_coordinate_storage,
ndim_coordinate_storage_set,
[&](
auto &target,
const auto &source
) {
target.reserve(source.size());
std::copy(
source.begin(),
source.end(),
std::back_inserter(target)
);
},
std::index_sequence<1, 2, 3>{}
);
auto coordinate_storage_index = compile_coordinate_storage_line_mapping(coordinate_index_data, coordinate_storage);
// Form coordinate_list_data : std::vector variant of coordinate_index_data. Internally, it creates std::set initially, stores everything in the set and then convert to vector.
// Then we can form coordinate_line_mapping : std::map<file_line_t, std::size_t> pointing for each entry to entry in coordinate_list_data.