26 const IndexRange points = points_by_curve[curve_i];
27 const BitSpan curve_bits = bits::to_best_bit_span(selected).slice(points);
28 return bits::any_bit_set(curve_bits);
38 [&](
const int curve,
const int pos) { point_ranges[pos] = points_by_curve[curve]; },
49 curves.curve_type_counts(),
84 const std::array<int, CURVE_TYPES_NUM> &type_counts,
89 if (type_counts[type] == types.
size()) {
97 selection, memory, [&](
const int index) {
return types_span[
index] == type; });
101 const std::array<int, CURVE_TYPES_NUM> &counts,
111 if (!
mask.is_empty()) {
137 const Fn unselected_fn)
142 int curve_i =
mask.is_empty() ? -1 : 0;
144 int range_first =
mask.is_empty() ? 0 :
mask.first();
145 int range_last = range_first - 1;
148 if (offset_data[curve_i + 1] <=
index) {
149 int first_unselected_curve = curve_i;
150 if (range_last >= range_first) {
152 selected_fn(curve_i, points_by_curve[curve_i], ranges);
154 first_unselected_curve++;
158 }
while (offset_data[curve_i + 1] <=
index);
159 if constexpr (std::is_invocable_r_v<void, Fn, IndexRange, IndexRange>) {
164 else if (range_last + 1 !=
index) {
171 if (range_last - range_first >= 0) {
173 selected_fn(curve_i, points_by_curve[curve_i], ranges);
175 if constexpr (std::is_invocable_r_v<void, Fn, IndexRange, IndexRange>) {
193 mask, points_by_curve, selected_fn, unselected_fn);
206 const std::optional<Span<float3>> handle_positions_left =
curves.handle_positions_left();
207 const std::optional<Span<float3>> handle_positions_right =
curves.handle_positions_right();
208 if (!handle_positions_left || !handle_positions_right) {
214 [&](
const int curve) {
215 const IndexRange points = points_by_curve[curve];
216 for (
const int point : points) {
217 const int index = point * 3;
218 all_positions[
index] = (*handle_positions_left)[point];
219 all_positions[
index + 1] = positions[point];
220 all_positions[
index + 2] = (*handle_positions_right)[point];
225 return all_positions;
244 [&](
const int curve) {
245 const IndexRange points = points_by_curve[curve];
246 for (
const int point : points) {
247 const int index = point * 3;
248 handle_positions_left[point] = all_positions[
index];
249 positions[point] = all_positions[
index + 1];
250 handle_positions_right[point] = all_positions[
index + 2];
262 const int dst_curve_offset,
270 src_knots_by_curve, src_curves, start_offset, dst_offsets);
288 int8_t &knot_mode = knot_modes[curve];
290 knot_mode = cyclic[curve] ? mode_for_cyclic : mode_for_regular;
294 curves.nurbs_custom_knots_update_size();
Low-level operations for curves.
CustomData interface, see also DNA_customdata_types.h.
Span< T > as_span() const
void fill_assign_n(const void *value, void *dst, int64_t n) const
GMutableSpan slice(const int64_t start, int64_t size) const
const CPPType & type() const
const CPPType * type() const
static IndexMask from_predicate(const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
static IndexMask from_difference(const IndexMask &mask_a, const IndexMask &mask_b, LinearAllocator<> &memory)
static IndexMask from_initializers(const Span< Initializer > initializers, LinearAllocator<> &memory)
constexpr int64_t size() const
static constexpr IndexRange from_begin_end(const int64_t begin, const int64_t end)
static constexpr IndexRange from_begin_end_inclusive(const int64_t begin, const int64_t last)
constexpr int64_t size() const
T get_internal_single() const
Span< T > get_internal_span() const
void append(const T &value)
std::array< int, CURVE_TYPES_NUM > type_counts
Span< float > nurbs_custom_knots() const
OffsetIndices< int > nurbs_custom_knots_by_curve() const
AttributeAccessor attributes() const
MutableSpan< float > nurbs_custom_knots_for_write()
bool nurbs_has_custom_knots() const
IndexMask nurbs_custom_knot_curves(IndexMaskMemory &memory) const
MutableAttributeAccessor attributes_for_write()
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
void to_bits(MutableBitSpan r_bits, int64_t offset=0) const
IndexRange index_range() const
void gather_group_to_group(const OffsetIndices< int > src_offsets, const OffsetIndices< int > dst_offsets, const IndexMask &selection, const Span< T > src, MutableSpan< T > dst)
Array< float3 > retrieve_all_positions(const bke::CurvesGeometry &curves, const IndexMask &curves_selection)
void write_all_positions(bke::CurvesGeometry &curves, const IndexMask &curves_selection, Span< float3 > all_positions)
void gather_custom_knots(const bke::CurvesGeometry &src, const IndexMask &src_curves, int dst_curve_offset, bke::CurvesGeometry &dst)
void update_custom_knot_modes(const IndexMask &mask, const KnotsMode mode_for_regular, const KnotsMode mode_for_cyclic, bke::CurvesGeometry &curves)
void copy_custom_knots(const bke::CurvesGeometry &src_curves, const IndexMask &exclude_curves, bke::CurvesGeometry &dst_curves)
IndexMask curve_type_point_selection(const bke::CurvesGeometry &curves, CurveType curve_type, LinearAllocator<> &memory)
void foreach_selected_point_ranges_per_curve(const IndexMask &mask, OffsetIndices< int > points_by_curve, SelectedCallback selected_fn)
bke::CurvesGeometry copy_only_curve_domain(const bke::CurvesGeometry &src_curves)
IndexMask indices_for_type(const VArray< int8_t > &types, const std::array< int, CURVE_TYPES_NUM > &type_counts, const CurveType type, const IndexMask &selection, LinearAllocator<> &memory)
FunctionRef< void( int curve_i, IndexRange curve_points, Span< IndexRange > selected_point_ranges)> SelectedCallback
static void foreach_selected_point_ranges_per_curve_(const IndexMask &mask, const OffsetIndices< int > points_by_curve, const SelectedCallback selected_fn, const Fn unselected_fn)
static void if_has_data_call_callback(const Span< int > offset_data, const int begin, const int end, UnselectedCallback callback)
FunctionRef< void(IndexRange curves, IndexRange unselected_points)> UnselectedCallback
IndexMask point_to_curve_selection(OffsetIndices< int > points_by_curve, const IndexMask &point_mask, LinearAllocator<> &memory)
void fill_points(OffsetIndices< int > points_by_curve, const IndexMask &curve_selection, GPointer value, GMutableSpan dst)
IndexMask curve_to_point_selection(OffsetIndices< int > points_by_curve, const IndexMask &curve_selection, LinearAllocator<> &memory)
void foreach_curve_by_type(const VArray< int8_t > &types, const std::array< int, CURVE_TYPES_NUM > &type_counts, const IndexMask &selection, FunctionRef< void(IndexMask)> catmull_rom_fn, FunctionRef< void(IndexMask)> poly_fn, FunctionRef< void(IndexMask)> bezier_fn, FunctionRef< void(IndexMask)> nurbs_fn)
void copy_attributes(const AttributeAccessor src_attributes, AttrDomain src_domain, AttrDomain dst_domain, const AttributeFilter &attribute_filter, MutableAttributeAccessor dst_attributes)
constexpr ParallelGrainSize grain_size(int grain_size)
OffsetIndices< int > gather_selected_offsets(OffsetIndices< int > src_offsets, const IndexMask &selection, int start_offset, MutableSpan< int > dst_offsets)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
bke::CurvesGeometryRuntime * runtime