|
SFCGAL
2.3.0
|
Non-Uniform Rational B-Spline (NURBS) curve implementation. More...
#include <NURBSCurve.h>
Inherits SFCGAL::GeometryImpl< Derived, Base >.
Public Types | |
| enum | KnotMethod : std::uint8_t { KnotMethod::UNIFORM, KnotMethod::CHORD_LENGTH, KnotMethod::CENTRIPETAL } |
| Knot vector generation methods for parameterization. More... | |
| enum | EndCondition : std::uint8_t { EndCondition::CLAMPED, EndCondition::NATURAL, EndCondition::PERIODIC, EndCondition::TANGENT } |
| End conditions for curve fitting and interpolation. More... | |
| enum | FitMethod : std::uint8_t { FitMethod::INTERPOLATE, FitMethod::APPROXIMATE } |
| Curve fitting methods. More... | |
| using | FT = Kernel::FT |
| Floating-point type for NURBS calculations. More... | |
| using | ControlPoint = Point |
| Type for NURBS control points. More... | |
| using | Weight = FT |
| Type for NURBS weights (positive values) More... | |
| using | Knot = FT |
| Type for knot values in knot vector. More... | |
| using | Parameter = FT |
| Type for curve parameter values. More... | |
Public Member Functions | |
| NURBSCurve () | |
| Default constructor creating empty curve. More... | |
| NURBSCurve (const std::vector< Point > &controlPoints, unsigned int degree, KnotMethod knotMethod=KnotMethod::UNIFORM) | |
| Constructor with control points and uniform weights. More... | |
| 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. More... | |
| 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. More... | |
| NURBSCurve (const NURBSCurve &other)=default | |
| Copy constructor. More... | |
| auto | operator= (const NURBSCurve &other) -> NURBSCurve &=default |
| Assignment operator. More... | |
| ~NURBSCurve () override=default | |
| Destructor. More... | |
| void | accept (GeometryVisitor &visitor) override |
| Accept visitor pattern for non-const operations. More... | |
| void | accept (ConstGeometryVisitor &visitor) const override |
| Accept visitor pattern for const operations. More... | |
| auto | geometryTypeId () const -> GeometryType override |
| Get the geometry type identifier. More... | |
| auto | geometryType () const -> std::string override |
| Get the geometry type as string. More... | |
| auto | isEmpty () const -> bool override |
| Check if curve is empty. More... | |
| auto | is3D () const -> bool override |
| Check if curve is three-dimensional. More... | |
| auto | isMeasured () const -> bool override |
| Check if curve has measure coordinates. More... | |
| auto | dropZ () -> bool override |
| Drop Z coordinates from curve. More... | |
| auto | dropM () -> bool override |
| Drop M coordinates from curve. More... | |
| void | swapXY () override |
| Swap the X and Y coordinates of all control points and any stored fit data. More... | |
| auto | evaluate (Parameter parameter) const -> Point override |
| Evaluate the curve at the given parameter and return the corresponding point in Cartesian space. More... | |
| auto | derivative (Parameter parameter, unsigned int order=1) const -> Point override |
| Compute the derivative of the curve at the given parameter. More... | |
| auto | tangent (Parameter parameter) const -> Point override |
| Return the unit tangent vector at the given parameter. More... | |
| auto | normal (Parameter parameter) const -> Point override |
| Return the principal unit normal vector at the given parameter. More... | |
| auto | binormal (Parameter parameter) const -> Point override |
| Return the unit binormal vector at the given parameter. More... | |
| auto | curvature (Parameter parameter) const -> FT override |
| Compute the curvature scalar at the given parameter. More... | |
| auto | torsion (Parameter parameter) const -> FT override |
| Compute the torsion scalar at the given parameter. More... | |
| auto | frenetFrame (Parameter parameter) const -> std::tuple< Point, Point, Point > override |
| Return the Frenet frame at the given parameter as (tangent, normal, binormal). More... | |
| 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. More... | |
| 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. More... | |
| auto | parameterBounds () const -> std::pair< Parameter, Parameter > override |
| Return the parameter domain of the curve as [u_min, u_max]. More... | |
| auto | isPeriodic () const -> bool override |
| True if the curve is periodic (periodic knot structure and matching end conditions). More... | |
| auto | isPlanar (std::vector< FT > *plane=nullptr) const -> bool override |
| Check whether the curve is planar. More... | |
| auto | isLinear () const -> bool override |
| Determine whether the curve is geometrically linear (represents a straight line). More... | |
| auto | degree () const -> unsigned int override |
| Return the polynomial degree of the curve. More... | |
| auto | length (Parameter from=Parameter(-1), Parameter to=Parameter(-1), FT tolerance=FT(1e-6)) const -> FT override |
| Compute arc length between two parameters. More... | |
| 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. More... | |
| auto | reparameterizeByArcLength () const -> std::unique_ptr< Curve > override |
| Return a new Curve reparameterized by arc length (parameter runs proportionally to arc length). More... | |
| 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]. More... | |
| auto | subcurve (Parameter from, Parameter to) const -> std::unique_ptr< Curve > override |
Extract a subcurve between parameters from and to (inclusive of domain interval). More... | |
| auto | reverse () const -> std::unique_ptr< Curve > override |
| Return a new Curve representing this curve with reversed parameter direction. More... | |
| 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. More... | |
| auto | closestPoint (const Point &point, Parameter *outParameter=nullptr) const -> Point override |
Project point onto the curve and return the closest point on the curve. More... | |
| auto | controlPoints () const -> const std::vector< Point > & |
| Get control points array. More... | |
| void | setControlPoints (const std::vector< Point > &controlPoints) |
| Set all control points with validation. More... | |
| auto | controlPointN (size_t index) -> Point &override |
| Access control point for modification. More... | |
| auto | controlPointN (size_t index) const -> const Point &override |
| Access control point for reading. More... | |
| void | setControlPoint (size_t index, const Point &point) |
| Set individual control point with validation. More... | |
| auto | weights () const -> const std::vector< FT > & |
| Get weights array. More... | |
| void | setWeights (const std::vector< FT > &weights) |
| Set all weights with validation. More... | |
| auto | weight (size_t index) const -> FT override |
| Get weight at specified index. More... | |
| void | setWeight (size_t index, const FT &weight) |
| Set weight at specified index. More... | |
| auto | isRational () const -> bool override |
| Check if curve uses non-uniform rational weights. More... | |
| auto | isBezier () const -> bool |
| Return true when this NURBS curve is represented in Bezier form. More... | |
| auto | isBSpline () const -> bool |
| Return true when the curve is a non-rational B-spline (uniform weights). More... | |
| auto | knotVector () const -> const std::vector< Knot > & |
| Return the knot vector for this curve. More... | |
| void | setKnotVector (const std::vector< Knot > &knots) |
| Set knot vector with full validation. More... | |
| auto | knot (size_t index) const -> Knot |
| Get knot value at index. More... | |
| auto | knotMultiplicity (const Knot &value, const FT &tolerance=FT(1e-10)) const -> unsigned int |
| Count multiplicity of knot value. More... | |
| auto | order () const -> unsigned int |
| Get curve order (degree + 1) More... | |
| auto | numControlPoints () const -> size_t override |
| Get number of control points. More... | |
| auto | numKnots () const -> size_t |
| Get number of knots in vector. More... | |
| auto | insertKnot (const Knot ¶meter, unsigned int times=1) const -> std::unique_ptr< NURBSCurve > |
| Insert knot into curve without changing shape (Oslo algorithm) More... | |
| auto | refineKnotVector (const std::vector< Knot > &newKnots) const -> std::unique_ptr< NURBSCurve > |
| Refine knot vector by adding multiple knots. More... | |
| auto | elevateDegree (unsigned int times=1) const -> std::unique_ptr< NURBSCurve > |
| Elevate degree of curve (increases smoothness) More... | |
| auto | reduceDegree (const FT &tolerance=FT(1e-6)) const -> std::unique_ptr< NURBSCurve > |
| Reduce degree if possible without shape change. More... | |
| auto | removeKnots (const FT &tolerance=FT(1e-6)) const -> std::unique_ptr< NURBSCurve > |
| Remove unnecessary knots while preserving shape. More... | |
| auto | fitPoints () const -> const std::vector< Point > & |
| Get original fit points if curve was created by fitting. More... | |
| auto | fitTolerance () const -> FT |
| Get fitting tolerance used. More... | |
| auto | startTangent () const -> const std::optional< Point > & |
| Get start tangent constraint if specified. More... | |
| auto | endTangent () const -> const std::optional< Point > & |
| Get end tangent constraint if specified. More... | |
| auto | validateData () const -> std::pair< bool, std::string > |
| Comprehensive NURBS data validation. More... | |
| auto | getCurveStatistics () const -> std::map< std::string, double > |
| Get detailed curve statistics for debugging. More... | |
Static Public Member Functions | |
| static auto | fromBezier (const std::vector< Point > &controlPoints) -> std::unique_ptr< NURBSCurve > |
| Create from Bezier control points. More... | |
| 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. More... | |
| static auto | createBSpline (const std::vector< Point > &controlPoints, unsigned int degree) -> std::unique_ptr< NURBSCurve > |
| Create uniform B-spline with automatic knot generation. More... | |
| static auto | createCircularArc (const Point ¢er, 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
Protected Member Functions | |
| auto | findSpan (const Parameter ¶meter) const -> size_t |
| Find knot span containing parameter (Algorithm A2.1) More... | |
| auto | basisFunctionDerivatives (size_t span, const Parameter ¶meter, unsigned int maxDerivative) const -> std::vector< std::vector< FT >> |
| Compute basis functions and derivatives (Algorithm A2.3) More... | |
| auto | deBoorRational (size_t span, const Parameter ¶meter) const -> Point |
| Evaluate curve using De Boor's algorithm for rational curves. More... | |
| auto | computeDerivatives (const Parameter ¶meter, unsigned int maxOrder) const -> std::vector< Point > |
| Compute curve derivatives up to specified order (Algorithm A4.2) More... | |
| auto | checkDimensionalConsistency () const -> bool |
| Check dimensional consistency across all control points. More... | |
| auto | computeArcLength (const Parameter &startParam, const Parameter &endParam, const FT &tolerance) const -> FT |
| Compute arc length using adaptive Simpson quadrature. More... | |
| auto | speedFunction (Parameter t) const -> FT |
| Compute speed function ||C'(t)|| for arc length integration. More... | |
| auto | simpsonRule (const Parameter &a, const Parameter &b) const -> FT |
| Apply Simpson's rule over interval [a,b]. More... | |
| auto | adaptiveSimpsonArcLength (const Parameter &a, const Parameter &b, const FT &tolerance, unsigned int maxDepth=20) const -> FT |
| Adaptive Simpson quadrature for arc length computation. More... | |
| auto | findParameterByArcLength (const FT &targetLength, const FT &tolerance) const -> Parameter |
| Find parameter corresponding to arc length using Newton-Raphson. More... | |
| 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. More... | |
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. More... | |
| static auto | computeParameters (const std::vector< Point > &points, KnotMethod method) -> std::vector< Parameter > |
| Compute parameter values for point sequence. More... | |
| 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. More... | |
| static auto | generateKnotVectorForEndCondition (const std::vector< Parameter > ¶meters, unsigned int degree, EndCondition endCondition) -> std::vector< Knot > |
| Generate knot vector for specific end conditions. More... | |
| static auto | generateApproximationKnotVector (const std::vector< Parameter > ¶meters, unsigned int degree, size_t numControlPoints) -> std::vector< Knot > |
| Generate knot vector for least-squares approximation. More... | |
| static auto | interpolateClampedCurve (const std::vector< Point > &points, const std::vector< Parameter > ¶meters, unsigned int degree, const std::vector< Knot > &knots) -> std::vector< Point > |
| Interpolate points with clamped end conditions. More... | |
| static auto | interpolateNaturalCurve (const std::vector< Point > &points, const std::vector< Parameter > ¶meters, unsigned int degree, const std::vector< Knot > &knots) -> std::vector< Point > |
| Interpolate with natural end conditions (minimal curvature) More... | |
| static auto | interpolatePeriodicCurve (const std::vector< Point > &points, unsigned int degree, KnotMethod knotMethod) -> std::unique_ptr< NURBSCurve > |
| Create periodic interpolating curve. More... | |
Protected Attributes | |
| std::vector< Point > | _controlPoints |
| Control points in curve space. More... | |
| std::vector< FT > | _weights |
| Weights (empty = all 1.0) More... | |
| unsigned int | _degree {0} |
| Polynomial degree of the NURBS curve (non-negative). More... | |
| std::vector< Knot > | _knotVector |
| Non-decreasing knot sequence. More... | |
| std::vector< Point > | _fitPoints |
| Original points if fitted. More... | |
| FT | _fitTolerance {FT(0)} |
| Fitting tolerance used. More... | |
| std::optional< Point > | _startTangent |
| Start tangent constraint. More... | |
| std::optional< Point > | _endTangent |
| End tangent constraint. More... | |
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.
## Usage Examples
Type for NURBS control points.
| using SFCGAL::NURBSCurve::FT = Kernel::FT |
Floating-point type for NURBS calculations.
| using SFCGAL::NURBSCurve::Knot = FT |
Type for knot values in knot vector.
| using SFCGAL::NURBSCurve::Parameter = FT |
Type for curve parameter values.
| using SFCGAL::NURBSCurve::Weight = FT |
Type for NURBS weights (positive values)
|
strong |
End conditions for curve fitting and interpolation.
Controls the behavior at curve endpoints to achieve different mathematical and aesthetic properties.
|
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) |
|
strong |
| SFCGAL::NURBSCurve::NURBSCurve | ( | ) |
Default constructor creating empty curve.
| SFCGAL::NURBSCurve::NURBSCurve | ( | const std::vector< Point > & | controlPoints, |
| unsigned int | degree, | ||
| KnotMethod | knotMethod = KnotMethod::UNIFORM |
||
| ) |
Constructor with control points and uniform weights.
| controlPoints | Control points defining curve shape |
| degree | Polynomial degree of curve (must be < controlPoints.size()) |
| knotMethod | Method for generating knot vector |
| 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.
| controlPoints | Control points defining curve shape |
| weights | Weight for each control point (must match size) |
| degree | Polynomial degree of curve |
| knotMethod | Method for generating knot vector |
| 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.
| controlPoints | Control points defining curve shape |
| weights | Weights (empty for uniform weights = 1.0) |
| degree | Polynomial degree |
| knotVector | Custom knot vector (must satisfy m = n + p + 1) |
|
default |
Copy constructor.
| other | The NURBSCurve to copy |
|
overridedefault |
Destructor.
|
override |
Accept visitor pattern for non-const operations.
| visitor | Geometry visitor to accept |
|
override |
Accept visitor pattern for const operations.
| visitor | Const geometry visitor to accept |
|
protected |
Adaptive Simpson quadrature for arc length computation.
| a | Start parameter |
| b | End parameter |
| tolerance | Integration tolerance |
| maxDepth | Maximum recursion depth (default 20) |
|
static |
Approximate points within tolerance using least squares.
| points | Points to approximate |
| degree | Target curve degree |
| tolerance | Maximum allowed deviation |
| maxControlPoints | Maximum control points to use |
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:
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
|
protected |
Compute basis functions and derivatives (Algorithm A2.3)
| span | Knot span index |
| parameter | Parameter value |
| maxDerivative | Maximum derivative order needed |
Return the unit binormal vector at the given parameter.
| parameter | Parameter value in the curve's parameter domain. |
parameter.
|
protected |
Check dimensional consistency across all control points.
|
override |
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.
| point | Query point to project. |
| outParameter | Optional output parameter pointer to receive the parameter of the closest point. |
point.
|
protected |
Compute arc length using adaptive Simpson quadrature.
| startParam | Start parameter |
| endParam | End parameter |
| tolerance | Integration tolerance |
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.
|
protected |
Compute curve derivatives up to specified order (Algorithm A4.2)
| parameter | Evaluation parameter |
| maxOrder | Maximum derivative order |
|
staticprotected |
Compute parameter values for point sequence.
| points | Points to parameterize |
| method | Parameterization method |
|
override |
Access control point for modification.
| index | Control point index (must be valid) |
| Exception | if index out of bounds |
|
override |
Access control point for reading.
| index | Control point index (must be valid) |
| Exception | if index out of bounds |
|
inline |
Get control points array.
|
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].
| controlPoints | Control points defining the curve shape |
| degree | Polynomial degree (must be ≥ 0 and < controlPoints.size()) |
| Exception | if controlPoints.empty() or degree ≥ controlPoints.size() |
|
static |
Create exact circular arc representation.
| center | Arc center point |
| radius | Arc radius (must be positive) |
| startAngle | Start angle in radians |
| endAngle | End angle in radians |
| normal | Normal vector for 3D arcs (default Z-axis) |
| knotMethod | Knot generation method for parameterization |
Compute the curvature scalar at the given parameter.
| parameter | Parameter value in the curve's parameter domain. |
parameter.
|
protected |
Evaluate curve using De Boor's algorithm for rational curves.
| span | Knot span containing parameter |
| parameter | Parameter value |
|
inlineoverride |
Return the polynomial degree of the curve.
|
override |
Compute the derivative of the curve at the given parameter.
| parameter | Parameter value in the curve's parameter domain. |
| order | Derivative order (1 = first derivative). Defaults to 1. |
parameter.
|
override |
Drop M coordinates from curve.
|
override |
Drop Z coordinates from curve.
| auto SFCGAL::NURBSCurve::elevateDegree | ( | unsigned int | times = 1 | ) | const -> std::unique_ptr<NURBSCurve> |
|
inline |
Get end tangent constraint if specified.
Evaluate the curve at the given parameter and return the corresponding point in Cartesian space.
| parameter | Parameter value in the curve's parameter domain. |
parameter.
|
protected |
Find parameter corresponding to arc length using Newton-Raphson.
| targetLength | Target arc length from start |
| tolerance | Convergence tolerance |
|
protected |
Find knot span containing parameter (Algorithm A2.1)
| parameter | Parameter value to locate |
|
static |
Unified curve fitting interface using FitMethod enum.
| points | Points to fit curve through or approximate |
| degree | Target curve degree |
| fitMethod | Whether to interpolate exactly or approximate within tolerance |
| knotMethod | Parameterization method for stability |
| endCondition | Boundary conditions for interpolation |
| tolerance | Maximum deviation for approximation (ignored for interpolation) |
| maxControlPoints | Maximum control points for approximation (ignored for interpolation) |
|
inline |
Get original fit points if curve was created by fitting.
|
inline |
Get fitting tolerance used.
|
override |
Return the Frenet frame at the given parameter as (tangent, normal, binormal).
| parameter | Parameter value in the curve's parameter domain. |
parameter.
|
static |
Create from Bezier control points.
| controlPoints | Bezier control points |
|
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.
| controlPoints | B-spline control points defining curve shape |
| degree | Polynomial degree (must be ≥ 0 and < controlPoints.size()) |
| knots | Complete knot vector (must satisfy: knots.size() = controlPoints.size() + degree + 1) |
| Exception | if parameters violate B-spline constraints |
|
staticprotected |
Generate knot vector for least-squares approximation.
| parameters | Parameter values for data points |
| degree | Curve degree |
| numControlPoints | Number of control points (m in Piegl & Tiller) |
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.
|
staticprotected |
Generate knot vector using specified method.
| points | Reference points for parameterization |
| degree | Curve degree |
| method | Knot generation method |
|
staticprotected |
Generate knot vector for specific end conditions.
| parameters | Parameter values for interpolation points |
| degree | Polynomial degree of the curve |
| endCondition | Type of end condition (clamped, natural, periodic) |
|
override |
Get the geometry type as string.
|
override |
Get the geometry type identifier.
| auto SFCGAL::NURBSCurve::getCurveStatistics | ( | ) | const -> std::map<std::string, double> |
Get detailed curve statistics for debugging.
| auto SFCGAL::NURBSCurve::insertKnot | ( | const Knot & | parameter, |
| unsigned int | times = 1 |
||
| ) | const -> std::unique_ptr<NURBSCurve> |
Insert knot into curve without changing shape (Oslo algorithm)
| parameter | Knot value to insert |
| times | Number of insertions (limited by degree) |
| Exception | if parameter outside knot span or too many insertions |
|
staticprotected |
Interpolate points with clamped end conditions.
| points | Data points to interpolate through |
| parameters | Parameter values at each data point |
| degree | Polynomial degree of interpolating curve |
| knots | Knot vector for interpolation |
|
static |
Interpolate points exactly with specified continuity.
| points | Points to interpolate through |
| degree | Curve degree (will be reduced if too high) |
| knotMethod | Parameterization method for stability |
| endCondition | Boundary conditions |
|
staticprotected |
Interpolate with natural end conditions (minimal curvature)
| points | Data points to interpolate through |
| parameters | Parameter values at each data point |
| degree | Polynomial degree of interpolating curve |
| knots | Knot vector for interpolation |
|
staticprotected |
Create periodic interpolating curve.
| points | Data points to interpolate (first and last should be same) |
| degree | Polynomial degree of curve |
| knotMethod | Knot generation method for parameterization |
|
override |
Check if curve is three-dimensional.
| auto SFCGAL::NURBSCurve::isBezier | ( | ) | const -> bool |
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).
| auto SFCGAL::NURBSCurve::isBSpline | ( | ) | const -> bool |
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.
|
override |
Check if curve is empty.
|
override |
Determine whether the curve is geometrically linear (represents a straight line).
|
override |
Check if curve has measure coordinates.
|
override |
True if the curve is periodic (periodic knot structure and matching end conditions).
|
override |
Check whether the curve is planar.
If plane is provided, fills it with plane coefficients.
| plane | Optional 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). |
|
override |
Check if curve uses non-uniform rational weights.
|
override |
Join this curve with other producing a single curve if they can be connected within the requested continuity and tolerance.
| other | Curve to join with. |
| continuity | Required continuity at the join point (default C0). |
| tolerance | Geometric tolerance for accepting the join. |
| auto SFCGAL::NURBSCurve::knot | ( | size_t | index | ) | const -> Knot |
Get knot value at index.
| index | Knot index |
| Exception | if index out of bounds |
| auto SFCGAL::NURBSCurve::knotMultiplicity | ( | const Knot & | value, |
| const FT & | tolerance = FT(1e-10) |
||
| ) | const -> unsigned int |
Count multiplicity of knot value.
| value | Knot value to count |
| tolerance | Tolerance for knot equality |
|
inline |
Return the knot vector for this curve.
The returned reference is to the internal, non-decreasing knot vector.
|
override |
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.
| from | Start parameter (use default to indicate domain start). |
| to | End parameter (use default to indicate domain end). |
| tolerance | Tolerance for numerical integration. |
from and to. Return the principal unit normal vector at the given parameter.
| parameter | Parameter value in the curve's parameter domain. |
parameter.
|
inlineoverride |
Get number of control points.
|
inline |
Get number of knots in vector.
|
default |
Assignment operator.
| other | The NURBSCurve to assign from |
|
inline |
Get curve order (degree + 1)
|
override |
Find the parameter corresponding to a given arc length measured from the start of the curve.
| arcLength | Target arc length along the curve (measured from domain start). |
| tolerance | Tolerance for the inverse mapping solver. |
arcLength. Return the parameter domain of the curve as [u_min, u_max].
|
protected |
Project point onto curve using Newton's method.
| point | Point to project |
| tolerance | Convergence tolerance |
| maxIterations | Maximum iterations |
| auto SFCGAL::NURBSCurve::reduceDegree | ( | const FT & | tolerance = FT(1e-6) | ) | const -> std::unique_ptr<NURBSCurve> |
Reduce degree if possible without shape change.
| tolerance | Maximum allowed deviation |
| auto SFCGAL::NURBSCurve::refineKnotVector | ( | const std::vector< Knot > & | newKnots | ) | const -> std::unique_ptr<NURBSCurve> |
Refine knot vector by adding multiple knots.
| newKnots | Sorted knots to insert |
| Exception | if knots not properly ordered |
| auto SFCGAL::NURBSCurve::removeKnots | ( | const FT & | tolerance = FT(1e-6) | ) | const -> std::unique_ptr<NURBSCurve> |
Remove unnecessary knots while preserving shape.
| tolerance | Maximum allowed deviation |
|
override |
|
override |
Return a new Curve representing this curve with reversed parameter direction.
| void SFCGAL::NURBSCurve::setControlPoint | ( | size_t | index, |
| const Point & | point | ||
| ) |
Set individual control point with validation.
| index | Control point index |
| point | New control point value |
| Exception | if index invalid or dimension mismatch |
| void SFCGAL::NURBSCurve::setControlPoints | ( | const std::vector< Point > & | controlPoints | ) |
Set all control points with validation.
| controlPoints | New control points |
| Exception | if dimensionally inconsistent or degree constraint violated |
| void SFCGAL::NURBSCurve::setKnotVector | ( | const std::vector< Knot > & | knots | ) |
Set knot vector with full validation.
| knots | New knot vector (must satisfy NURBS constraints) |
| Exception | if knot vector invalid for current curve parameters |
| void SFCGAL::NURBSCurve::setWeight | ( | size_t | index, |
| const FT & | weight | ||
| ) |
Set weight at specified index.
| index | Weight index |
| weight | New weight value (must be positive) |
| Exception | if index invalid or weight non-positive |
| void SFCGAL::NURBSCurve::setWeights | ( | const std::vector< FT > & | weights | ) |
Set all weights with validation.
| weights | New weights (must be positive and match control point count) |
| Exception | if invalid weights provided |
|
protected |
Apply Simpson's rule over interval [a,b].
| a | Start parameter |
| b | End parameter |
Compute speed function ||C'(t)|| for arc length integration.
| t | Parameter value |
|
override |
Split the curve at parameter into two curves [domain_start, parameter] and [parameter, domain_end].
| parameter | Parameter at which to split the curve. |
|
inline |
Get start tangent constraint if specified.
|
override |
Extract a subcurve between parameters from and to (inclusive of domain interval).
| from | Start parameter of the subcurve. |
| to | End parameter of the subcurve. |
|
override |
Swap the X and Y coordinates of all control points and any stored fit data.
Return the unit tangent vector at the given parameter.
| parameter | Parameter value in the curve's parameter domain. |
parameter.
|
override |
Convert the curve to a LineString by sampling numSegments uniformly in parameter space.
| numSegments | Number of segments (default 32) to use for the polyline approximation. |
|
override |
Convert the curve to a LineString using adaptive subdivision until the polyline approximates the curve within tolerance, respecting minSegments and maxSegments bounds.
| tolerance | Maximum allowed deviation between curve and polyline. |
| minSegments | Minimum number of segments to produce. |
| maxSegments | Maximum number of segments to produce. |
tolerance. Compute the torsion scalar at the given parameter.
| parameter | Parameter value in the curve's parameter domain. |
parameter. | auto SFCGAL::NURBSCurve::validateData | ( | ) | const -> std::pair<bool, std::string> |
Comprehensive NURBS data validation.
|
staticprotected |
Validate complete NURBS data structure.
| controlPoints | Control points to validate |
| weights | Weights to validate |
| degree | Degree to validate |
| knots | Knot vector to validate |
|
override |
Get weight at specified index.
| index | Weight index |
| Exception | if index out of bounds |
|
inline |
Get weights array.
|
protected |
Control points in curve space.
|
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
|
protected |
End tangent constraint.
|
protected |
Original points if fitted.
|
protected |
Non-decreasing knot sequence.
|
protected |
Start tangent constraint.
|
protected |
Weights (empty = all 1.0)
1.8.10