Blender V5.0
curves_masks.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10
11#include "BKE_attribute.hh"
12#include "BKE_curves.hh"
13
14#include "ED_curves.hh"
15
16namespace blender::ed::curves {
17
19 const IndexMask &point_mask,
20 const GrainSize grain_size,
21 IndexMaskMemory &memory)
22{
23 Array<bool> selected(curves.points_num());
24 point_mask.to_bools(selected);
25
26 const OffsetIndices points_by_curve = curves.points_by_curve();
28 curves.curves_range(), grain_size, memory, [&](const int curve_i) {
29 const IndexRange points = points_by_curve[curve_i];
30 for (const int point_i : points) {
31 if (selected[point_i]) {
32 return true;
33 }
34 }
35 return false;
36 });
37}
38
40 const IndexMask &curves_mask,
41 const int amount_start,
42 const int amount_end,
43 const bool inverted,
44 IndexMaskMemory &memory)
45{
46 const OffsetIndices points_by_curve = curves.points_by_curve();
47
48 Array<bool> end_points(curves.points_num(), inverted ? false : true);
49 curves_mask.foreach_index(GrainSize(512), [&](const int64_t curve_i) {
50 end_points.as_mutable_span()
51 .slice(points_by_curve[curve_i].drop_front(amount_start).drop_back(amount_end))
52 .fill(inverted ? true : false);
53 });
54
55 return IndexMask::from_bools(end_points, memory);
56}
57
59 const int amount_start,
60 const int amount_end,
61 const bool inverted,
62 IndexMaskMemory &memory)
63{
64 return end_points(curves, curves.curves_range(), amount_start, amount_end, inverted, memory);
65}
66
67} // namespace blender::ed::curves
Low-level operations for curves.
long long int int64_t
static IndexMask from_bools(Span< bool > bools, IndexMaskMemory &memory)
static IndexMask from_predicate(const IndexMask &universe, GrainSize grain_size, IndexMaskMemory &memory, Fn &&predicate)
void to_bools(MutableSpan< bool > r_bools) const
void foreach_index(Fn &&fn) const
IndexMask curve_mask_from_points(const bke::CurvesGeometry &curves, const IndexMask &point_mask, const GrainSize grain_size, IndexMaskMemory &memory)
IndexMask end_points(const bke::CurvesGeometry &curves, const IndexMask &curves_mask, const int amount_start, const int amount_end, const bool inverted, IndexMaskMemory &memory)