21 if (!fill_ids || fill_ids.
is_empty()) {
33 const int fill_id = fill_ids[curve];
44 *value = fill_sizes.
size();
48 [&](
const int *value) {
49 const int fill_index = *value;
50 fill_sizes[fill_index]++;
51 curve_indices_by_fill[fill_index].
append(curve);
64 for (const int fill_i : range) {
65 const IndexRange fill_range = fill_offsets[fill_i];
66 const Span<int> curve_indices = curve_indices_by_fill[fill_i].as_span();
67 fill_map.as_mutable_span().slice(fill_range).copy_from(curve_indices);
72 fill_cache.
fill_map = std::move(fill_map);
80 if (!fill_ids || fill_ids.
is_empty()) {
88 shape_data.
shape_map = std::move(shape_map);
111 for (
const int curve :
IndexRange(num_curves)) {
112 const int fill_id = fill_ids[curve];
116 all_zero_fill_curve_indices.
append(curve);
119 else if (fill_id_to_shape.
add(fill_id, shape_sizes.
size())) {
121 all_fill_ids.
append(fill_id);
123 all_zero_fill_curve_indices.
append(-1);
126 shape_sizes[fill_id_to_shape.
lookup(fill_id)]++;
131 if (non_zero_fill_indexing.
add(fill_id, curve_indices_by_non_zero_fill.
size())) {
135 curve_indices_by_non_zero_fill[non_zero_fill_indexing.
lookup(fill_id)].
append(curve);
146 for (const int shape_i : range) {
147 const IndexRange shape_range = shape_offsets[shape_i];
148 const bool is_zero_fill = all_fill_ids[shape_i] == 0;
150 const int curve_i = all_zero_fill_curve_indices[shape_i];
151 BLI_assert(shape_range.size() == 1);
152 shape_map_span[shape_range.first()] = curve_i;
155 const int fill_id = all_fill_ids[shape_i];
156 const Span<int> curve_indices =
157 curve_indices_by_non_zero_fill[non_zero_fill_indexing.lookup(fill_id)].as_span();
158 shape_map_span.slice(shape_range).copy_from(curve_indices);
164 shape_data.
shape_map = std::move(shape_map);
174 return max_fill_id <= 0 ? 1 : max_fill_id + 1;
203 [&](
const int index,
const int pos) { r_new_fill_ids[
index] = next_fill_id + pos; },
219 return selected_mask;
224 points_by_curve, selected_mask, memory);
233 points_by_curve, selected_mask, memory);
236 const int fill_id = fill_ids[curve_i];
238 selected_fill_ids.
add(fill_id);
241 selected_curves.
to_bools(src_selected_curves);
245 const int fill_id = fill_ids[curve_i];
247 selected_fill_ids.
add(fill_id);
250 selected_mask.
to_bools(src_selected_curves);
255 const int fill_id = fill_ids[curve_i];
257 return src_selected_curves[curve_i];
259 return selected_fill_ids.
contains(fill_id);
263 return selected_curves;
274 const int curves_num = shapes.
data.size();
277 if (shapes.
size() == curves_num) {
283 for (const int shape_i : range) {
284 const Span<int> shape = shapes[shape_i];
285 for (const int curve_i : shape) {
286 curve_to_shape_map[curve_i] = shape_i;
292 curve_mask.foreach_index([&](
const int curve_i) {
293 const int shape_i = curve_to_shape_map[curve_i];
294 selected_shapes.
add(shape_i);
318 [&](
const int curve_i) { max_id =
math::max(max_id, fill_ids.
span[curve_i]); });
327 [&](
const int curve_i) { fill_indexing.
add(fill_ids.
span[curve_i]); });
330 [&](
const int curve_i) {
331 if (fill_ids.
span[curve_i] == 0) {
334 fill_ids.
span[curve_i] = fill_indexing.
index_of(fill_ids.
span[curve_i]) + max_id + 1;
Low-level operations for curves.
Low-level operations for curves.
static IndexMask from_predicate(const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
static IndexMask from_indices(Span< T > indices, LinearAllocator<> &memory)
bool add(const Key &key, const Value &value)
const Value & lookup(const Key &key) const
auto add_or_modify(const Key &key, const CreateValueF &create_value, const ModifyValueF &modify_value) -> decltype(create_value(nullptr))
IndexRange index_range() const
int64_t index_of(const Key &key) const
bool contains(const Key &key) const
Span< Key > as_span() const
void append(const T &value)
MutableSpan< T > as_mutable_span()
GAttributeReader lookup(const StringRef name) const
GSpanAttributeWriter lookup_for_write_span(StringRef name)
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
IndexMask complement(const IndexMask &universe, LinearAllocator<> &memory) const
void to_bools(MutableSpan< bool > r_bools) const
IndexRange index_range() const
std::optional< int64_t > max_element_index(const Span< T > &span, const int64_t grain_size=8192)
void fill_index_range(MutableSpan< T > span, const T start=0)
IndexMask point_to_curve_selection(OffsetIndices< int > points_by_curve, const IndexMask &point_mask, LinearAllocator<> &memory)
IndexMask curve_to_point_selection(OffsetIndices< int > points_by_curve, const IndexMask &curve_selection, LinearAllocator<> &memory)
IndexMask selected_mask_to_fills(const IndexMask &selected_mask, const CurvesGeometry &curves, AttrDomain selection_domain, IndexMaskMemory &memory)
std::optional< FillCache > fill_cache_from_fill_ids(const VArray< int > &fill_ids)
int get_next_available_fill_id(Span< int > fill_ids)
static int get_next_available_fill_id_from_max(const int max_fill_id)
IndexMask curves_mask_to_shapes(const IndexMask &curve_mask, const GroupedSpan< int > shapes, IndexMaskMemory &memory)
void gather_next_available_fill_ids(const VArray< int > &fill_ids, MutableSpan< int > r_new_fill_ids)
void separate_fill_ids(CurvesGeometry &curves, const IndexMask &strokes_to_keep)
ShapeData shapes_from_fill_ids(const VArray< int > &fill_ids, int curves_num)
constexpr ParallelGrainSize grain_size(int grain_size)
T max(const T &a, const T &b)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MutableVArraySpan< T > span
Vector< int > fill_offsets
Vector< int > shape_offsets
IndexRange index_range() const