14#include <lagrange/IndexedAttribute.h>
15#include <lagrange/utils/invalid.h>
16#include <lagrange/utils/scope_guard.h>
36template <
typename ValueType,
typename Index,
typename Predicate>
39 auto indices = attr.indices().ref_all();
40 const size_t num_indices = attr.indices().get_num_elements();
44 for (
size_t i = 0; i < num_indices; ++i) {
45 if (predicate(indices[i])) {
50 if (num_remap == 0)
return;
53 const size_t num_valid = attr.values().get_num_elements();
55 const ValueType old_default_value = attr.values().get_default_value();
56 auto scope =
make_scope_guard([&] { attr.values().set_default_value(old_default_value); });
58 attr.values().insert_elements(num_remap);
61 Index next_value =
static_cast<Index
>(num_valid);
62 for (
size_t i = 0; i < num_indices; ++i) {
63 if (predicate(indices[i])) {
64 indices[i] = next_value++;
78template <
typename ValueType,
typename Index>
93template <
typename ValueType,
typename Index>
96 const size_t num_values = attr.values().get_num_elements();
98 return static_cast<size_t>(index) >= num_values;
Derived attribute class that stores the actual information.
Definition IndexedAttribute.h:29
void set_out_of_range_indexed_values(IndexedAttribute< ValueType, Index > &attr)
For each element in the index buffer pointing outside the value buffer, appends a new value set to in...
Definition set_indexed_values.h:94
void set_predicated_indexed_values(IndexedAttribute< ValueType, Index > &attr, Predicate &&predicate)
For each index matching the given predicate, appends a new value set to invalid<ValueType>() and reas...
Definition set_indexed_values.h:37
void set_invalid_indexed_values(IndexedAttribute< ValueType, Index > &attr)
For each element in the index buffer set to invalid<Index>(), appends a new value set to invalid<Valu...
Definition set_indexed_values.h:79
sg_detail::scope_guard< Callback > make_scope_guard(Callback &&callback) noexcept(std::is_nothrow_constructible< Callback, Callback && >::value)
Creates a scope guard around a callable object.
constexpr T invalid()
You can use invalid<T>() to get a value that can represent "invalid" values, such as invalid indices ...
Definition invalid.h:40
nullptr_t, size_t, ptrdiff_t basic_ostream bad_weak_ptr extent, remove_extent, is_array,...
Definition attribute_string_utils.h:21