SFCGAL 2.3.0
SFCGAL::NURBSCurve Class Reference

Non-Uniform Rational B-Spline (NURBS) curve implementation. More...

#include <NURBSCurve.h>

Public Types

enum class  KnotMethod : std::uint8_t { UNIFORM , CHORD_LENGTH , CENTRIPETAL }
 Knot vector generation methods for parameterization. More...
enum class  EndCondition : std::uint8_t { CLAMPED , NATURAL , PERIODIC , TANGENT }
 End conditions for curve fitting and interpolation. More...
enum class  FitMethod : std::uint8_t { INTERPOLATE , APPROXIMATE }
 Curve fitting methods. More...
using FT = Kernel::FT
 Floating-point type for NURBS calculations.
using ControlPoint = Point
 Type for NURBS control points.
using Weight = FT
 Type for NURBS weights (positive values).
using Knot = FT
 Type for knot values in knot vector.
using Parameter = FT
 Type for curve parameter values.

Public Member Functions

 NURBSCurve ()
 Default constructor creating empty curve.
 NURBSCurve (const std::vector< Point > &controlPoints, unsigned int degree, KnotMethod knotMethod=KnotMethod::UNIFORM)
 Constructor with control points and uniform weights.
 NURBSCurve (const std::vector< Point > &controlPoints, const std::vector< FT > &weights, unsigned int degree, KnotMethod knotMethod=KnotMethod::UNIFORM)
 Constructor with control points and explicit weights.
 NURBSCurve (const std::vector< Point > &controlPoints, const std::vector< FT > &weights, unsigned int degree, const std::vector< Knot > &knotVector)
 Full constructor with all NURBS parameters.
 NURBSCurve (const NURBSCurve &other)=default
 Copy constructor.
auto operator= (const NURBSCurve &other) -> NURBSCurve &=default
 Assignment operator.
 ~NURBSCurve () override=default
 Destructor.
void accept (GeometryVisitor &visitor) override
 Accept visitor pattern for non-const operations.
void accept (ConstGeometryVisitor &visitor) const override
 Accept visitor pattern for const operations.
auto geometryTypeId () const -> GeometryType override
 Get the geometry type identifier.
auto geometryType () const -> std::string override
 Get the geometry type as string.
auto isEmpty () const -> bool override
 Check if curve is empty.
auto is3D () const -> bool override
 Check if curve is three-dimensional.
auto isMeasured () const -> bool override
 Check if curve has measure coordinates.
auto dropZ () -> bool override
 Drop Z coordinates from curve.
auto dropM () -> bool override
 Drop M coordinates from curve.
void swapXY () override
 Swap the X and Y coordinates of all control points and any stored fit data.
auto evaluate (Parameter parameter) const -> Point override
 Evaluate the curve at the given parameter and return the corresponding point in Cartesian space.
auto derivative (Parameter parameter, unsigned int order=1) const -> Point override
 Compute the derivative of the curve at the given parameter.
auto tangent (Parameter parameter) const -> Point override
 Return the unit tangent vector at the given parameter.
auto normal (Parameter parameter) const -> Point override
 Return the principal unit normal vector at the given parameter.
auto binormal (Parameter parameter) const -> Point override
 Return the unit binormal vector at the given parameter.
auto curvature (Parameter parameter) const -> FT override
 Compute the curvature scalar at the given parameter.
auto torsion (Parameter parameter) const -> FT override
 Compute the torsion scalar at the given parameter.
auto frenetFrame (Parameter parameter) const -> std::tuple< Point, Point, Point > override
 Return the Frenet frame at the given parameter as (tangent, normal, binormal).
auto toLineString (unsigned int numSegments=32) const -> std::unique_ptr< LineString > override
 Convert the curve to a LineString by sampling numSegments uniformly in parameter space.
auto toLineStringAdaptive (FT tolerance=FT(1e-3), unsigned int minSegments=8, unsigned int maxSegments=256) const -> std::unique_ptr< LineString > override
 Convert the curve to a LineString using adaptive subdivision until the polyline approximates the curve within tolerance, respecting minSegments and maxSegments bounds.
auto parameterBounds () const -> std::pair< Parameter, Parameter > override
 Return the parameter domain of the curve as [u_min, u_max].
auto isPeriodic () const -> bool override
 True if the curve is periodic (periodic knot structure and matching end conditions).
auto isPlanar (std::vector< FT > *plane=nullptr) const -> bool override
 Check whether the curve is planar.
auto isLinear () const -> bool override
 Determine whether the curve is geometrically linear (represents a straight line).
auto degree () const -> unsigned int override
 Return the polynomial degree of the curve.
auto length (Parameter from=Parameter(-1), Parameter to=Parameter(-1), FT tolerance=FT(1e-6)) const -> FT override
 Compute arc length between two parameters.
auto parameterAtLength (FT arcLength, FT tolerance=FT(1e-6)) const -> Parameter override
 Find the parameter corresponding to a given arc length measured from the start of the curve.
auto reparameterizeByArcLength () const -> std::unique_ptr< Curve > override
 Return a new Curve reparameterized by arc length (parameter runs proportionally to arc length).
auto split (Parameter parameter) const -> std::pair< std::unique_ptr< Curve >, std::unique_ptr< Curve > > override
 Split the curve at parameter into two curves [domain_start, parameter] and [parameter, domain_end].
auto subcurve (Parameter from, Parameter to) const -> std::unique_ptr< Curve > override
 Extract a subcurve between parameters from and to (inclusive of domain interval).
auto reverse () const -> std::unique_ptr< Curve > override
 Return a new Curve representing this curve with reversed parameter direction.
auto join (const Curve &other, Continuity continuity=Continuity::C0, FT tolerance=FT(1e-6)) const -> std::unique_ptr< Curve > override
 Join this curve with other producing a single curve if they can be connected within the requested continuity and tolerance.
auto closestPoint (const Point &point, Parameter *outParameter=nullptr) const -> Point override
 Project point onto the curve and return the closest point on the curve.
auto controlPoints () const -> const std::vector< Point > &
 Get control points array.
void setControlPoints (const std::vector< Point > &controlPoints)
 Set all control points with validation.
auto controlPointN (size_t index) -> Point &override
 Access control point for modification.
auto controlPointN (size_t index) const -> const Point &override
 Access control point for reading.
void setControlPoint (size_t index, const Point &point)
 Set individual control point with validation.
auto weights () const -> const std::vector< FT > &
 Get weights array.
void setWeights (const std::vector< FT > &weights)
 Set all weights with validation.
auto weight (size_t index) const -> FT override
 Get weight at specified index.
void setWeight (size_t index, const FT &weight)
 Set weight at specified index.
auto isRational () const -> bool override
 Check if curve uses non-uniform rational weights.
auto isBezier () const -> bool
 Return true when this NURBS curve is represented in Bezier form.
auto isBSpline () const -> bool
 Return true when the curve is a non-rational B-spline (uniform weights).
auto knotVector () const -> const std::vector< Knot > &
 Return the knot vector for this curve.
void setKnotVector (const std::vector< Knot > &knots)
 Set knot vector with full validation.
auto knot (size_t index) const -> Knot
 Get knot value at index.
auto knotMultiplicity (const Knot &value, const FT &tolerance=FT(1e-10)) const -> unsigned int
 Count multiplicity of knot value.
auto order () const -> unsigned int
 Get curve order (degree + 1).
auto numControlPoints () const -> size_t override
 Get number of control points.
auto numKnots () const -> size_t
 Get number of knots in vector.
auto insertKnot (const Knot &parameter, unsigned int times=1) const -> std::unique_ptr< NURBSCurve >
 Insert knot into curve without changing shape (Oslo algorithm).
auto refineKnotVector (const std::vector< Knot > &newKnots) const -> std::unique_ptr< NURBSCurve >
 Refine knot vector by adding multiple knots.
auto elevateDegree (unsigned int times=1) const -> std::unique_ptr< NURBSCurve >
 Elevate degree of curve (increases smoothness).
auto reduceDegree (const FT &tolerance=FT(1e-6)) const -> std::unique_ptr< NURBSCurve >
 Reduce degree if possible without shape change.
auto removeKnots (const FT &tolerance=FT(1e-6)) const -> std::unique_ptr< NURBSCurve >
 Remove unnecessary knots while preserving shape.
auto fitPoints () const -> const std::vector< Point > &
 Get original fit points if curve was created by fitting.
auto fitTolerance () const -> FT
 Get fitting tolerance used.
auto startTangent () const -> const std::optional< Point > &
 Get start tangent constraint if specified.
auto endTangent () const -> const std::optional< Point > &
 Get end tangent constraint if specified.
auto validateData () const -> std::pair< bool, std::string >
 Comprehensive NURBS data validation.
auto getCurveStatistics () const -> std::map< std::string, double >
 Get detailed curve statistics for debugging.

Static Public Member Functions

static auto fromBezier (const std::vector< Point > &controlPoints) -> std::unique_ptr< NURBSCurve >
 Create from Bezier control points.
static auto fromBSpline (const std::vector< Point > &controlPoints, unsigned int degree, const std::vector< Knot > &knots) -> std::unique_ptr< NURBSCurve >
 Create NURBS curve from explicit B-spline parameters.
static auto createBSpline (const std::vector< Point > &controlPoints, unsigned int degree) -> std::unique_ptr< NURBSCurve >
 Create uniform B-spline with automatic knot generation.
static auto createCircularArc (const Point &center, const FT &radius, const FT &startAngle, const FT &endAngle, const Point &normal=Point(0, 0, 1), KnotMethod knotMethod=KnotMethod::UNIFORM) -> std::unique_ptr< NURBSCurve >
 Create exact circular arc representation.
static auto interpolateCurve (const std::vector< Point > &points, unsigned int degree=3, KnotMethod knotMethod=KnotMethod::UNIFORM, EndCondition endCondition=EndCondition::CLAMPED) -> std::unique_ptr< NURBSCurve >
 Interpolate points exactly with specified continuity.
static auto approximateCurve (const std::vector< Point > &points, unsigned int degree, FT tolerance, size_t maxControlPoints=50) -> std::unique_ptr< NURBSCurve >
 Approximate points within tolerance using least squares.
static auto fitCurve (const std::vector< Point > &points, unsigned int degree=3, FitMethod fitMethod=FitMethod::INTERPOLATE, KnotMethod knotMethod=KnotMethod::UNIFORM, EndCondition endCondition=EndCondition::CLAMPED, FT tolerance=FT(1e-6), size_t maxControlPoints=50) -> std::unique_ptr< NURBSCurve >
 Unified curve fitting interface using FitMethod enum.

Protected Member Functions

auto findSpan (const Parameter &parameter) const -> size_t
 Find knot span containing parameter (Algorithm A2.1).
auto basisFunctionDerivatives (size_t span, const Parameter &parameter, unsigned int maxDerivative) const -> std::vector< std::vector< FT > >
 Compute basis functions and derivatives (Algorithm A2.3).
auto deBoorRational (size_t span, const Parameter &parameter) const -> Point
 Evaluate curve using De Boor's algorithm for rational curves.
auto computeDerivatives (const Parameter &parameter, unsigned int maxOrder) const -> std::vector< Point >
 Compute curve derivatives up to specified order (Algorithm A4.2).
auto checkDimensionalConsistency () const -> bool
 Check dimensional consistency across all control points.
auto computeArcLength (const Parameter &startParam, const Parameter &endParam, const FT &tolerance) const -> FT
 Compute arc length using adaptive Simpson quadrature.
auto speedFunction (Parameter t) const -> FT
 Compute speed function ||C'(t)|| for arc length integration.
auto simpsonRule (const Parameter &a, const Parameter &b) const -> FT
 Apply Simpson's rule over interval [a,b].
auto adaptiveSimpsonArcLength (const Parameter &a, const Parameter &b, const FT &tolerance, unsigned int maxDepth=20) const -> FT
 Adaptive Simpson quadrature for arc length computation.
auto findParameterByArcLength (const FT &targetLength, const FT &tolerance) const -> Parameter
 Find parameter corresponding to arc length using Newton-Raphson.
auto projectPointToCurve (const Point &point, const FT &tolerance=FT(1e-9), unsigned int maxIterations=50) const -> std::pair< Point, Parameter >
 Project point onto curve using Newton's method.

Static Protected Member Functions

static auto generateKnotVector (const std::vector< Point > &points, unsigned int degree, KnotMethod method) -> std::vector< Knot >
 Generate knot vector using specified method.
static auto computeParameters (const std::vector< Point > &points, KnotMethod method) -> std::vector< Parameter >
 Compute parameter values for point sequence.
static auto validateNURBSData (const std::vector< Point > &controlPoints, const std::vector< FT > &weights, unsigned int degree, const std::vector< Knot > &knots) -> std::pair< bool, std::string >
 Validate complete NURBS data structure.
static auto generateKnotVectorForEndCondition (const std::vector< Parameter > &parameters, unsigned int degree, EndCondition endCondition) -> std::vector< Knot >
 Generate knot vector for specific end conditions.
static auto generateApproximationKnotVector (const std::vector< Parameter > &parameters, unsigned int degree, size_t numControlPoints) -> std::vector< Knot >
 Generate knot vector for least-squares approximation.
static auto interpolateClampedCurve (const std::vector< Point > &points, const std::vector< Parameter > &parameters, unsigned int degree, const std::vector< Knot > &knots) -> std::vector< Point >
 Interpolate points with clamped end conditions.
static auto interpolateNaturalCurve (const std::vector< Point > &points, const std::vector< Parameter > &parameters, unsigned int degree, const std::vector< Knot > &knots) -> std::vector< Point >
 Interpolate with natural end conditions (minimal curvature).
static auto interpolatePeriodicCurve (const std::vector< Point > &points, unsigned int degree, KnotMethod knotMethod) -> std::unique_ptr< NURBSCurve >
 Create periodic interpolating curve.

Protected Attributes

std::vector< Point > _controlPoints
 Control points in curve space.
std::vector< FT > _weights
 Weights (empty = all 1.0).
unsigned int _degree {0}
 Polynomial degree of the NURBS curve (non-negative).
std::vector< Knot > _knotVector
 Non-decreasing knot sequence.
std::vector< Point > _fitPoints
 Original points if fitted.
FT _fitTolerance {FT(0)}
 Fitting tolerance used.
std::optional< Point > _startTangent
 Start tangent constraint.
std::optional< Point > _endTangent
 End tangent constraint.

Detailed Description

Non-Uniform Rational B-Spline (NURBS) curve implementation.

Complete OGC/SQL-MM compliant implementation supporting XY, Z, M, ZM dimensions. Weights affect XYZ coordinates in homogeneous space (x*w, y*w, z*w, w). M coordinate is interpolated non-rationally through basis functions.

Based on "The NURBS Book" by Piegl & Tiller algorithms and NURBS-Python/geomdl. Uses Kernel::FT (Exact Predicates Exact Constructions) for numerical robustness.

Key Features

  • Complete EndCondition support: CLAMPED, NATURAL, PERIODIC, TANGENT
  • All KnotMethod implementations: UNIFORM, CHORD_LENGTH, CENTRIPETAL
  • Unified FitMethod interface: INTERPOLATE (exact) vs APPROXIMATE (smooth)
  • AutoCAD SPLINE compatibility: Supports CAD-standard curve fitting
  • Mathematical operations: evaluation, derivatives, arc length, intersections
  • Advanced manipulations: splitting, joining, offsetting, degree elevation

Usage Examples

// Simple interpolation (exact fit through points)
auto curve1 = NURBSCurve::interpolateCurve(points, 3);
// Natural end conditions for smoother curves
auto curve2 = NURBSCurve::interpolateCurve(points, 3,
// Unified interface with explicit control
auto curve3 = NURBSCurve::fitCurve(points, 3,
// Create a Bézier curve from control points
std::vector<Point> bezierPoints = {
Point(0, 0), Point(1, 3), Point(3, 3), Point(4, 0) // Cubic Bézier
};
auto bezier = NURBSCurve::fromBezier(bezierPoints);
// Create a B-spline curve with automatic knot generation
std::vector<Point> controlPoints = {
Point(0, 0), Point(1, 2), Point(3, 3), Point(4, 1), Point(5, 0)
};
// Create a B-spline with explicit knot vector
std::vector<Point> explicitPoints = {Point(0, 0), Point(2, 1), Point(4, 0)};
std::vector<NURBSCurve::Knot> knots = {0, 0, 0, 1, 1, 1}; // Clamped
quadratic auto explicitBSpline = NURBSCurve::fromBSpline(explicitPoints, 2,
knots);
static auto interpolateCurve(const std::vector< Point > &points, unsigned int degree=3, KnotMethod knotMethod=KnotMethod::UNIFORM, EndCondition endCondition=EndCondition::CLAMPED) -> std::unique_ptr< NURBSCurve >
Interpolate points exactly with specified continuity.
Definition NURBSCurve.cpp:918
static auto fitCurve(const std::vector< Point > &points, unsigned int degree=3, FitMethod fitMethod=FitMethod::INTERPOLATE, KnotMethod knotMethod=KnotMethod::UNIFORM, EndCondition endCondition=EndCondition::CLAMPED, FT tolerance=FT(1e-6), size_t maxControlPoints=50) -> std::unique_ptr< NURBSCurve >
Unified curve fitting interface using FitMethod enum.
Definition NURBSCurve.cpp:1290
@ CENTRIPETAL
Square root of chord length (often best shape preservation).
Definition NURBSCurve.h:92
@ CHORD_LENGTH
Based on Euclidean distances between points.
Definition NURBSCurve.h:91
static auto fromBezier(const std::vector< Point > &controlPoints) -> std::unique_ptr< NURBSCurve >
Create from Bezier control points.
Definition NURBSCurve.cpp:83
@ NATURAL
Minimal curvature conditions (smoother, more organic curves).
Definition NURBSCurve.h:103
@ CLAMPED
Multiplicity degree+1 at curve ends (standard CAD behavior).
Definition NURBSCurve.h:102
auto controlPoints() const -> const std::vector< Point > &
Get control points array.
Definition NURBSCurve.h:627
static auto createBSpline(const std::vector< Point > &controlPoints, unsigned int degree) -> std::unique_ptr< NURBSCurve >
Create uniform B-spline with automatic knot generation.
Definition NURBSCurve.cpp:116
@ INTERPOLATE
Pass exactly through all points (higher fidelity, may be less smooth).
Definition NURBSCurve.h:115
static auto fromBSpline(const std::vector< Point > &controlPoints, unsigned int degree, const std::vector< Knot > &knots) -> std::unique_ptr< NURBSCurve >
Create NURBS curve from explicit B-spline parameters.
Definition NURBSCurve.cpp:107
A point in SFA.
Definition Point.h:24
Since
2.3.0

Member Typedef Documentation

◆ ControlPoint

Type for NURBS control points.

◆ FT

using SFCGAL::NURBSCurve::FT = Kernel::FT

Floating-point type for NURBS calculations.

◆ Knot

Type for knot values in knot vector.

◆ Parameter

Type for curve parameter values.

◆ Weight

Type for NURBS weights (positive values).

Member Enumeration Documentation

◆ EndCondition

enum class SFCGAL::NURBSCurve::EndCondition : std::uint8_t
strong

End conditions for curve fitting and interpolation.

Controls the behavior at curve endpoints to achieve different mathematical and aesthetic properties.

Enumerator
CLAMPED 

Multiplicity degree+1 at curve ends (standard CAD behavior).

NATURAL 

Minimal curvature conditions (smoother, more organic curves).

PERIODIC 

Closed periodic curve with C^(degree-1) continuity at junction.

TANGENT 

User-specified tangent constraints at ends (future enhancement).

◆ FitMethod

enum class SFCGAL::NURBSCurve::FitMethod : std::uint8_t
strong

Curve fitting methods.

Determines the mathematical approach to curve generation from input points.

Enumerator
INTERPOLATE 

Pass exactly through all points (higher fidelity, may be less smooth).

APPROXIMATE 

Least squares approximation within tolerance (smoother, fewer control points).

◆ KnotMethod

enum class SFCGAL::NURBSCurve::KnotMethod : std::uint8_t
strong

Knot vector generation methods for parameterization.

Enumerator
UNIFORM 

Equal knot spacing (fastest generation).

CHORD_LENGTH 

Based on Euclidean distances between points.

CENTRIPETAL 

Square root of chord length (often best shape preservation).

Constructor & Destructor Documentation

◆ NURBSCurve() [1/5]

SFCGAL::NURBSCurve::NURBSCurve ( )

Default constructor creating empty curve.

◆ NURBSCurve() [2/5]

SFCGAL::NURBSCurve::NURBSCurve ( const std::vector< Point > & controlPoints,
unsigned int degree,
KnotMethod knotMethod = KnotMethod::UNIFORM )

Constructor with control points and uniform weights.

Parameters
controlPointsControl points defining curve shape
degreePolynomial degree of curve (must be < controlPoints.size())
knotMethodMethod for generating knot vector

◆ NURBSCurve() [3/5]

SFCGAL::NURBSCurve::NURBSCurve ( const std::vector< Point > & controlPoints,
const std::vector< FT > & weights,
unsigned int degree,
KnotMethod knotMethod = KnotMethod::UNIFORM )

Constructor with control points and explicit weights.

Parameters
controlPointsControl points defining curve shape
weightsWeight for each control point (must match size)
degreePolynomial degree of curve
knotMethodMethod for generating knot vector

◆ NURBSCurve() [4/5]

SFCGAL::NURBSCurve::NURBSCurve ( const std::vector< Point > & controlPoints,
const std::vector< FT > & weights,
unsigned int degree,
const std::vector< Knot > & knotVector )

Full constructor with all NURBS parameters.

Parameters
controlPointsControl points defining curve shape
weightsWeights (empty for uniform weights = 1.0)
degreePolynomial degree
knotVectorCustom knot vector (must satisfy m = n + p + 1)

◆ NURBSCurve() [5/5]

SFCGAL::NURBSCurve::NURBSCurve ( const NURBSCurve & other)
default

Copy constructor.

Parameters
otherThe NURBSCurve to copy

◆ ~NURBSCurve()

SFCGAL::NURBSCurve::~NURBSCurve ( )
overridedefault

Destructor.

Member Function Documentation

◆ accept() [1/2]

void SFCGAL::NURBSCurve::accept ( ConstGeometryVisitor & visitor) const
override

Accept visitor pattern for const operations.

Parameters
visitorConst geometry visitor to accept

◆ accept() [2/2]

void SFCGAL::NURBSCurve::accept ( GeometryVisitor & visitor)
override

Accept visitor pattern for non-const operations.

Parameters
visitorGeometry visitor to accept

◆ adaptiveSimpsonArcLength()

auto SFCGAL::NURBSCurve::adaptiveSimpsonArcLength ( const Parameter & a,
const Parameter & b,
const FT & tolerance,
unsigned int maxDepth = 20 ) const -> FT
nodiscardprotected

Adaptive Simpson quadrature for arc length computation.

Parameters
aStart parameter
bEnd parameter
toleranceIntegration tolerance
maxDepthMaximum recursion depth (default 20)
Returns
Accurate arc length using adaptive subdivision

◆ approximateCurve()

auto SFCGAL::NURBSCurve::approximateCurve ( const std::vector< Point > & points,
unsigned int degree,
FT tolerance,
size_t maxControlPoints = 50 ) -> std::unique_ptr< NURBSCurve >
static

Approximate points within tolerance using least squares.

Parameters
pointsPoints to approximate
degreeTarget curve degree
toleranceMaximum allowed deviation
maxControlPointsMaximum control points to use
Returns
Approximating NURBS curve within tolerance

NURBS Curve Approximation - Piegl & Tiller Algorithm A9.1

This implements true least-squares approximation, generating control points that minimize the sum of squared distances to input data points.

Mathematical Foundation:

  • Given: n+1 data points Q_k, k = 0,...,n
  • Find: m+1 control points P_j that minimize ||C(u_k) - Q_k||²
  • Where: C(u) = Σ_{j=0}^m N_{j,p}(u) * P_j (NURBS curve)

The least-squares problem becomes: N^T * N * P = N^T * Q where N_{i,j} = N_{j,p}(u_i) are the basis function values

◆ basisFunctionDerivatives()

auto SFCGAL::NURBSCurve::basisFunctionDerivatives ( size_t span,
const Parameter & parameter,
unsigned int maxDerivative ) const -> std::vector< std::vector< FT > >
nodiscardprotected

Compute basis functions and derivatives (Algorithm A2.3).

Parameters
spanKnot span index
parameterParameter value
maxDerivativeMaximum derivative order needed
Returns
Matrix [derivative_order][basis_function] of values

◆ binormal()

auto SFCGAL::NURBSCurve::binormal ( Parameter parameter) const -> Point
nodiscardoverride

Return the unit binormal vector at the given parameter.

Parameters
parameterParameter value in the curve's parameter domain.
Returns
Unit binormal vector at parameter.

◆ checkDimensionalConsistency()

auto SFCGAL::NURBSCurve::checkDimensionalConsistency ( ) const -> bool
nodiscardprotected

Check dimensional consistency across all control points.

Returns
true if all points have same XYZ and M dimensions

◆ closestPoint()

auto SFCGAL::NURBSCurve::closestPoint ( const Point & point,
Parameter * outParameter = nullptr ) const -> Point
nodiscardoverride

Project point onto the curve and return the closest point on the curve.

If outParameter is provided, it will be set to the parameter of the closest point.

Parameters
pointQuery point to project.
outParameterOptional output parameter pointer to receive the parameter of the closest point.
Returns
Closest point on the curve to point.

◆ computeArcLength()

auto SFCGAL::NURBSCurve::computeArcLength ( const Parameter & startParam,
const Parameter & endParam,
const FT & tolerance ) const -> FT
nodiscardprotected

Compute arc length using adaptive Simpson quadrature.

Parameters
startParamStart parameter
endParamEnd parameter
toleranceIntegration tolerance
Returns
Arc length between parameters

Arc length computation using adaptive Simpson quadrature.

Integrates the speed function ||C'(t)|| over [startParam, endParam]: L = ∫[a,b] ||dC/dt|| dt

The adaptive approach subdivides intervals where Simpson's rule and its halving disagree by more than 15*tolerance, ensuring accurate results for curves with varying curvature.

◆ computeDerivatives()

auto SFCGAL::NURBSCurve::computeDerivatives ( const Parameter & parameter,
unsigned int maxOrder ) const -> std::vector< Point >
nodiscardprotected

Compute curve derivatives up to specified order (Algorithm A4.2).

Parameters
parameterEvaluation parameter
maxOrderMaximum derivative order
Returns
Vector of derivatives [C(u), C'(u), C''(u), ...]

◆ computeParameters()

auto SFCGAL::NURBSCurve::computeParameters ( const std::vector< Point > & points,
KnotMethod method ) -> std::vector< Parameter >
staticprotected

Compute parameter values for point sequence.

Parameters
pointsPoints to parameterize
methodParameterization method
Returns
Normalized parameter values [0,1]

◆ controlPointN() [1/2]

auto SFCGAL::NURBSCurve::controlPointN ( size_t index) -> Point &
nodiscardoverride

Access control point for modification.

Parameters
indexControl point index (must be valid)
Returns
Non-const reference to control point
Exceptions
Exceptionif index out of bounds

◆ controlPointN() [2/2]

auto SFCGAL::NURBSCurve::controlPointN ( size_t index) const -> const Point &
nodiscardoverride

Access control point for reading.

Parameters
indexControl point index (must be valid)
Returns
Const reference to control point
Exceptions
Exceptionif index out of bounds

◆ controlPoints()

auto SFCGAL::NURBSCurve::controlPoints ( ) const -> const std::vector< Point > &
inlinenodiscard

Get control points array.

Returns
Const reference to control points vector

◆ createBSpline()

auto SFCGAL::NURBSCurve::createBSpline ( const std::vector< Point > & controlPoints,
unsigned int degree ) -> std::unique_ptr< NURBSCurve >
static

Create uniform B-spline with automatic knot generation.

Convenience method that creates a B-spline with uniformly spaced knots, suitable for most general-purpose curve creation. The knot vector is automatically generated using uniform parameterization [0,1].

Parameters
controlPointsControl points defining the curve shape
degreePolynomial degree (must be ≥ 0 and < controlPoints.size())
Returns
Non-rational NURBS curve with uniform knots and weights
Exceptions
Exceptionif controlPoints.empty() or degree ≥ controlPoints.size()
Note
This method generates a clamped knot vector with uniform spacing, which is the most common B-spline configuration for general use.
See also
fromBSpline() for explicit knot vector control
NURBSCurve(controlPoints, degree, KnotMethod::UNIFORM) for constructor equivalent
Example:
std::vector<Point> controlPoints = {{0,0}, {1,2}, {3,1}, {4,0}};
auto curve = NURBSCurve::createBSpline(controlPoints, 3); // Cubic B-spline
Generated knot vector structure:
  • Degree 2, 4 control points → knots: [0,0,0, 0.5, 1,1,1] (clamped)
  • Degree 3, 5 control points → knots: [0,0,0,0, 0.5, 1,1,1,1] (clamped)

◆ createCircularArc()

auto SFCGAL::NURBSCurve::createCircularArc ( const Point & center,
const FT & radius,
const FT & startAngle,
const FT & endAngle,
const Point & normal = Point(0, 0, 1),
KnotMethod knotMethod = KnotMethod::UNIFORM ) -> std::unique_ptr< NURBSCurve >
static

Create exact circular arc representation.

Parameters
centerArc center point
radiusArc radius (must be positive)
startAngleStart angle in radians
endAngleEnd angle in radians
normalNormal vector for 3D arcs (default Z-axis)
knotMethodKnot generation method for parameterization
Returns
Exact NURBS representation of circular arc

◆ curvature()

auto SFCGAL::NURBSCurve::curvature ( Parameter parameter) const -> FT
nodiscardoverride

Compute the curvature scalar at the given parameter.

Parameters
parameterParameter value in the curve's parameter domain.
Returns
Curvature κ at parameter.

◆ deBoorRational()

auto SFCGAL::NURBSCurve::deBoorRational ( size_t span,
const Parameter & parameter ) const -> Point
nodiscardprotected

Evaluate curve using De Boor's algorithm for rational curves.

Parameters
spanKnot span containing parameter
parameterParameter value
Returns
Point on curve

◆ degree()

auto SFCGAL::NURBSCurve::degree ( ) const -> unsigned int
inlinenodiscardoverride

Return the polynomial degree of the curve.

Returns
Degree (non-negative integer).

◆ derivative()

auto SFCGAL::NURBSCurve::derivative ( Parameter parameter,
unsigned int order = 1 ) const -> Point
nodiscardoverride

Compute the derivative of the curve at the given parameter.

Parameters
parameterParameter value in the curve's parameter domain.
orderDerivative order (1 = first derivative). Defaults to 1.
Returns
The derivative vector (as a Point) of the specified order at parameter.

◆ dropM()

auto SFCGAL::NURBSCurve::dropM ( ) -> bool
override

Drop M coordinates from curve.

Returns
true if M coordinates were removed, false otherwise

◆ dropZ()

auto SFCGAL::NURBSCurve::dropZ ( ) -> bool
override

Drop Z coordinates from curve.

Returns
true if Z coordinates were removed, false otherwise

◆ elevateDegree()

auto SFCGAL::NURBSCurve::elevateDegree ( unsigned int times = 1) const -> std::unique_ptr< NURBSCurve >
nodiscard

Elevate degree of curve (increases smoothness).

Parameters
timesNumber of degree elevations
Returns
Curve with elevated degree (shape unchanged)
Exceptions
Exceptionif elevation would create too many control points

◆ endTangent()

auto SFCGAL::NURBSCurve::endTangent ( ) const -> const std::optional< Point > &
inlinenodiscard

Get end tangent constraint if specified.

Returns
Optional end tangent vector

◆ evaluate()

auto SFCGAL::NURBSCurve::evaluate ( Parameter parameter) const -> Point
nodiscardoverride

Evaluate the curve at the given parameter and return the corresponding point in Cartesian space.

Parameters
parameterParameter value in the curve's parameter domain.
Returns
Point on the curve at parameter.

◆ findParameterByArcLength()

auto SFCGAL::NURBSCurve::findParameterByArcLength ( const FT & targetLength,
const FT & tolerance ) const -> Parameter
nodiscardprotected

Find parameter corresponding to arc length using Newton-Raphson.

Parameters
targetLengthTarget arc length from start
toleranceConvergence tolerance
Returns
Parameter value at specified arc length

◆ findSpan()

auto SFCGAL::NURBSCurve::findSpan ( const Parameter & parameter) const -> size_t
nodiscardprotected

Find knot span containing parameter (Algorithm A2.1).

Parameters
parameterParameter value to locate
Returns
Knot span index

◆ fitCurve()

auto SFCGAL::NURBSCurve::fitCurve ( const std::vector< Point > & points,
unsigned int degree = 3,
FitMethod fitMethod = FitMethod::INTERPOLATE,
KnotMethod knotMethod = KnotMethod::UNIFORM,
EndCondition endCondition = EndCondition::CLAMPED,
FT tolerance = FT(1e-6),
size_t maxControlPoints = 50 ) -> std::unique_ptr< NURBSCurve >
static

Unified curve fitting interface using FitMethod enum.

Parameters
pointsPoints to fit curve through or approximate
degreeTarget curve degree
fitMethodWhether to interpolate exactly or approximate within tolerance
knotMethodParameterization method for stability
endConditionBoundary conditions for interpolation
toleranceMaximum deviation for approximation (ignored for interpolation)
maxControlPointsMaximum control points for approximation (ignored for interpolation)
Returns
NURBS curve fitting the specified points

◆ fitPoints()

auto SFCGAL::NURBSCurve::fitPoints ( ) const -> const std::vector< Point > &
inlinenodiscard

Get original fit points if curve was created by fitting.

Returns
Original fit points (empty if not applicable)

◆ fitTolerance()

auto SFCGAL::NURBSCurve::fitTolerance ( ) const -> FT
inlinenodiscard

Get fitting tolerance used.

Returns
Fit tolerance (0.0 for exact interpolation)

◆ frenetFrame()

auto SFCGAL::NURBSCurve::frenetFrame ( Parameter parameter) const -> std::tuple< Point, Point, Point >
nodiscardoverride

Return the Frenet frame at the given parameter as (tangent, normal, binormal).

Parameters
parameterParameter value in the curve's parameter domain.
Returns
Tuple of (unit tangent, unit normal, unit binormal) at parameter.

◆ fromBezier()

auto SFCGAL::NURBSCurve::fromBezier ( const std::vector< Point > & controlPoints) -> std::unique_ptr< NURBSCurve >
static

Create from Bezier control points.

Parameters
controlPointsBezier control points
Returns
NURBS curve with clamped knot vector [0,...,0,1,...,1]

◆ fromBSpline()

auto SFCGAL::NURBSCurve::fromBSpline ( const std::vector< Point > & controlPoints,
unsigned int degree,
const std::vector< Knot > & knots ) -> std::unique_ptr< NURBSCurve >
static

Create NURBS curve from explicit B-spline parameters.

Constructs a non-rational B-spline (NURBS with uniform weights = 1.0) from complete B-spline specification. This is the low-level constructor for users who need precise control over the knot vector structure.

Parameters
controlPointsB-spline control points defining curve shape
degreePolynomial degree (must be ≥ 0 and < controlPoints.size())
knotsComplete knot vector (must satisfy: knots.size() = controlPoints.size() + degree + 1)
Returns
NURBS curve with uniform weights (all = 1.0)
Exceptions
Exceptionif parameters violate B-spline constraints
Note
Use this method when you have a specific knot vector from external sources (CAD files, mathematical specifications, etc.)
See also
createBSpline() for automatic knot generation with uniform spacing
Example:
std::vector<Point> controlPoints = {{0,0}, {1,1}, {2,0}};
std::vector<Knot> knots = {0, 0, 0, 1, 1, 1}; // Clamped quadratic
auto curve = NURBSCurve::fromBSpline(controlPoints, 2, knots);

◆ generateApproximationKnotVector()

auto SFCGAL::NURBSCurve::generateApproximationKnotVector ( const std::vector< Parameter > & parameters,
unsigned int degree,
size_t numControlPoints ) -> std::vector< Knot >
staticprotected

Generate knot vector for least-squares approximation.

Parameters
parametersParameter values for data points
degreeCurve degree
numControlPointsNumber of control points (m in Piegl & Tiller)
Returns
Knot vector optimized for approximation

Generate knot vector for NURBS approximation using geomdl method.

This is compute_knot_vector2 from geomdl which uses Piegl & Tiller Equation 9.68 from "The NURBS Book".

This method ensures that every knot span contains at least one parameter value, which produces better approximations than simple averaging.

◆ generateKnotVector()

auto SFCGAL::NURBSCurve::generateKnotVector ( const std::vector< Point > & points,
unsigned int degree,
KnotMethod method ) -> std::vector< Knot >
staticprotected

Generate knot vector using specified method.

Parameters
pointsReference points for parameterization
degreeCurve degree
methodKnot generation method
Returns
Generated knot vector

◆ generateKnotVectorForEndCondition()

auto SFCGAL::NURBSCurve::generateKnotVectorForEndCondition ( const std::vector< Parameter > & parameters,
unsigned int degree,
EndCondition endCondition ) -> std::vector< Knot >
staticprotected

Generate knot vector for specific end conditions.

Parameters
parametersParameter values for interpolation points
degreePolynomial degree of the curve
endConditionType of end condition (clamped, natural, periodic)
Returns
Generated knot vector satisfying the end condition

◆ geometryType()

auto SFCGAL::NURBSCurve::geometryType ( ) const -> std::string
nodiscardoverride

Get the geometry type as string.

Returns
String representation of geometry type

◆ geometryTypeId()

auto SFCGAL::NURBSCurve::geometryTypeId ( ) const -> GeometryType
nodiscardoverride

Get the geometry type identifier.

Returns
GeometryType enumeration value

◆ getCurveStatistics()

auto SFCGAL::NURBSCurve::getCurveStatistics ( ) const -> std::map< std::string, double >
nodiscard

Get detailed curve statistics for debugging.

Returns
Map of curve properties and values

◆ insertKnot()

auto SFCGAL::NURBSCurve::insertKnot ( const Knot & parameter,
unsigned int times = 1 ) const -> std::unique_ptr< NURBSCurve >
nodiscard

Insert knot into curve without changing shape (Oslo algorithm).

Parameters
parameterKnot value to insert
timesNumber of insertions (limited by degree)
Returns
New curve with inserted knot
Exceptions
Exceptionif parameter outside knot span or too many insertions

◆ interpolateClampedCurve()

auto SFCGAL::NURBSCurve::interpolateClampedCurve ( const std::vector< Point > & points,
const std::vector< Parameter > & parameters,
unsigned int degree,
const std::vector< Knot > & knots ) -> std::vector< Point >
staticprotected

Interpolate points with clamped end conditions.

Parameters
pointsData points to interpolate through
parametersParameter values at each data point
degreePolynomial degree of interpolating curve
knotsKnot vector for interpolation
Returns
Control points for interpolating NURBS curve

◆ interpolateCurve()

auto SFCGAL::NURBSCurve::interpolateCurve ( const std::vector< Point > & points,
unsigned int degree = 3,
KnotMethod knotMethod = KnotMethod::UNIFORM,
EndCondition endCondition = EndCondition::CLAMPED ) -> std::unique_ptr< NURBSCurve >
static

Interpolate points exactly with specified continuity.

Parameters
pointsPoints to interpolate through
degreeCurve degree (will be reduced if too high)
knotMethodParameterization method for stability
endConditionBoundary conditions
Returns
Interpolating NURBS curve

◆ interpolateNaturalCurve()

auto SFCGAL::NURBSCurve::interpolateNaturalCurve ( const std::vector< Point > & points,
const std::vector< Parameter > & parameters,
unsigned int degree,
const std::vector< Knot > & knots ) -> std::vector< Point >
staticprotected

Interpolate with natural end conditions (minimal curvature).

Parameters
pointsData points to interpolate through
parametersParameter values at each data point
degreePolynomial degree of interpolating curve
knotsKnot vector for interpolation
Returns
Control points for natural interpolating curve

◆ interpolatePeriodicCurve()

auto SFCGAL::NURBSCurve::interpolatePeriodicCurve ( const std::vector< Point > & points,
unsigned int degree,
KnotMethod knotMethod ) -> std::unique_ptr< NURBSCurve >
staticprotected

Create periodic interpolating curve.

Parameters
pointsData points to interpolate (first and last should be same)
degreePolynomial degree of curve
knotMethodKnot generation method for parameterization
Returns
Periodic NURBS curve interpolating the points

◆ is3D()

auto SFCGAL::NURBSCurve::is3D ( ) const -> bool
nodiscardoverride

Check if curve is three-dimensional.

Returns
true if curve has Z coordinates, false otherwise

◆ isBezier()

auto SFCGAL::NURBSCurve::isBezier ( ) const -> bool
nodiscard

Return true when this NURBS curve is represented in Bezier form.

A Bezier form here means the knot vector corresponds to one or more clamped Bezier segments (clamped ends with the appropriate multiplicities).

Returns
true if curve is in Bezier form, false otherwise

◆ isBSpline()

auto SFCGAL::NURBSCurve::isBSpline ( ) const -> bool
nodiscard

Return true when the curve is a non-rational B-spline (uniform weights).

This is true when no explicit weights are stored (all weights implicitly 1) or when all stored weights are effectively equal.

Returns
true if curve is a non-rational B-spline, false otherwise

◆ isEmpty()

auto SFCGAL::NURBSCurve::isEmpty ( ) const -> bool
nodiscardoverride

Check if curve is empty.

Returns
true if curve has no control points, false otherwise

◆ isLinear()

auto SFCGAL::NURBSCurve::isLinear ( ) const -> bool
nodiscardoverride

Determine whether the curve is geometrically linear (represents a straight line).

Returns
true if the curve is linear, false otherwise.

◆ isMeasured()

auto SFCGAL::NURBSCurve::isMeasured ( ) const -> bool
nodiscardoverride

Check if curve has measure coordinates.

Returns
true if curve has M coordinates, false otherwise

◆ isPeriodic()

auto SFCGAL::NURBSCurve::isPeriodic ( ) const -> bool
nodiscardoverride

True if the curve is periodic (periodic knot structure and matching end conditions).

Returns
true if periodic, false otherwise.

◆ isPlanar()

auto SFCGAL::NURBSCurve::isPlanar ( std::vector< FT > * plane = nullptr) const -> bool
nodiscardoverride

Check whether the curve is planar.

If plane is provided, fills it with plane coefficients.

Parameters
planeOptional pointer to a vector that, if provided, will be set to a plane representation (e.g., coefficients {A, B, C, D} for plane Ax + By + Cz + D = 0).
Returns
true if the curve is planar, false otherwise.

◆ isRational()

auto SFCGAL::NURBSCurve::isRational ( ) const -> bool
nodiscardoverride

Check if curve uses non-uniform rational weights.

Returns
true if weights vary significantly from uniform

◆ join()

auto SFCGAL::NURBSCurve::join ( const Curve & other,
Continuity continuity = Continuity::C0,
FT tolerance = FT(1e-6) ) const -> std::unique_ptr< Curve >
nodiscardoverride

Join this curve with other producing a single curve if they can be connected within the requested continuity and tolerance.

Parameters
otherCurve to join with.
continuityRequired continuity at the join point (default C0).
toleranceGeometric tolerance for accepting the join.
Returns
Unique pointer to the joined curve on success, or nullptr if join is not possible.

◆ knot()

auto SFCGAL::NURBSCurve::knot ( size_t index) const -> Knot
nodiscard

Get knot value at index.

Parameters
indexKnot index
Returns
Knot value
Exceptions
Exceptionif index out of bounds

◆ knotMultiplicity()

auto SFCGAL::NURBSCurve::knotMultiplicity ( const Knot & value,
const FT & tolerance = FT(1e-10) ) const -> unsigned int
nodiscard

Count multiplicity of knot value.

Parameters
valueKnot value to count
toleranceTolerance for knot equality
Returns
Number of occurrences of knot value

◆ knotVector()

auto SFCGAL::NURBSCurve::knotVector ( ) const -> const std::vector< Knot > &
inlinenodiscard

Return the knot vector for this curve.

The returned reference is to the internal, non-decreasing knot vector.

Returns
Const reference to the knot vector

◆ length()

auto SFCGAL::NURBSCurve::length ( Parameter from = Parameter(-1),
Parameter to = Parameter(-1),
FT tolerance = FT(1e-6) ) const -> FT
nodiscardoverride

Compute arc length between two parameters.

If from or to is omitted (default -1), the full curve domain is used. Integration is performed to within tolerance.

Parameters
fromStart parameter (use default to indicate domain start).
toEnd parameter (use default to indicate domain end).
toleranceTolerance for numerical integration.
Returns
Arc length between from and to.

◆ normal()

auto SFCGAL::NURBSCurve::normal ( Parameter parameter) const -> Point
nodiscardoverride

Return the principal unit normal vector at the given parameter.

Parameters
parameterParameter value in the curve's parameter domain.
Returns
Unit normal vector at parameter.

◆ numControlPoints()

auto SFCGAL::NURBSCurve::numControlPoints ( ) const -> size_t
inlinenodiscardoverride

Get number of control points.

Returns
Control point count

◆ numKnots()

auto SFCGAL::NURBSCurve::numKnots ( ) const -> size_t
inlinenodiscard

Get number of knots in vector.

Returns
Knot count

◆ operator=()

auto SFCGAL::NURBSCurve::operator= ( const NURBSCurve & other) -> NURBSCurve &=default
default

Assignment operator.

Parameters
otherThe NURBSCurve to assign from
Returns
Reference to this NURBSCurve

◆ order()

auto SFCGAL::NURBSCurve::order ( ) const -> unsigned int
inlinenodiscard

Get curve order (degree + 1).

Returns
Curve order

◆ parameterAtLength()

auto SFCGAL::NURBSCurve::parameterAtLength ( FT arcLength,
FT tolerance = FT(1e-6) ) const -> Parameter
nodiscardoverride

Find the parameter corresponding to a given arc length measured from the start of the curve.

Parameters
arcLengthTarget arc length along the curve (measured from domain start).
toleranceTolerance for the inverse mapping solver.
Returns
Parameter value whose arc length from the curve start equals arcLength.

◆ parameterBounds()

auto SFCGAL::NURBSCurve::parameterBounds ( ) const -> std::pair< Parameter, Parameter >
nodiscardoverride

Return the parameter domain of the curve as [u_min, u_max].

Returns
Pair {u_min, u_max}.

◆ projectPointToCurve()

auto SFCGAL::NURBSCurve::projectPointToCurve ( const Point & point,
const FT & tolerance = FT(1e-9),
unsigned int maxIterations = 50 ) const -> std::pair< Point, Parameter >
nodiscardprotected

Project point onto curve using Newton's method.

Parameters
pointPoint to project
toleranceConvergence tolerance
maxIterationsMaximum iterations
Returns
Pair of (closest_point_on_curve, parameter_value)

◆ reduceDegree()

auto SFCGAL::NURBSCurve::reduceDegree ( const FT & tolerance = FT(1e-6)) const -> std::unique_ptr< NURBSCurve >
nodiscard

Reduce degree if possible without shape change.

Parameters
toleranceMaximum allowed deviation
Returns
Degree-reduced curve or nullptr if reduction impossible within tolerance

◆ refineKnotVector()

auto SFCGAL::NURBSCurve::refineKnotVector ( const std::vector< Knot > & newKnots) const -> std::unique_ptr< NURBSCurve >
nodiscard

Refine knot vector by adding multiple knots.

Parameters
newKnotsSorted knots to insert
Returns
Refined curve (shape unchanged)
Exceptions
Exceptionif knots not properly ordered

◆ removeKnots()

auto SFCGAL::NURBSCurve::removeKnots ( const FT & tolerance = FT(1e-6)) const -> std::unique_ptr< NURBSCurve >
nodiscard

Remove unnecessary knots while preserving shape.

Parameters
toleranceMaximum allowed deviation
Returns
Simplified curve with fewer knots

◆ reparameterizeByArcLength()

auto SFCGAL::NURBSCurve::reparameterizeByArcLength ( ) const -> std::unique_ptr< Curve >
nodiscardoverride

Return a new Curve reparameterized by arc length (parameter runs proportionally to arc length).

Returns
New Curve owned pointer reparameterized by arc length.

◆ reverse()

auto SFCGAL::NURBSCurve::reverse ( ) const -> std::unique_ptr< Curve >
nodiscardoverride

Return a new Curve representing this curve with reversed parameter direction.

Returns
Unique pointer to the reversed curve.

◆ setControlPoint()

void SFCGAL::NURBSCurve::setControlPoint ( size_t index,
const Point & point )

Set individual control point with validation.

Parameters
indexControl point index
pointNew control point value
Exceptions
Exceptionif index invalid or dimension mismatch

◆ setControlPoints()

void SFCGAL::NURBSCurve::setControlPoints ( const std::vector< Point > & controlPoints)

Set all control points with validation.

Parameters
controlPointsNew control points
Exceptions
Exceptionif dimensionally inconsistent or degree constraint violated

◆ setKnotVector()

void SFCGAL::NURBSCurve::setKnotVector ( const std::vector< Knot > & knots)

Set knot vector with full validation.

Parameters
knotsNew knot vector (must satisfy NURBS constraints)
Exceptions
Exceptionif knot vector invalid for current curve parameters

◆ setWeight()

void SFCGAL::NURBSCurve::setWeight ( size_t index,
const FT & weight )

Set weight at specified index.

Parameters
indexWeight index
weightNew weight value (must be positive)
Exceptions
Exceptionif index invalid or weight non-positive

◆ setWeights()

void SFCGAL::NURBSCurve::setWeights ( const std::vector< FT > & weights)

Set all weights with validation.

Parameters
weightsNew weights (must be positive and match control point count)
Exceptions
Exceptionif invalid weights provided

◆ simpsonRule()

auto SFCGAL::NURBSCurve::simpsonRule ( const Parameter & a,
const Parameter & b ) const -> FT
nodiscardprotected

Apply Simpson's rule over interval [a,b].

Parameters
aStart parameter
bEnd parameter
Returns
Simpson approximation of integral

◆ speedFunction()

auto SFCGAL::NURBSCurve::speedFunction ( Parameter t) const -> FT
nodiscardprotected

Compute speed function ||C'(t)|| for arc length integration.

Parameters
tParameter value
Returns
Magnitude of derivative vector at parameter t

◆ split()

auto SFCGAL::NURBSCurve::split ( Parameter parameter) const -> std::pair< std::unique_ptr< Curve >, std::unique_ptr< Curve > >
nodiscardoverride

Split the curve at parameter into two curves [domain_start, parameter] and [parameter, domain_end].

Parameters
parameterParameter at which to split the curve.
Returns
Pair of unique_ptrs to the left and right subcurves.

◆ startTangent()

auto SFCGAL::NURBSCurve::startTangent ( ) const -> const std::optional< Point > &
inlinenodiscard

Get start tangent constraint if specified.

Returns
Optional start tangent vector

◆ subcurve()

auto SFCGAL::NURBSCurve::subcurve ( Parameter from,
Parameter to ) const -> std::unique_ptr< Curve >
nodiscardoverride

Extract a subcurve between parameters from and to (inclusive of domain interval).

Parameters
fromStart parameter of the subcurve.
toEnd parameter of the subcurve.
Returns
Unique pointer to the extracted subcurve.

◆ swapXY()

void SFCGAL::NURBSCurve::swapXY ( )
override

Swap the X and Y coordinates of all control points and any stored fit data.

◆ tangent()

auto SFCGAL::NURBSCurve::tangent ( Parameter parameter) const -> Point
nodiscardoverride

Return the unit tangent vector at the given parameter.

Parameters
parameterParameter value in the curve's parameter domain.
Returns
Unit tangent vector at parameter.

◆ toLineString()

auto SFCGAL::NURBSCurve::toLineString ( unsigned int numSegments = 32) const -> std::unique_ptr< LineString >
nodiscardoverride

Convert the curve to a LineString by sampling numSegments uniformly in parameter space.

Parameters
numSegmentsNumber of segments (default 32) to use for the polyline approximation.
Returns
LineString approximating the curve.

◆ toLineStringAdaptive()

auto SFCGAL::NURBSCurve::toLineStringAdaptive ( FT tolerance = FT(1e-3),
unsigned int minSegments = 8,
unsigned int maxSegments = 256 ) const -> std::unique_ptr< LineString >
nodiscardoverride

Convert the curve to a LineString using adaptive subdivision until the polyline approximates the curve within tolerance, respecting minSegments and maxSegments bounds.

Parameters
toleranceMaximum allowed deviation between curve and polyline.
minSegmentsMinimum number of segments to produce.
maxSegmentsMaximum number of segments to produce.
Returns
LineString approximating the curve within tolerance.

◆ torsion()

auto SFCGAL::NURBSCurve::torsion ( Parameter parameter) const -> FT
nodiscardoverride

Compute the torsion scalar at the given parameter.

Parameters
parameterParameter value in the curve's parameter domain.
Returns
Torsion τ at parameter.

◆ validateData()

auto SFCGAL::NURBSCurve::validateData ( ) const -> std::pair< bool, std::string >
nodiscard

Comprehensive NURBS data validation.

Returns
Pair of (is_valid, error_description)

◆ validateNURBSData()

auto SFCGAL::NURBSCurve::validateNURBSData ( const std::vector< Point > & controlPoints,
const std::vector< FT > & weights,
unsigned int degree,
const std::vector< Knot > & knots ) -> std::pair< bool, std::string >
staticprotected

Validate complete NURBS data structure.

Parameters
controlPointsControl points to validate
weightsWeights to validate
degreeDegree to validate
knotsKnot vector to validate
Returns
Pair of (is_valid, detailed_error_message)

◆ weight()

auto SFCGAL::NURBSCurve::weight ( size_t index) const -> FT
nodiscardoverride

Get weight at specified index.

Parameters
indexWeight index
Returns
Weight value (1.0 if using uniform weights)
Exceptions
Exceptionif index out of bounds

◆ weights()

auto SFCGAL::NURBSCurve::weights ( ) const -> const std::vector< FT > &
inlinenodiscard

Get weights array.

Returns
Const reference to weights vector

Member Data Documentation

◆ _controlPoints

std::vector<Point> SFCGAL::NURBSCurve::_controlPoints
protected

Control points in curve space.

◆ _degree

unsigned int SFCGAL::NURBSCurve::_degree {0}
protected

Polynomial degree of the NURBS curve (non-negative).

A degree of 0 represents a point; the curve order is degree + 1. Defaults to 0. Polynomial degree

◆ _endTangent

std::optional<Point> SFCGAL::NURBSCurve::_endTangent
protected

End tangent constraint.

◆ _fitPoints

std::vector<Point> SFCGAL::NURBSCurve::_fitPoints
protected

Original points if fitted.

◆ _fitTolerance

FT SFCGAL::NURBSCurve::_fitTolerance {FT(0)}
protected

Fitting tolerance used.

◆ _knotVector

std::vector<Knot> SFCGAL::NURBSCurve::_knotVector
protected

Non-decreasing knot sequence.

◆ _startTangent

std::optional<Point> SFCGAL::NURBSCurve::_startTangent
protected

Start tangent constraint.

◆ _weights

std::vector<FT> SFCGAL::NURBSCurve::_weights
protected

Weights (empty = all 1.0).