14#include <lagrange/IndexedAttribute.h>
15#include <lagrange/utils/invalid.h>
16#include <lagrange/utils/scope_guard.h>
34template <
typename ValueType,
typename Index>
37 auto indices = attr.indices().ref_all();
38 const size_t num_indices = attr.indices().get_num_elements();
41 size_t num_invalid = 0;
42 for (
size_t i = 0; i < num_indices; ++i) {
48 if (num_invalid == 0)
return;
51 const size_t num_valid = attr.values().get_num_elements();
53 const ValueType old_default_value = attr.values().get_default_value();
54 auto scope =
make_scope_guard([&] { attr.values().set_default_value(old_default_value); });
56 attr.values().insert_elements(num_invalid);
59 Index next_value =
static_cast<Index
>(num_valid);
60 for (
size_t i = 0; i < num_indices; ++i) {
62 indices[i] = next_value++;
Derived attribute class that stores the actual information.
Definition IndexedAttribute.h:29
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_invalid_indexed_values.h:35
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