30 .evaluated_geometry_field()
33 "A curve is created for every distinct group ID. All points with the same ID are put "
34 "into the same curve");
36 .evaluated_geometry_field()
38 .description(
"Determines the order of points in each curve");
47 const auto comparator = [&](
const int index_a,
const int index_b) {
48 const float weight_a = weights[index_a];
49 const float weight_b = weights[index_b];
50 if (weight_a == weight_b) [[unlikely]] {
52 return index_a < index_b;
54 return weight_a < weight_b;
58 for (const int group_index : range) {
59 MutableSpan<int> group = indices.slice(offsets[group_index]);
60 parallel_sort(group.begin(), group.end(), comparator);
79 r_identifiers_to_indices, indices.
index_range(), indices);
80 r_identifiers_to_indices.
copy_from(indices);
88 const int domain_size = weights_varray.
size();
96 curves.attributes_for_write());
108 curves.attributes_for_write());
117 const int domain_size = points.
totpoint;
118 if (domain_size == 0) {
124 evaluator.
add(group_id_field);
125 evaluator.
add(weight_field);
138 if (total_curves == 1) {
152 const bool sort_by_weight = !weights_varray.is_single();
154 if (sort_by_weight) {
164 curves.attributes_for_write());
181 *points, group_id_field, weight_field, attribute_filter);
187 params.
set_output(
"Curves"_ustr, std::move(geometry_set));
195 ntype.
ui_name =
"Points to Curves";
196 ntype.
ui_description =
"Split all points to curve by its group ID and reorder by weight";
Low-level operations for curves.
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_POINTS_TO_CURVES
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void sort(btMatrix3x3 &U, btVector3 &sigma, btMatrix3x3 &V, int t)
Helper function of 3X3 SVD for sorting singular values.
MutableSpan< T > as_mutable_span()
IndexRange index_range() const
constexpr int64_t size() const
constexpr void fill(const T &value) const
constexpr void copy_from(Span< T > values) const
void materialize(MutableSpan< T > r_span) const
int add(GField field, GVArray *varray_ptr)
const GVArray & get_evaluated(const int field_index) const
NodeAttributeFilter get_attribute_filter(const UString output_identifier) const
T extract_input(const UString identifier)
void set_output(const UString identifier, T &&value)
IndexRange index_range() const
void fill_index_range(MutableSpan< T > span, const T start=0)
int group_ids_to_indices(Span< int > ids, const IndexMask &mask, MutableSpan< int > r_group_indices, Vector< int > *r_first_indices=nullptr)
void node_register_type(bNodeType &ntype)
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)
Curves * curves_new_nomain_single(int points_num, CurveType type)
Curves * curves_new_nomain(int points_num, int curves_num)
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
void debug_randomize_curve_order(bke::CurvesGeometry *curves)
static void find_points_by_group_index(const Span< int > indices_of_curves, const bool sort, MutableSpan< int > r_offsets, MutableSpan< int > r_indices)
static void node_geo_exec(GeoNodeExecParams params)
static Curves * curve_from_points(const AttributeAccessor attributes, const VArray< float > &weights_varray, const AttributeFilter &attribute_filter)
static void grouped_sort(const OffsetIndices< int > offsets, const Span< float > weights, MutableSpan< int > indices)
static void node_declare(NodeDeclarationBuilder &b)
static Curves * curves_from_points(const PointCloud &points, const Field< int > &group_id_field, const Field< float > &weight_field, const AttributeFilter &attribute_filter)
static int identifiers_to_indices(MutableSpan< int > r_identifiers_to_indices)
static void node_register()
OffsetIndices< int > build_reverse_offsets(Span< int > indices, MutableSpan< int > offsets)
void reverse_indices_in_groups(Span< int > group_indices, OffsetIndices< int > offsets, MutableSpan< int > results, bool sort=true)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void keep_only(Span< GeometryComponent::Type > component_types)
void replace_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
const PointCloud * get_pointcloud() const
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
const char * enum_name_legacy
NodeDeclareFunction declare