27 .structure_type(StructureType::List)
29 .description(
"A list of the point positions in all curves");
31 .structure_type(StructureType::List)
34 "A list with a size one larger than the number of curves storing the first point index "
35 "of each curve and a final value for the total number of points. This is a prefix sum "
36 "of the curve sizes");
43 const int points_num = positions_list.
size();
44 const int curves_num = curve_offsets_list.
size() - 1;
53 if (points_num < curves_num) {
56 "Number of curves must be less than or equal to the number of points");
59 const std::variant<Span<int>,
const int *> offset_values = curve_offsets_list.
values();
61 if (curve_offsets->first() != 0) {
65 if (curve_offsets->last() != points_num) {
67 "Curve sizes must sum to the number of points");
71 curve_offsets->drop_back(1).index_range(),
74 [&](
const IndexRange range,
const bool sizes_greater_zero) {
75 if (!sizes_greater_zero) {
78 for (
const int i : range) {
79 const int curr = (*curve_offsets)[i];
80 const int next = (*curve_offsets)[i + 1];
87 std::logical_and<>());
88 if (!sizes_greater_zero) {
102 const int points_num = positions_list.
size();
108 if (
const auto *positions_array_data = std::get_if<nodes::GList::ArrayData>(
109 &positions_list.
data()))
117 else if (
const auto *positions_single_value = std::get_if<nodes::GList::SingleData>(
118 &positions_list.
data()))
131 const auto *curve_offset_data = std::get_if<nodes::GList::ArrayData>(&curve_offsets_list.
data());
134 const int curves_num = curve_offsets_list.
size() - 1;
136 curves.attribute_storage.wrap().resize(AttrDomain::Curve, curves_num);
139 static_cast<int *
>(
const_cast<void *
>(curve_offset_data->data)),
140 &(*curve_offset_data->sharing_info),
142 &
curves.runtime->curve_offsets_sharing_info);
143 curves.curve_num = curves_num;
155 if (!positions_glist || !curve_offsets_glist) {
161 BLI_assert(curve_offsets_glist->cpp_type().is<
int>());
163 const List<int> &curve_offsets_list = curve_offsets_glist->typed<
int>();
178 ntype.
ui_name =
"Construct Curves";
Low-level operations for curves.
#define NODE_CLASS_GEOMETRY
#define NOD_REGISTER_NODE(REGISTER_FUNC)
const CPPType & cpp_type() const
const List< T > & typed() const
void error_message_add(const NodeWarningType type, StringRef message) const
T extract_input(const UString identifier)
bool output_is_required(const UString identifier) const
void set_default_remaining_outputs()
void set_output(const UString identifier, T &&value)
VArray< T > varray() const
std::variant< Span< T >, const T * > values() const
void node_register_type(bNodeType &ntype)
CurvesGeometry curves_new_no_attributes(int point_num, int curve_num)
Curves * curves_new_nomain(int points_num, int curves_num)
void copy_shared_pointer(T *src_ptr, const ImplicitSharingInfo *src_sharing_info, T **r_dst_ptr, const ImplicitSharingInfo **r_dst_sharing_info)
static bool validate_inputs(GeoNodeExecParams ¶ms, const List< float3 > &positions_list, const List< int > &curve_offsets_list)
static Curves * create_curves_from_topology_info(const List< float3 > &positions_list, const List< int > &curve_offsets_list)
static void node_declare(NodeDeclarationBuilder &b)
static void node_register()
static void node_geo_exec(GeoNodeExecParams params)
Value parallel_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
VecBase< float, 3 > float3
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
NodeDeclareFunction declare
static GeometrySet from_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)