extract explicit mesh with topology information from implicit surfaces with boolean operations, and do surface/volume integrating on them.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
1.4 KiB

#pragma once
#include "../stl_alias.hpp"
struct flat_index_group {
stl_vector_mp<uint32_t> index_group{}; /// a list of indices in the group
stl_vector_mp<uint32_t> start_indices{}; /// a list of start indices for each group in the flat index group
inline size_t size() const { return start_indices.size() - 1; }
// f(group_index, element_index_in_group, elemenet)
template <typename F>
inline void foreach (F&& f) const
{
for (uint32_t group_idx = 0; group_idx < size(); ++group_idx) {
for (uint32_t elem_idx = 0; elem_idx < start_indices[group_idx + 1] - start_indices[group_idx]; ++elem_idx) {
f(group_idx, elem_idx, index_group[start_indices[group_idx] + elem_idx]);
}
}
}
// f(group_index, group_start_index, group_end_index)
template <typename F>
inline void group_foreach(F&& f) const
{
for (uint32_t group_idx = 0; group_idx < size(); ++group_idx) {
f(group_idx, start_indices[group_idx], start_indices[group_idx + 1]);
}
}
// f(element_index_in_group, element)
template <typename F>
inline void loop_on_group(uint32_t group_idx, F&& f) const
{
for (uint32_t elem_idx = 0; elem_idx < start_indices[group_idx + 1] - start_indices[group_idx]; ++elem_idx) {
f(elem_idx, index_group[start_indices[group_idx] + elem_idx]);
}
}
};