Blender V4.5
blender::bke::curves::nurbs Namespace Reference

Classes

struct  BasisCache

Functions

bool check_valid_num_and_order (int points_num, int8_t order, bool cyclic, KnotsMode knots_mode)
int calculate_evaluated_num (int points_num, int8_t order, bool cyclic, int resolution, KnotsMode knots_mode)
int knots_num (int points_num, int8_t order, bool cyclic)
void load_curve_knots (KnotsMode mode, int points_num, int8_t order, bool cyclic, IndexRange curve_knots, Span< float > custom_knots, MutableSpan< float > knots)
void calculate_knots (int points_num, KnotsMode mode, int8_t order, bool cyclic, MutableSpan< float > knots)
Vector< int > calculate_multiplicity_sequence (Span< float > knots)
void calculate_basis_cache (int points_num, int evaluated_num, int8_t order, bool cyclic, Span< float > knots, BasisCache &basis_cache)
void interpolate_to_evaluated (const BasisCache &basis_cache, int8_t order, Span< float > control_weights, GSpan src, GMutableSpan dst)
void gather_custom_knots (const bke::CurvesGeometry &src, const IndexMask &src_curves, int dst_curve_offset, bke::CurvesGeometry &dst)
void update_custom_knot_modes (const IndexMask &mask, const KnotsMode mode_for_regular, const KnotsMode mode_for_cyclic, bke::CurvesGeometry &curves)
void copy_custom_knots (const bke::CurvesGeometry &src_curves, const IndexMask &exclude_curves, bke::CurvesGeometry &dst_curves)
static void copy_custom_knots (const int8_t order, const bool cyclic, const Span< float > custom_knots, MutableSpan< float > knots)
static void calculate_basis_for_point (const float parameter, const int points_num, const int degree, const Span< float > knots, MutableSpan< float > r_weights, int &r_start_index)
template<typename T>
static void interpolate_to_evaluated (const BasisCache &basis_cache, const int8_t order, const Span< T > src, MutableSpan< T > dst)
template<typename T>
static void interpolate_to_evaluated_rational (const BasisCache &basis_cache, const int8_t order, const Span< float > control_weights, const Span< T > src, MutableSpan< T > dst)

Function Documentation

◆ calculate_basis_cache()

void blender::bke::curves::nurbs::calculate_basis_cache ( int points_num,
int evaluated_num,
int8_t order,
bool cyclic,
Span< float > knots,
BasisCache & basis_cache )

Based on the knots, the order, and other properties of a NURBS curve, calculate a cache that can be used to more simply interpolate attributes to the evaluated points later. The cache includes two pieces of information for every evaluated point: the first control point that influences it, and a weight for each control point.

Definition at line 206 of file curve_nurbs.cc.

References BLI_assert, calculate_basis_for_point(), i, blender::Vector< T, InlineBufferCapacity, Allocator >::resize(), Vector< T, InlineBufferCapacity, Allocator >::resize(), blender::bke::curves::segments_num(), blender::MutableSpan< T >::slice(), blender::bke::curves::nurbs::BasisCache::start_indices, step, and blender::bke::curves::nurbs::BasisCache::weights.

◆ calculate_basis_for_point()

void blender::bke::curves::nurbs::calculate_basis_for_point ( const float parameter,
const int points_num,
const int degree,
const Span< float > knots,
MutableSpan< float > r_weights,
int & r_start_index )
static

◆ calculate_evaluated_num()

int blender::bke::curves::nurbs::calculate_evaluated_num ( int points_num,
int8_t order,
bool cyclic,
int resolution,
KnotsMode knots_mode )

Calculate the standard evaluated size for a NURBS curve, using the standard that the resolution is multiplied by the number of segments between the control points.

Note
Though the number of evaluated points is rather arbitrary, it's useful to have a standard for predictability and so that cached basis weights of NURBS curves with these properties can be shared.

Definition at line 35 of file curve_nurbs.cc.

References check_valid_num_and_order(), and blender::bke::curves::segments_num().

Referenced by blender::bke::calculate_evaluated_offsets().

◆ calculate_knots()

void blender::bke::curves::nurbs::calculate_knots ( int points_num,
KnotsMode mode,
int8_t order,
bool cyclic,
MutableSpan< float > knots )

Calculate the knots for a curve given its properties, based on built-in standards defined by KnotsMode.

Note
Theoretically any sorted values can be used for NURBS knots, but calculating based on standard modes allows useful presets, automatic recalculation when the number of points changes, and is generally more intuitive than defining the knot vector manually.

Definition at line 71 of file curve_nurbs.cc.

References BLI_assert, ELEM, i, knots_num(), min_ii(), NURBS_KNOT_MODE_BEZIER, NURBS_KNOT_MODE_ENDPOINT, NURBS_KNOT_MODE_ENDPOINT_BEZIER, blender::MutableSpan< T >::size(), and UNUSED_VARS_NDEBUG.

Referenced by blender::io::obj::OBJCurve::get_knots_u(), load_curve_knots(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), blender::bke::tests::TEST(), and blender::bke::tests::TEST().

◆ calculate_multiplicity_sequence()

◆ check_valid_num_and_order()

bool blender::bke::curves::nurbs::check_valid_num_and_order ( int points_num,
int8_t order,
bool cyclic,
KnotsMode knots_mode )

Checks the conditions that a NURBS curve needs to evaluate.

Definition at line 16 of file curve_nurbs.cc.

References ELEM, NURBS_KNOT_MODE_BEZIER, and NURBS_KNOT_MODE_ENDPOINT_BEZIER.

Referenced by calculate_evaluated_num().

◆ copy_custom_knots() [1/2]

◆ copy_custom_knots() [2/2]

void blender::bke::curves::nurbs::copy_custom_knots ( const int8_t order,
const bool cyclic,
const Span< float > custom_knots,
MutableSpan< float > knots )
static

◆ gather_custom_knots()

void blender::bke::curves::nurbs::gather_custom_knots ( const bke::CurvesGeometry & src,
const IndexMask & src_curves,
int dst_curve_offset,
bke::CurvesGeometry & dst )

◆ interpolate_to_evaluated() [1/2]

template<typename T>
void blender::bke::curves::nurbs::interpolate_to_evaluated ( const BasisCache & basis_cache,
const int8_t order,
const Span< T > src,
MutableSpan< T > dst )
static

◆ interpolate_to_evaluated() [2/2]

void blender::bke::curves::nurbs::interpolate_to_evaluated ( const BasisCache & basis_cache,
int8_t order,
Span< float > control_weights,
GSpan src,
GMutableSpan dst )

Using a "basis cache" generated by BasisCache, interpolate attribute values to the evaluated points. The number of evaluated points is determined by the #basis_cache argument.

Parameters
control_weightsAn optional span of control point weights, which must have the same size as the number of control points in the curve if provided. Using this argument gives a NURBS curve the "Rational" behavior that's part of its acronym; otherwise it is a NUBS.

Definition at line 287 of file curve_nurbs.cc.

References BLI_assert, blender::bke::attribute_math::convert_to_static_type(), blender::GMutableSpan::copy_from(), interpolate_to_evaluated(), blender::bke::curves::nurbs::BasisCache::invalid, blender::GMutableSpan::size(), blender::Vector< T, InlineBufferCapacity, Allocator >::size(), blender::bke::curves::nurbs::BasisCache::start_indices, and blender::GSpan::type().

Referenced by blender::bke::evaluate_generic_data_for_curve(), blender::bke::CurvesGeometry::evaluated_positions(), and interpolate_to_evaluated().

◆ interpolate_to_evaluated_rational()

template<typename T>
void blender::bke::curves::nurbs::interpolate_to_evaluated_rational ( const BasisCache & basis_cache,
const int8_t order,
const Span< float > control_weights,
const Span< T > src,
MutableSpan< T > dst )
static

◆ knots_num()

int blender::bke::curves::nurbs::knots_num ( int points_num,
int8_t order,
bool cyclic )

◆ load_curve_knots()

void blender::bke::curves::nurbs::load_curve_knots ( KnotsMode mode,
int points_num,
int8_t order,
bool cyclic,
IndexRange curve_knots,
Span< float > custom_knots,
MutableSpan< float > knots )

Depending on KnotsMode calculates knots or copies custom knots into given MutableSpan. Adds order - 1 length tail for cyclic curves.

Definition at line 115 of file curve_nurbs.cc.

References BLI_assert, calculate_knots(), copy_custom_knots(), blender::IndexRange::is_empty(), blender::Span< T >::is_empty(), NURBS_KNOT_MODE_CUSTOM, and blender::Span< T >::slice().

Referenced by blender::io::usd::populate_curve_props_for_nurbs().

◆ update_custom_knot_modes()

void blender::bke::curves::nurbs::update_custom_knot_modes ( const IndexMask & mask,
const KnotsMode mode_for_regular,
const KnotsMode mode_for_cyclic,
bke::CurvesGeometry & curves )

Overwrites NURBS_KNOT_MODE_CUSTOM to given ones for regular and cyclic curves. The purpose is to update knot modes for curves when knot copying or calculation is not possible or too complex. Curve operators not supporting NURBS custom knots should call this function with IndexMask CurvesGeometry.curves_range(), if resulting curves are created by copying all attributes. This way NURBS_KNOT_MODE_CUSTOM values might be copied though custom knots not.

Definition at line 239 of file curves_utils.cc.

References mask(), and NURBS_KNOT_MODE_CUSTOM.

Referenced by copy_custom_knots(), blender::geometry::curves_merge_endpoints(), blender::ed::greasepencil::extrude_grease_pencil_curves(), blender::geometry::fillet_curves(), blender::geometry::remove_points_and_split(), blender::ed::curves::resize_curves(), and blender::geometry::trim_curves().