Blender V5.0
resample_curves.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
5#include "BLI_array_utils.hh"
6#include "BLI_math_color.hh"
8#include "BLI_math_vector.hh"
9
11#include "BLI_task.hh"
12
13#include "FN_field.hh"
15
16#include "BKE_attribute_math.hh"
17#include "BKE_curves.hh"
18#include "BKE_curves_utils.hh"
19#include "BKE_deform.hh"
21
23
24namespace blender::geometry {
25
27{
28 static auto max_one_fn = mf::build::SI1_SO<int, int>(
29 "Clamp Above One",
30 [](int value) { return std::max(1, value); },
31 mf::build::exec_presets::AllSpanOrSingle());
32 return fn::Field<int>(fn::FieldOperation::from(max_one_fn, {count_field}));
33}
34
35static int get_count_from_length(const float curve_length,
36 const float sample_length,
37 const bool keep_last_segment)
38{
39 /* Find the number of sampled segments by dividing the total length by
40 * the sample length. Then there is one more sampled point than segment. */
41 if (UNLIKELY(sample_length == 0.0f)) {
42 return 1;
43 }
44 const int count = int(curve_length / sample_length) + 1;
45 return std::max(keep_last_segment ? 2 : 1, count);
46}
47
49 const bool keep_last_segment)
50{
51 static auto get_count_fn = mf::build::SI3_SO<float, float, bool, int>(
52 "Length Input to Count",
54 mf::build::exec_presets::SomeSpanOrSingle<0, 1>());
55
56 auto get_count_op = fn::FieldOperation::from(
57 get_count_fn,
58 {fn::Field<float>(std::make_shared<bke::CurveLengthFieldInput>()),
59 length_field,
60 fn::make_constant_field(keep_last_segment)});
61
62 return fn::Field<int>(std::move(get_count_op));
63}
64
69static bool interpolate_attribute_to_curves(const StringRef attribute_id,
70 const std::array<int, CURVE_TYPES_NUM> &type_counts)
71{
72 if (bke::attribute_name_is_anonymous(attribute_id)) {
73 return true;
74 }
75 if (ELEM(attribute_id, "handle_type_left", "handle_type_right", "handle_left", "handle_right")) {
76 return type_counts[CURVE_TYPE_BEZIER] != 0;
77 }
78 if (ELEM(attribute_id, "nurbs_weight")) {
79 return type_counts[CURVE_TYPE_NURBS] != 0;
80 }
81 return true;
82}
83
87static bool interpolate_attribute_to_poly_curve(const StringRef attribute_id)
88{
89 static const Set<StringRef> no_interpolation{{
90 "handle_type_left",
91 "handle_type_right",
92 "handle_right",
93 "handle_left",
94 "nurbs_weight",
95 }};
96 return !no_interpolation.contains(attribute_id);
97}
98
103 const CurvesGeometry &src_curves,
104 CurvesGeometry &dst_curves,
107 Vector<bke::GSpanAttributeWriter> &dst_attributes)
108{
109 const bke::AttributeAccessor src_attributes = src_curves.attributes();
110 for (const int i : ids.index_range()) {
111 const bke::GAttributeReader src_attribute = src_attributes.lookup(ids[i],
113 src.append(src_attribute.varray);
114
115 const bke::AttrType data_type = bke::cpp_type_to_attribute_type(src_attribute.varray.type());
116 bke::GSpanAttributeWriter dst_attribute =
118 ids[i], bke::AttrDomain::Point, data_type);
119 dst.append(dst_attribute.span);
120 dst_attributes.append(std::move(dst_attribute));
121 }
122}
123
138
143 const CurvesGeometry &src_curves,
144 CurvesGeometry &dst_curves,
146 const ResampleCurvesOutputAttributeIDs &output_ids)
147{
149 VectorSet<StringRef> ids_no_interpolation;
150 src_curves.attributes().foreach_attribute([&](const bke::AttributeIter &iter) {
151 if (iter.domain != bke::AttrDomain::Point) {
152 return;
153 }
154 if (iter.data_type == bke::AttrType::String) {
155 return;
156 }
157 if (!interpolate_attribute_to_curves(iter.name, dst_curves.curve_type_counts())) {
158 return;
159 }
161 ids.add_new(iter.name);
162 }
163 else {
164 ids_no_interpolation.add_new(iter.name);
165 }
166 });
167
168 /* Position is handled differently since it has non-generic interpolation for Bezier
169 * curves and because the evaluated positions are cached for each evaluated point. */
170 ids.remove_contained("position");
171
173 ids, src_curves, dst_curves, result.src, result.dst, result.dst_attributes);
174
175 /* Attributes that aren't interpolated like Bezier handles still have to be copied
176 * to the result when there are any unselected curves of the corresponding type. */
177 retrieve_attribute_spans(ids_no_interpolation,
178 src_curves,
179 dst_curves,
180 result.src_no_interpolation,
181 result.dst_no_interpolation,
182 result.dst_attributes);
183
184 bke::MutableAttributeAccessor dst_attributes = dst_curves.attributes_for_write();
185 if (output_ids.tangent_id) {
186 result.src_evaluated_tangents = src_curves.evaluated_tangents();
189 result.dst_tangents = dst_attribute.span.typed<float3>();
190 result.dst_attributes.append(std::move(dst_attribute));
191 }
192 if (output_ids.normal_id) {
193 result.src_evaluated_normals = src_curves.evaluated_normals();
196 result.dst_normals = dst_attribute.span.typed<float3>();
197 result.dst_attributes.append(std::move(dst_attribute));
198 }
199}
200
202 const IndexMask &unselected_curves,
203 const AttributesForResample &attributes,
204 CurvesGeometry &dst_curves)
205{
206 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
207 const OffsetIndices dst_points_by_curve = dst_curves.points_by_curve();
208 array_utils::copy_group_to_group(src_points_by_curve,
209 dst_points_by_curve,
210 unselected_curves,
211 src_curves.positions(),
212 dst_curves.positions_for_write());
213
214 for (const int i : attributes.src.index_range()) {
215 array_utils::copy_group_to_group(src_points_by_curve,
216 dst_points_by_curve,
217 unselected_curves,
218 attributes.src[i],
219 attributes.dst[i]);
220 }
221 for (const int i : attributes.src_no_interpolation.index_range()) {
222 array_utils::copy_group_to_group(src_points_by_curve,
223 dst_points_by_curve,
224 unselected_curves,
225 attributes.src_no_interpolation[i],
226 attributes.dst_no_interpolation[i]);
227 }
228
229 if (!attributes.dst_tangents.is_empty()) {
231 dst_points_by_curve, unselected_curves, float3(0), attributes.dst_tangents);
232 }
233 if (!attributes.dst_normals.is_empty()) {
235 dst_points_by_curve, unselected_curves, float3(0), attributes.dst_normals);
236 }
237}
238
240{
241 for (const int i : data.index_range()) {
243 }
244}
245
246static void normalize_curve_point_data(const IndexMaskSegment curve_selection,
247 const OffsetIndices<int> points_by_curve,
249{
250 for (const int i_curve : curve_selection) {
251 normalize_span(data.slice(points_by_curve[i_curve]));
252 }
253}
254
261 /* Use a default alignment that works for all attribute types, and don't use the inline buffer
262 * because it doesn't necessarily have the correct alignment. */
264 alignas(AllocatorType::min_alignment) std::array<std::byte, 1024> inline_buffer;
265
266 template<typename T> MutableSpan<T> resize(const int64_t size)
267 {
268 const int64_t size_in_bytes = sizeof(T) * size;
269 if (size_in_bytes <= this->inline_buffer.size()) {
270 return MutableSpan<std::byte>(this->inline_buffer).slice(0, size_in_bytes).cast<T>();
271 }
272 this->heap_allocated.resize(size_in_bytes);
273 return this->heap_allocated.as_mutable_span().cast<T>();
274 }
275};
276
277static void resample_to_uniform(const CurvesGeometry &src_curves,
278 const IndexMask &selection,
279 const ResampleCurvesOutputAttributeIDs &output_ids,
280 CurvesGeometry &dst_curves)
281{
282 if (src_curves.curves_range().is_empty()) {
283 return;
284 }
285
286 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
287 const OffsetIndices evaluated_points_by_curve = src_curves.evaluated_points_by_curve();
288 const VArray<bool> curves_cyclic = src_curves.cyclic();
289 const VArray<int8_t> curve_types = src_curves.curve_types();
290 const Span<float3> evaluated_positions = src_curves.evaluated_positions();
291
292 /* All resampled curves are poly curves. */
293 dst_curves.fill_curve_types(selection, CURVE_TYPE_POLY);
294
295 MutableSpan<float3> dst_positions = dst_curves.positions_for_write();
296
297 AttributesForResample attributes;
298 gather_point_attributes_to_interpolate(src_curves, dst_curves, attributes, output_ids);
299
300 src_curves.ensure_evaluated_lengths();
301
302 /* Sampling arbitrary attributes works by first interpolating them to the curve's standard
303 * "evaluated points" and then interpolating that result with the uniform samples. This is
304 * potentially wasteful when down-sampling a curve to many fewer points. There are two possible
305 * solutions: only sample the necessary points for interpolation, or first sample curve
306 * parameter/segment indices and evaluate the curve directly. */
307 Array<int> sample_indices(dst_curves.points_num());
308 Array<float> sample_factors(dst_curves.points_num());
309
310 const OffsetIndices dst_points_by_curve = dst_curves.points_by_curve();
311
312 /* Use a "for each group of curves: for each attribute: for each curve" pattern to work on
313 * smaller sections of data that ideally fit into CPU cache better than simply one attribute at a
314 * time or one curve at a time. */
315 selection.foreach_segment(GrainSize(512), [&](const IndexMaskSegment selection_segment) {
316 EvalDataBuffer evaluated_buffer;
317
318 /* Gather uniform samples based on the accumulated lengths of the original curve. */
319 for (const int i_curve : selection_segment) {
320 const bool cyclic = curves_cyclic[i_curve];
321 const IndexRange dst_points = dst_points_by_curve[i_curve];
322 const Span<float> lengths = src_curves.evaluated_lengths_for_curve(i_curve, cyclic);
323 if (lengths.is_empty()) {
324 /* Handle curves with only one evaluated point. */
325 sample_indices.as_mutable_span().slice(dst_points).fill(0);
326 sample_factors.as_mutable_span().slice(dst_points).fill(0.0f);
327 }
328 else {
330 !curves_cyclic[i_curve],
331 sample_indices.as_mutable_span().slice(dst_points),
332 sample_factors.as_mutable_span().slice(dst_points));
333 }
334 }
335
336 /* For every attribute, evaluate attributes from every curve in the range in the original
337 * curve's "evaluated points", then use linear interpolation to sample to the result. */
338 for (const int i_attribute : attributes.dst.index_range()) {
339 const CPPType &type = attributes.src[i_attribute].type();
340 bke::attribute_math::convert_to_static_type(type, [&](auto dummy) {
341 using T = decltype(dummy);
342 Span<T> src = attributes.src[i_attribute].typed<T>();
343 MutableSpan<T> dst = attributes.dst[i_attribute].typed<T>();
344
345 for (const int i_curve : selection_segment) {
346 const IndexRange src_points = src_points_by_curve[i_curve];
347 const IndexRange dst_points = dst_points_by_curve[i_curve];
348
349 if (curve_types[i_curve] == CURVE_TYPE_POLY) {
351 sample_indices.as_span().slice(dst_points),
352 sample_factors.as_span().slice(dst_points),
353 dst.slice(dst_points));
354 }
355 else {
356 MutableSpan evaluated = evaluated_buffer.resize<T>(
357 evaluated_points_by_curve[i_curve].size());
358 src_curves.interpolate_to_evaluated(i_curve, src.slice(src_points), evaluated);
359
361 sample_indices.as_span().slice(dst_points),
362 sample_factors.as_span().slice(dst_points),
363 dst.slice(dst_points));
364 }
365 }
366 });
367 }
368
369 auto interpolate_evaluated_data = [&](const Span<float3> src, MutableSpan<float3> dst) {
370 for (const int i_curve : selection_segment) {
371 const IndexRange src_points = evaluated_points_by_curve[i_curve];
372 const IndexRange dst_points = dst_points_by_curve[i_curve];
374 sample_indices.as_span().slice(dst_points),
375 sample_factors.as_span().slice(dst_points),
376 dst.slice(dst_points));
377 }
378 };
379
380 /* Interpolate the evaluated positions to the resampled curves. */
381 interpolate_evaluated_data(evaluated_positions, dst_positions);
382
383 if (!attributes.dst_tangents.is_empty()) {
384 interpolate_evaluated_data(attributes.src_evaluated_tangents, attributes.dst_tangents);
385 normalize_curve_point_data(selection_segment, dst_points_by_curve, attributes.dst_tangents);
386 }
387 if (!attributes.dst_normals.is_empty()) {
388 interpolate_evaluated_data(attributes.src_evaluated_normals, attributes.dst_normals);
389 normalize_curve_point_data(selection_segment, dst_points_by_curve, attributes.dst_normals);
390 }
391
392 /* Fill the default value for non-interpolating attributes that still must be copied. */
393 for (GMutableSpan dst : attributes.dst_no_interpolation) {
394 for (const int i_curve : selection_segment) {
395 const IndexRange dst_points = dst_points_by_curve[i_curve];
396 dst.type().value_initialize_n(dst.slice(dst_points).data(), dst_points.size());
397 }
398 }
399 });
400
401 IndexMaskMemory memory;
402 const IndexMask unselected = selection.complement(src_curves.curves_range(), memory);
403 copy_or_defaults_for_unselected_curves(src_curves, unselected, attributes, dst_curves);
404
405 for (bke::GSpanAttributeWriter &attribute : attributes.dst_attributes) {
406 attribute.finish();
407 }
408}
409
411 const fn::FieldContext &field_context,
412 const fn::Field<bool> &selection_field,
413 const fn::Field<int> &count_field,
414 const ResampleCurvesOutputAttributeIDs &output_ids)
415{
416 if (src_curves.curves_range().is_empty()) {
417 return {};
418 }
419 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
420
422 /* Copy vertex groups from source curves to allow copying vertex group attributes. */
424 MutableSpan<int> dst_offsets = dst_curves.offsets_for_write();
425
426 fn::FieldEvaluator evaluator{field_context, src_curves.curves_num()};
427 evaluator.set_selection(selection_field);
428 evaluator.add_with_destination(count_field, dst_offsets.drop_back(1));
429 evaluator.evaluate();
430 const IndexMask selection = evaluator.get_evaluated_selection_as_mask();
431 IndexMaskMemory memory;
432 const IndexMask unselected = selection.complement(src_curves.curves_range(), memory);
433
434 /* Fill the counts for the curves that aren't selected and accumulate the counts into offsets. */
435 offset_indices::copy_group_sizes(src_points_by_curve, unselected, dst_offsets);
437 return {};
438 }
439 dst_curves.resize(dst_offsets.last(), dst_curves.curves_num());
440
441 resample_to_uniform(src_curves, selection, output_ids, dst_curves);
442
443 bke::curves::nurbs::copy_custom_knots(src_curves, selection, dst_curves);
444 return dst_curves;
445}
446
448 const IndexMask &selection,
449 const VArray<int> &counts,
450 const ResampleCurvesOutputAttributeIDs &output_ids)
451{
452 if (src_curves.curves_range().is_empty()) {
453 return {};
454 }
455 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
456
458 /* Copy vertex groups from source curves to allow copying vertex group attributes. */
460 MutableSpan<int> dst_offsets = dst_curves.offsets_for_write();
461
462 array_utils::copy(counts, selection, dst_offsets);
463
464 IndexMaskMemory memory;
465 const IndexMask unselected = selection.complement(src_curves.curves_range(), memory);
466
467 /* Fill the counts for the curves that aren't selected and accumulate the counts into offsets. */
468 offset_indices::copy_group_sizes(src_points_by_curve, unselected, dst_offsets);
469 /* We assume the counts are at least 1. */
470 BLI_assert(std::all_of(dst_offsets.begin(),
471 dst_offsets.drop_back(1).end(),
472 [&](const int count) { return count > 0; }));
474 dst_curves.resize(dst_offsets.last(), dst_curves.curves_num());
475
476 resample_to_uniform(src_curves, selection, output_ids, dst_curves);
477
478 bke::curves::nurbs::copy_custom_knots(src_curves, selection, dst_curves);
479 return dst_curves;
480}
481
483 const fn::FieldContext &field_context,
484 const fn::Field<bool> &selection_field,
485 const fn::Field<int> &count_field,
486 const ResampleCurvesOutputAttributeIDs &output_ids)
487{
488 return resample_to_uniform(src_curves,
489 field_context,
490 selection_field,
491 get_count_input_max_one(count_field),
492 output_ids);
493}
494
496 const IndexMask &selection,
497 const VArray<float> &sample_lengths,
498 const ResampleCurvesOutputAttributeIDs &output_ids,
499 const bool keep_last_segment)
500{
501 if (src_curves.curves_range().is_empty()) {
502 return {};
503 }
504 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
505 const VArray<bool> curves_cyclic = src_curves.cyclic();
506
508 /* Copy vertex groups from source curves to allow copying vertex group attributes. */
510 MutableSpan<int> dst_offsets = dst_curves.offsets_for_write();
511
512 src_curves.ensure_evaluated_lengths();
513 selection.foreach_index(GrainSize(1024), [&](const int curve_i) {
514 const float curve_length = src_curves.evaluated_length_total_for_curve(curve_i,
515 curves_cyclic[curve_i]);
516 dst_offsets[curve_i] = get_count_from_length(
517 curve_length, sample_lengths[curve_i], keep_last_segment);
518 });
519
520 IndexMaskMemory memory;
521 const IndexMask unselected = selection.complement(src_curves.curves_range(), memory);
522
523 /* Fill the counts for the curves that aren't selected and accumulate the counts into offsets. */
524 offset_indices::copy_group_sizes(src_points_by_curve, unselected, dst_offsets);
526 dst_curves.resize(dst_offsets.last(), dst_curves.curves_num());
527
528 resample_to_uniform(src_curves, selection, output_ids, dst_curves);
529
530 bke::curves::nurbs::copy_custom_knots(src_curves, selection, dst_curves);
531 return dst_curves;
532}
533
535 const fn::FieldContext &field_context,
536 const fn::Field<bool> &selection_field,
537 const fn::Field<float> &segment_length_field,
538 const ResampleCurvesOutputAttributeIDs &output_ids,
539 const bool keep_last_segment)
540{
541 return resample_to_uniform(src_curves,
542 field_context,
543 selection_field,
544 get_count_input_from_length(segment_length_field, keep_last_segment),
545 output_ids);
546}
547
549 const IndexMask &selection,
550 const ResampleCurvesOutputAttributeIDs &output_ids)
551{
552 if (src_curves.curves_range().is_empty()) {
553 return {};
554 }
555 const OffsetIndices src_points_by_curve = src_curves.points_by_curve();
556 const OffsetIndices src_evaluated_points_by_curve = src_curves.evaluated_points_by_curve();
557 const Span<float3> evaluated_positions = src_curves.evaluated_positions();
558
559 IndexMaskMemory memory;
560 const IndexMask unselected = selection.complement(src_curves.curves_range(), memory);
561
563 /* Copy vertex groups from source curves to allow copying vertex group attributes. */
565 dst_curves.fill_curve_types(selection, CURVE_TYPE_POLY);
566 MutableSpan<int> dst_offsets = dst_curves.offsets_for_write();
567 offset_indices::copy_group_sizes(src_evaluated_points_by_curve, selection, dst_offsets);
568 offset_indices::copy_group_sizes(src_points_by_curve, unselected, dst_offsets);
570 const OffsetIndices dst_points_by_curve = dst_curves.points_by_curve();
571
572 dst_curves.resize(dst_offsets.last(), dst_curves.curves_num());
573
574 MutableSpan<float3> dst_positions = dst_curves.positions_for_write();
575
576 AttributesForResample attributes;
577 gather_point_attributes_to_interpolate(src_curves, dst_curves, attributes, output_ids);
578
580 selection.foreach_segment(GrainSize(512), [&](const IndexMaskSegment selection_segment) {
581 /* Evaluate generic point attributes directly to the result attributes. */
582 for (const int i_attribute : attributes.dst.index_range()) {
583 for (const int i_curve : selection_segment) {
584 const IndexRange src_points = src_points_by_curve[i_curve];
585 const IndexRange dst_points = dst_points_by_curve[i_curve];
586 src_curves.interpolate_to_evaluated(i_curve,
587 attributes.src[i_attribute].slice(src_points),
588 attributes.dst[i_attribute].slice(dst_points));
589 }
590 }
591
592 auto copy_evaluated_data = [&](const Span<float3> src, MutableSpan<float3> dst) {
593 for (const int i_curve : selection_segment) {
594 const IndexRange src_points = src_evaluated_points_by_curve[i_curve];
595 const IndexRange dst_points = dst_points_by_curve[i_curve];
596 dst.slice(dst_points).copy_from(src.slice(src_points));
597 }
598 };
599
600 /* Copy the evaluated positions to the selected curves. */
601 copy_evaluated_data(evaluated_positions, dst_positions);
602
603 if (!attributes.dst_tangents.is_empty()) {
604 copy_evaluated_data(attributes.src_evaluated_tangents, attributes.dst_tangents);
605 normalize_curve_point_data(selection_segment, dst_points_by_curve, attributes.dst_tangents);
606 }
607 if (!attributes.dst_normals.is_empty()) {
608 copy_evaluated_data(attributes.src_evaluated_normals, attributes.dst_normals);
609 normalize_curve_point_data(selection_segment, dst_points_by_curve, attributes.dst_normals);
610 }
611
612 /* Fill the default value for non-interpolating attributes that still must be copied. */
613 for (GMutableSpan dst : attributes.dst_no_interpolation) {
614 for (const int i_curve : selection_segment) {
615 const IndexRange dst_points = dst_points_by_curve[i_curve];
616 dst.type().value_initialize_n(dst.slice(dst_points).data(), dst_points.size());
617 }
618 }
619 });
620
621 copy_or_defaults_for_unselected_curves(src_curves, unselected, attributes, dst_curves);
622
623 for (bke::GSpanAttributeWriter &attribute : attributes.dst_attributes) {
624 attribute.finish();
625 }
626
627 bke::curves::nurbs::copy_custom_knots(src_curves, selection, dst_curves);
628 return dst_curves;
629}
630
632 const fn::FieldContext &field_context,
633 const fn::Field<bool> &selection_field,
634 const ResampleCurvesOutputAttributeIDs &output_ids)
635{
636 if (src_curves.curves_range().is_empty()) {
637 return {};
638 }
639 fn::FieldEvaluator evaluator{field_context, src_curves.curves_num()};
640 evaluator.set_selection(selection_field);
641 evaluator.evaluate();
643 src_curves, evaluator.get_evaluated_selection_as_mask(), output_ids);
644}
645
646} // namespace blender::geometry
Low-level operations for curves.
Low-level operations for curves.
support for deformation groups and hooks.
void BKE_defgroup_copy_list(ListBase *outbase, const ListBase *inbase)
Definition deform.cc:73
#define BLI_assert(a)
Definition BLI_assert.h:46
#define UNLIKELY(x)
#define ELEM(...)
BMesh const char void * data
long long int int64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
Span< T > as_span() const
Definition BLI_array.hh:243
MutableSpan< T > as_mutable_span()
Definition BLI_array.hh:248
void value_initialize_n(void *ptr, int64_t n) const
GMutableSpan slice(const int64_t start, int64_t size) const
const CPPType & type() const
MutableSpan< T > typed() const
static constexpr size_t min_alignment
constexpr int64_t size() const
constexpr bool is_empty() const
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
Definition BLI_span.hh:573
constexpr MutableSpan< NewT > cast() const
Definition BLI_span.hh:749
constexpr MutableSpan drop_back(const int64_t n) const
Definition BLI_span.hh:618
constexpr Span< T > as_span() const
Definition BLI_span.hh:661
constexpr T * end() const
Definition BLI_span.hh:548
constexpr T * begin() const
Definition BLI_span.hh:544
constexpr T & last(const int64_t n=0) const
Definition BLI_span.hh:689
NonCopyable(const NonCopyable &other)=delete
NonMovable(NonMovable &&other)=delete
bool contains(const Key &key) const
Definition BLI_set.hh:310
constexpr Span slice(int64_t start, int64_t size) const
Definition BLI_span.hh:137
constexpr IndexRange index_range() const
Definition BLI_span.hh:401
constexpr bool is_empty() const
Definition BLI_span.hh:260
void add_new(const Key &key)
void remove_contained(const Key &key)
void append(const T &value)
void resize(const int64_t new_size)
MutableSpan< T > as_mutable_span()
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
GAttributeReader lookup(const StringRef attribute_id) const
MutableSpan< float3 > positions_for_write()
OffsetIndices< int > points_by_curve() const
void ensure_can_interpolate_to_evaluated() const
IndexRange curves_range() const
const std::array< int, CURVE_TYPES_NUM > & curve_type_counts() const
MutableAttributeAccessor attributes_for_write()
Span< float > evaluated_lengths_for_curve(int curve_index, bool cyclic) const
Span< float3 > evaluated_tangents() const
void interpolate_to_evaluated(int curve_index, GSpan src, GMutableSpan dst) const
Span< float3 > evaluated_normals() const
Span< float3 > positions() const
OffsetIndices< int > evaluated_points_by_curve() const
void resize(int points_num, int curves_num)
void fill_curve_types(CurveType type)
AttributeAccessor attributes() const
float evaluated_length_total_for_curve(int curve_index, bool cyclic) const
MutableSpan< int > offsets_for_write()
Span< float3 > evaluated_positions() const
VArray< int8_t > curve_types() const
VArray< bool > cyclic() const
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef attribute_id, AttrDomain domain, AttrType data_type)
void set_selection(Field< bool > selection)
Definition FN_field.hh:383
IndexMask get_evaluated_selection_as_mask() const
Definition field.cc:817
int add_with_destination(GField field, GVMutableArray dst)
Definition field.cc:738
static std::shared_ptr< FieldOperation > from(std::shared_ptr< const mf::MultiFunction > function, Vector< GField > inputs={})
Definition FN_field.hh:242
IndexMask complement(const IndexMask &universe, IndexMaskMemory &memory) const
void foreach_index(Fn &&fn) const
void foreach_segment(Fn &&fn) const
OffsetIndices slice(const IndexRange range) const
int count
#define T
void copy(const GVArray &src, GMutableSpan dst, int64_t grain_size=4096)
void copy_group_to_group(OffsetIndices< int > src_offsets, OffsetIndices< int > dst_offsets, const IndexMask &selection, GSpan src, GMutableSpan dst)
void convert_to_static_type(const CPPType &cpp_type, const Func &func)
void copy_custom_knots(const bke::CurvesGeometry &src_curves, const IndexMask &exclude_curves, bke::CurvesGeometry &dst_curves)
bke::CurvesGeometry copy_only_curve_domain(const bke::CurvesGeometry &src_curves)
void fill_points(OffsetIndices< int > points_by_curve, const IndexMask &curve_selection, GPointer value, GMutableSpan dst)
bool attribute_name_is_anonymous(const StringRef name)
AttrType cpp_type_to_attribute_type(const CPPType &type)
GField make_constant_field(const CPPType &type, const void *value)
Definition field.cc:528
static fn::Field< int > get_count_input_max_one(const fn::Field< int > &count_field)
static AttributesForInterpolation retrieve_attribute_spans(const Span< StringRef > ids, const CurvesGeometry &src_from_curves, const CurvesGeometry &src_to_curves, const bke::AttrDomain domain, CurvesGeometry &dst_curves)
static void normalize_span(MutableSpan< float3 > data)
static void copy_or_defaults_for_unselected_curves(const CurvesGeometry &src_curves, const IndexMask &unselected_curves, const AttributesForResample &attributes, CurvesGeometry &dst_curves)
CurvesGeometry resample_to_count(const CurvesGeometry &src_curves, const IndexMask &selection, const VArray< int > &counts, const ResampleCurvesOutputAttributeIDs &output_ids={})
static bool interpolate_attribute_to_poly_curve(const StringRef attribute_id)
CurvesGeometry resample_to_evaluated(const CurvesGeometry &src_curves, const IndexMask &selection, const ResampleCurvesOutputAttributeIDs &output_ids={})
static int get_count_from_length(const float curve_length, const float sample_length, const bool keep_last_segment)
CurvesGeometry resample_to_length(const CurvesGeometry &src_curves, const IndexMask &selection, const VArray< float > &sample_lengths, const ResampleCurvesOutputAttributeIDs &output_ids={}, bool keep_last_segment=false)
static void resample_to_uniform(const CurvesGeometry &src_curves, const IndexMask &selection, const ResampleCurvesOutputAttributeIDs &output_ids, CurvesGeometry &dst_curves)
static bool interpolate_attribute_to_curves(const StringRef attribute_id, const std::array< int, CURVE_TYPES_NUM > &type_counts)
static AttributesForInterpolation gather_point_attributes_to_interpolate(const CurvesGeometry &from_curves, const CurvesGeometry &to_curves, CurvesGeometry &dst_curves)
static fn::Field< int > get_count_input_from_length(const fn::Field< float > &length_field, const bool keep_last_segment)
static void normalize_curve_point_data(const IndexMaskSegment curve_selection, const OffsetIndices< int > points_by_curve, MutableSpan< float3 > data)
void interpolate(const Span< T > src, const Span< int > indices, const Span< float > factors, MutableSpan< T > dst)
void sample_uniform(Span< float > accumulated_segment_lengths, bool include_last_point, MutableSpan< int > r_segment_indices, MutableSpan< float > r_factors)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
void copy_group_sizes(OffsetIndices< int > offsets, const IndexMask &mask, MutableSpan< int > sizes)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
std::optional< OffsetIndices< int > > accumulate_counts_to_offsets_with_overflow_check(MutableSpan< int > counts_to_offsets, int start_offset=0)
VecBase< float, 3 > float3
ListBase vertex_group_names
Vector< bke::GSpanAttributeWriter > dst_attributes
GuardedAlignedAllocator<> AllocatorType
MutableSpan< T > resize(const int64_t size)
std::array< std::byte, 1024 > inline_buffer
Vector< std::byte, 0, AllocatorType > heap_allocated
i
Definition text_draw.cc:230