34 bool has_cycle =
false;
35 auto push_curve = [&](
const int curve_i) ->
bool {
36 if ((flags[curve_i] &
Inserted) != 0) {
39 if ((flags[curve_i] &
OnStack) != 0) {
52 const int current = stack.
peek();
54 const int next = connect_to_curve[current];
56 if (push_curve(next)) {
77 for (
const int curve_i : range) {
78 const int next = connect_to_curve[curve_i];
80 is_start_curve[next] =
false;
87 for (
const int curve_i : range) {
88 if (is_start_curve[curve_i]) {
90 connect_to_curve, flags, curve_i, [&](
const int index) { is_reachable[
index] =
true; });
98 for (
const int curve_i : range) {
99 if (is_start_curve[curve_i] || !is_reachable[curve_i]) {
101 connect_to_curve, flags, curve_i, [&](
const int index) { sorted_curves.
append(
index); });
106 return sorted_curves;
117 const int mirror_i = span.
size() - 1 - i;
137 if (iter.
domain != domain) {
158 for (const int new_i : range) {
159 const int old_i = old_by_new_map[new_i];
160 const bool flip = flip_direction[old_i];
162 GMutableSpan dst_span = dst.span.slice(dst_offsets[new_i]);
163 array_utils::copy(src.slice(src_offsets[old_i]), dst_span);
165 reverse_order(dst_span);
214 for (
const int dst_i : old_by_new_map.
index_range()) {
215 const int src_i = old_by_new_map[dst_i];
216 new_by_old_map[src_i] = dst_i;
219 r_joined_curve_offsets.
reserve(curves_range.
size() + 1);
222 int start_index = -1;
223 for (
const int dst_i : curves_range) {
224 const int src_i = old_by_new_map[dst_i];
227 const bool src_cyclic = cyclic[src_i];
229 if (start_index < 0) {
230 r_joined_curve_offsets.
append(0);
231 r_joined_cyclic.
append(src_cyclic);
235 ++r_joined_curve_offsets.
last();
237 const int src_connect_to = connect_to_curve[src_i];
238 const bool is_connected = curves_range.
contains(src_connect_to);
239 const int dst_connect_to = is_connected ? new_by_old_map[src_connect_to] : -1;
242 if (dst_connect_to != dst_i + 1) {
245 const bool is_chain = (is_connected || dst_i != start_index);
247 r_joined_cyclic.
last() = (dst_connect_to == start_index);
254 r_joined_curve_offsets.
append(0);
263 old_curves_by_new.
size());
270 const Span<int> old_by_new_map = old_curves_by_new.
data().drop_back(1);
282 const IndexRange old_curves = old_curves_by_new[new_i];
311 src_curves, old_by_new_map, connect_to_curve, src_cyclic, joined_curve_offsets, cyclic);
314 src_curves, old_by_new_map, flip_direction);
330 return merged_curves;
Low-level operations for curves.
#define BUFFER_FOR_CPP_TYPE_VALUE(type, variable_name)
void fill(const T &value) const
void move_assign(void *src, void *dst) const
void destruct(void *ptr) const
void default_construct(void *ptr) const
const CPPType & type() const
CommonVArrayInfo common_info() const
const CPPType & type() const
constexpr IndexRange drop_back(int64_t n) const
constexpr int64_t size() const
constexpr IndexRange()=default
constexpr bool contains(int64_t value) const
constexpr void fill(const T &value) const
constexpr Span< T > as_span() const
constexpr IndexRange index_range() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
void push(const T &value)
void append(const T &value)
const T & last(const int64_t n=0) const
void reserve(const int64_t min_capacity)
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
GAttributeReader get() const
VArray< bool > cyclic() const
AttributeAccessor attributes() const
void tag_topology_changed()
bool nurbs_has_custom_knots() const
IndexRange curves_range() const
Span< int > offsets() const
MutableSpan< int > offsets_for_write()
MutableSpan< bool > cyclic_for_write()
OffsetIndices< int > points_by_curve() const
MutableAttributeAccessor attributes_for_write()
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef name, AttrDomain domain, AttrType data_type)
void update_custom_knot_modes(const IndexMask &mask, const KnotsMode mode_for_regular, const KnotsMode mode_for_cyclic, bke::CurvesGeometry &curves)
auto attribute_filter_from_skip_ref(const Span< StringRef > skip)
void copy_attributes(const AttributeAccessor src_attributes, AttrDomain src_domain, AttrDomain dst_domain, const AttributeFilter &attribute_filter, MutableAttributeAccessor dst_attributes)
void gather_attributes(AttributeAccessor src_attributes, AttrDomain src_domain, AttrDomain dst_domain, const AttributeFilter &attribute_filter, const IndexMask &selection, MutableAttributeAccessor dst_attributes)
static Vector< int > toposort_connected_curves(const Span< int > connect_to_curve)
static bke::CurvesGeometry reorder_and_flip_curves(const bke::CurvesGeometry &src_curves, const Span< int > old_by_new_map, const Span< bool > flip_direction)
static void foreach_connected_curve(const Span< int > connect_to_curve, MutableSpan< uint8_t > flags, const int start, Fn fn)
static void reorder_and_flip_attributes_group_to_group(const bke::AttributeAccessor src_attributes, const bke::AttrDomain domain, const OffsetIndices< int > src_offsets, const OffsetIndices< int > dst_offsets, const Span< int > old_by_new_map, const Span< bool > flip_direction, bke::MutableAttributeAccessor dst_attributes)
static void reverse_order(GMutableSpan span)
static bke::CurvesGeometry join_curves_ranges(const bke::CurvesGeometry &src_curves, const OffsetIndices< int > old_curves_by_new)
static void find_connected_ranges(const bke::CurvesGeometry &src_curves, const Span< int > old_by_new_map, Span< int > connect_to_curve, Span< bool > cyclic, Vector< int > &r_joined_curve_offsets, Vector< bool > &r_joined_cyclic)
bke::CurvesGeometry curves_merge_endpoints(const bke::CurvesGeometry &src_curves, Span< int > connect_to_curve, Span< bool > flip_direction, const bke::AttributeFilter &attribute_filter)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
void gather_group_sizes(OffsetIndices< int > offsets, const IndexMask &mask, MutableSpan< int > sizes)
int sum_group_sizes(OffsetIndices< int > offsets, const IndexMask &mask)
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)
void BKE_defgroup_copy_list(ListBaseT< bDeformGroup > *outbase, const ListBaseT< bDeformGroup > *inbase)
int attributes_active_index
ListBaseT< struct bDeformGroup > vertex_group_names