47 if (std::any_of(sizes_ptr, sizes_ptr + sizes_num, [](
const int size) {
return size < 1; })) {
57static std::optional<IndexMask> rna_indices_to_mask(
const IndexRange universe,
58 const int *indices_ptr,
59 const int indices_num,
67 if (std::any_of(
indices.begin(),
indices.end(), [&](
const int index) {
68 return !universe.contains(index);
88 const int *indices_ptr,
89 const int indices_num)
93 const std::optional<IndexMask> curves_to_delete = rna_indices_to_mask(
94 curves.
curves_range(), indices_ptr, indices_num, *reports, memory);
95 if (!curves_to_delete) {
104 const int *sizes_ptr,
106 const int *indices_ptr,
107 const int indices_num)
110 const Span<int> new_sizes(sizes_ptr, sizes_num);
111 if (std::any_of(new_sizes.begin(), new_sizes.end(), [](
const int size) { return size < 1; })) {
116 const std::optional<IndexMask> curves_to_resize = rna_indices_to_mask(
117 curves.
curves_range(), indices_ptr, indices_num, *reports, memory);
118 if (!curves_to_resize) {
121 if (curves_to_resize->size() != sizes_num) {
131 const int *reorder_indices_ptr,
132 const int reorder_indices_num)
135 const Span<int> new_to_old_indices_map(reorder_indices_ptr, reorder_indices_num);
136 if (curves.
curves_num() != reorder_indices_num) {
138 reports,
RPT_ERROR,
"Length of reorder indices must be the same as the number of curves");
141 if (std::any_of(new_to_old_indices_map.begin(),
142 new_to_old_indices_map.end(),
143 [&](
const int index) { return !curves.curves_range().contains(index); }))
148 if (
Set(new_to_old_indices_map).
size() != reorder_indices_num) {
159 const int *indices_ptr,
160 const int indices_num)
163 const std::optional<IndexMask> selection = rna_indices_to_mask(
164 curves.
curves_range(), indices_ptr, indices_num, *reports, memory);
174static void rna_Curves_add_curves(
Curves *curves_id,
181 if (!rna_CurvesGeometry_add_curves(curves, reports, sizes, sizes_num)) {
186 if (curves_id->
id.
us > 0) {
192static void rna_Curves_remove_curves(
Curves *curves_id,
194 const int *indices_ptr,
195 const int indices_num)
199 if (!rna_CurvesGeometry_remove_curves(curves, reports, indices_ptr, indices_num)) {
204 if (curves_id->
id.
us > 0) {
210static void rna_Curves_resize_curves(
Curves *curves_id,
212 const int *sizes_ptr,
214 const int *indices_ptr,
215 const int indices_num)
219 if (!rna_CurvesGeometry_resize_curves(
220 curves, reports, sizes_ptr, sizes_num, indices_ptr, indices_num))
226 if (curves_id->
id.
us > 0) {
232static void rna_Curves_reorder_curves(
Curves *curves_id,
234 const int *reorder_indices_ptr,
235 const int reorder_indices_num)
239 if (!rna_CurvesGeometry_reorder_curves(
240 curves, reports, reorder_indices_ptr, reorder_indices_num))
246 if (curves_id->
id.
us > 0) {
252static void rna_Curves_set_types(
Curves *curves_id,
255 const int *indices_ptr,
256 const int indices_num)
260 if (!rna_CurvesGeometry_set_types(curves, reports, type, indices_ptr, indices_num)) {
264 if (curves_id->
id.
us > 0) {
270static const char *rna_Curves_unit_test_compare(
Curves *curves1,
Curves *curves2,
float threshold)
300 "The number of points in each curve",
307 "Remove all curves. If indices are provided, remove only the "
308 "curves with the given indices.");
317 "The indices of the curves to remove",
325 "Resize all existing curves. If indices are provided, resize only the curves with the given "
326 "indices. If the new size for a curve is smaller, the curve is trimmed. If "
327 "the new size for a curve is larger, the new end values are default initialized.");
336 "The number of points in each curve",
347 "The indices of the curves to resize",
352 func =
RNA_def_function(srna,
"reorder_curves",
"rna_Curves_reorder_curves");
362 "The new index for each of the curves",
369 "Set the curve type. If indices are provided, set only the "
370 "types with the given curve indices.");
380 "The indices of the curves to resize",
385 func =
RNA_def_function(srna,
"unit_test_compare",
"rna_Curves_unit_test_compare");
393 "Comparison tolerance threshold",
398 func,
"result",
"nothing", 64,
"Return value",
"String description of result of comparison");
Low-level operations for curves.
void BKE_report(ReportList *reports, eReportType type, const char *message)
void DEG_id_tag_update(ID *id, unsigned int flags)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static IndexMask from_indices(Span< T > indices, IndexMaskMemory &memory)
IndexRange curves_range() const
void tag_topology_changed()
void remove_curves(const IndexMask &curves_to_delete, const AttributeFilter &attribute_filter)
void fill_curve_types(CurveType type)
std::optional< GeoMismatch > compare_curves(const CurvesGeometry &curves1, const CurvesGeometry &curves2, float threshold)
Checks if the two curves geometries are different, returning the type of mismatch if any....
const char * mismatch_to_string(const GeoMismatch &mismatch)
void resize_curves(bke::CurvesGeometry &curves, const IndexMask &curves_to_resize, const Span< int > new_sizes)
void add_curves(bke::CurvesGeometry &curves, const Span< int > new_sizes)
void reorder_curves(bke::CurvesGeometry &curves, const Span< int > old_by_new_indices_map)
const EnumPropertyItem rna_enum_curves_type_items[]
void RNA_api_curves(StructRNA *srna)
PropertyRNA * RNA_def_float_factor(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void WM_main_add_notifier(uint type, void *reference)