SFCGAL  2.3.0
Public Types | Public Member Functions | List of all members
SFCGAL::Curve Class Referenceabstract

Abstract base class for parametric curves. More...

#include <Curve.h>

Inherits SFCGAL::GeometryImpl< Derived, Base >.

Inherited by SFCGAL::GeometryImpl< NURBSCurve, Curve >.

Public Types

enum  Continuity : std::uint8_t {
  Continuity::C0, Continuity::C1, Continuity::C2, Continuity::G1,
  Continuity::G2
}
 Curve continuity types. More...
 
using FT = Kernel::FT
 Floating-point type for curve calculations. More...
 
using Parameter = FT
 Parameter type for curve parameterization. More...
 

Public Member Functions

 Curve ()
 Default constructor. More...
 
 Curve (const Curve &other)
 Copy constructor. More...
 
auto operator= (const Curve &other) -> Curve &
 Assignment operator. More...
 
 ~Curve () override
 Virtual destructor. More...
 
auto dimension () const -> int override
 Return the topological dimension of this geometry. More...
 
auto coordinateDimension () const -> int override
 Return the coordinate dimension of the curve. More...
 
virtual auto evaluate (Parameter parameter) const -> Point=0
 Evaluate the curve at parameter value. More...
 
virtual auto derivative (Parameter parameter, unsigned int order=1) const -> Point=0
 Compute the derivative of the curve at parameter value. More...
 
virtual auto tangent (Parameter parameter) const -> Point=0
 Compute the tangent unit vector at parameter value. More...
 
virtual auto normal (Parameter parameter) const -> Point=0
 Compute the normal vector at parameter value (for planar curves) More...
 
virtual auto binormal (Parameter parameter) const -> Point=0
 Compute the binormal vector at parameter value (for 3D curves) More...
 
virtual auto curvature (Parameter parameter) const -> FT=0
 Compute the curvature at parameter value. More...
 
virtual auto torsion (Parameter parameter) const -> FT=0
 Compute the torsion at parameter value (for 3D curves) More...
 
virtual auto frenetFrame (Parameter parameter) const -> std::tuple< Point, Point, Point >=0
 Get the Frenet-Serret frame at parameter value. More...
 
virtual auto toLineString (unsigned int numSegments=32) const -> std::unique_ptr< LineString >=0
 Convert curve to a LineString approximation. More...
 
virtual auto toLineStringAdaptive (FT tolerance=FT(1e-3), unsigned int minSegments=8, unsigned int maxSegments=256) const -> std::unique_ptr< LineString >=0
 Convert curve to LineString with adaptive sampling. More...
 
virtual auto parameterBounds () const -> std::pair< Parameter, Parameter >=0
 Get the parameter bounds of the curve. More...
 
virtual auto isPeriodic () const -> bool=0
 Check if the curve is periodic. More...
 
virtual auto isPlanar (std::vector< FT > *plane=nullptr) const -> bool=0
 Check if the curve is planar. More...
 
virtual auto isLinear () const -> bool=0
 Check if the curve is linear (straight line) More...
 
virtual auto degree () const -> unsigned int=0
 Get the degree of the curve. More...
 
virtual auto length (Parameter from=Parameter(-1), Parameter to=Parameter(-1), FT tolerance=FT(1e-6)) const -> FT=0
 Get the curve length. More...
 
virtual auto parameterAtLength (FT arcLength, FT tolerance=FT(1e-6)) const -> Parameter=0
 Find parameter value at given arc length from start. More...
 
virtual auto reparameterizeByArcLength () const -> std::unique_ptr< Curve >=0
 Reparameterize curve by arc length. More...
 
virtual auto split (Parameter parameter) const -> std::pair< std::unique_ptr< Curve >, std::unique_ptr< Curve >>=0
 Split curve at parameter value. More...
 
virtual auto subcurve (Parameter from, Parameter to) const -> std::unique_ptr< Curve >=0
 Extract subcurve between two parameters. More...
 
virtual auto reverse () const -> std::unique_ptr< Curve >=0
 Reverse the curve direction. More...
 
virtual auto join (const Curve &other, Continuity continuity=Continuity::C0, FT tolerance=FT(1e-6)) const -> std::unique_ptr< Curve >=0
 Join with another curve. More...
 
virtual auto closestPoint (const Point &point, Parameter *parameter=nullptr) const -> Point=0
 Project point onto curve. More...
 
virtual auto numControlPoints () const -> size_t
 Get number of control points. More...
 
virtual auto isRational () const -> bool
 Check if curve uses non-uniform rational weights. More...
 
virtual auto weight (size_t index) const -> FT
 Return the rational weight of the curve's control point at the given index. More...
 
virtual auto controlPointN (size_t index) const -> const Point &
 Return a read-only reference to the control point at the given index. More...
 
virtual auto controlPointN (size_t index) -> Point &
 Return a modifiable reference to the control point at the given index. More...
 
auto startPoint () const -> Point
 Get the start point of the curve. More...
 
auto endPoint () const -> Point
 Get the end point of the curve. More...
 
auto midPoint () const -> Point
 Get the midpoint of the curve. More...
 
auto isValidParameter (const Parameter &parameter) const -> bool
 Check if a parameter value is within curve bounds. More...
 
auto normalizeParameter (const Parameter &parameter) const -> FT
 Normalize parameter to [0,1] range. More...
 
auto denormalizeParameter (const FT &normalizedParameter) const -> Parameter
 Denormalize parameter from [0,1] to actual range. More...
 

Detailed Description

Abstract base class for parametric curves.

This class provides a common interface for parametric curves. All curves are represented as NURBS (Non-Uniform Rational B-Splines) which can degenerate to B-splines (uniform weights) or Bezier curves.

Since
2.3.0

Member Typedef Documentation

using SFCGAL::Curve::FT = Kernel::FT

Floating-point type for curve calculations.

Parameter type for curve parameterization.

Member Enumeration Documentation

enum SFCGAL::Curve::Continuity : std::uint8_t
strong

Curve continuity types.

Enumerator
C0 

Position continuity (sharp corners allowed)

C1 

Tangent continuity.

C2 

Curvature continuity.

G1 

Geometric tangent continuity.

G2 

Geometric curvature continuity.

Constructor & Destructor Documentation

SFCGAL::Curve::Curve ( )
default

Default constructor.

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

Copy constructor.

Parameters
otherCurve to copy from
SFCGAL::Curve::~Curve ( )
overridedefault

Virtual destructor.

Member Function Documentation

virtual auto SFCGAL::Curve::binormal ( Parameter  parameter) const -> Point
pure virtual

Compute the binormal vector at parameter value (for 3D curves)

Parameters
parameterParameter value
Returns
Binormal vector (tangent × normal)
virtual auto SFCGAL::Curve::closestPoint ( const Point &  point,
Parameter *  parameter = nullptr 
) const -> Point
pure virtual

Project point onto curve.

Parameters
pointPoint to project
parameterOutput parameter at closest point
Returns
Closest point on curve
virtual auto SFCGAL::Curve::controlPointN ( size_t  index) const -> const Point &
inlinevirtual

Return a read-only reference to the control point at the given index.

This method is part of the NURBS-specific interface. The base implementation always throws an Exception to indicate the operation is not supported for curve types that do not expose control points.

Parameters
indexIndex of the control point.
Returns
Const reference to the control point at index.
Exceptions
Exceptionif the curve type does not support control points or if index is out of range for implementations that override this method.
virtual auto SFCGAL::Curve::controlPointN ( size_t  index) -> Point &
inlinevirtual

Return a modifiable reference to the control point at the given index.

Concrete NURBS-style curve implementations should override this to provide writable access to their control points. The base implementation throws an Exception indicating the operation is not supported for this curve type.

Parameters
indexZero-based control point index.
Returns
Reference to the control point that can be modified.
Exceptions
ExceptionIf the curve type does not support control point access or if index is out of range.
auto SFCGAL::Curve::coordinateDimension ( ) const -> int
inlineoverride

Return the coordinate dimension of the curve.

Computes 2 for non-3D curves or 3 for 3D curves, and adds 1 if the curve is measured.

Returns
Coordinate dimension (2 or 3, plus 1 when measured).
virtual auto SFCGAL::Curve::curvature ( Parameter  parameter) const -> FT
pure virtual

Compute the curvature at parameter value.

Parameters
parameterParameter value
Returns
Curvature value (1/radius of curvature)
virtual auto SFCGAL::Curve::degree ( ) const -> unsigned int
pure virtual

Get the degree of the curve.

Returns
Polynomial degree
auto SFCGAL::Curve::denormalizeParameter ( const FT &  normalizedParameter) const -> Parameter

Denormalize parameter from [0,1] to actual range.

Parameters
normalizedParameterParameter in [0,1]
Returns
Actual parameter value
virtual auto SFCGAL::Curve::derivative ( Parameter  parameter,
unsigned int  order = 1 
) const -> Point
pure virtual

Compute the derivative of the curve at parameter value.

Parameters
parameterParameter value
orderDerivative order (1 for first derivative, 2 for second, etc.)
Returns
Vector representing the derivative at parameter
auto SFCGAL::Curve::dimension ( ) const -> int
inlineoverride

Return the topological dimension of this geometry.

For Curve objects this is always 1.

Returns
The integer dimension (always 1 for curves).
auto SFCGAL::Curve::endPoint ( ) const -> Point

Get the end point of the curve.

Returns
Last point of the curve
virtual auto SFCGAL::Curve::evaluate ( Parameter  parameter) const -> Point
pure virtual

Evaluate the curve at parameter value.

Parameters
parameterParameter value (usually in [tMin, tMax])
Returns
Point on the curve at parameter
Exceptions
Exceptionif parameter is outside valid range
virtual auto SFCGAL::Curve::frenetFrame ( Parameter  parameter) const -> std::tuple< Point, Point, Point >
pure virtual

Get the Frenet-Serret frame at parameter value.

Parameters
parameterParameter value
Returns
Tuple of (tangent, normal, binormal) vectors
virtual auto SFCGAL::Curve::isLinear ( ) const -> bool
pure virtual

Check if the curve is linear (straight line)

Returns
true if curve is a straight line segment
virtual auto SFCGAL::Curve::isPeriodic ( ) const -> bool
pure virtual

Check if the curve is periodic.

Returns
true if curve has periodic parameterization
virtual auto SFCGAL::Curve::isPlanar ( std::vector< FT > *  plane = nullptr) const -> bool
pure virtual

Check if the curve is planar.

Parameters
planeOutput parameter for the plane equation if planar
Returns
true if curve lies in a plane
virtual auto SFCGAL::Curve::isRational ( ) const -> bool
inlinevirtual

Check if curve uses non-uniform rational weights.

Returns
false for non-NURBS curves, true if NURBS with varying weights
Exceptions
Exceptionif not implemented for curve type
auto SFCGAL::Curve::isValidParameter ( const Parameter &  parameter) const -> bool

Check if a parameter value is within curve bounds.

Parameters
parameterParameter to check
Returns
true if parameter is valid for this curve
virtual auto SFCGAL::Curve::join ( const Curve &  other,
Continuity  continuity = Continuity::C0,
FT  tolerance = FT(1e-6) 
) const -> std::unique_ptr< Curve >
pure virtual

Join with another curve.

Parameters
otherCurve to join with
continuityDesired continuity at join
toleranceTolerance for join
Returns
Joined curve or nullptr if join impossible
virtual auto SFCGAL::Curve::length ( Parameter  from = Parameter(-1),
Parameter  to = Parameter(-1),
FT  tolerance = FT(1e-6) 
) const -> FT
pure virtual

Get the curve length.

Parameters
fromStart parameter (default: curve start)
toEnd parameter (default: curve end)
toleranceIntegration tolerance
Returns
Arc length between parameters
auto SFCGAL::Curve::midPoint ( ) const -> Point

Get the midpoint of the curve.

Returns
Point at middle parameter value
virtual auto SFCGAL::Curve::normal ( Parameter  parameter) const -> Point
pure virtual

Compute the normal vector at parameter value (for planar curves)

Parameters
parameterParameter value
Returns
Normal vector perpendicular to tangent
auto SFCGAL::Curve::normalizeParameter ( const Parameter &  parameter) const -> FT

Normalize parameter to [0,1] range.

Parameters
parameterRaw parameter value
Returns
Normalized parameter in [0,1]
virtual auto SFCGAL::Curve::numControlPoints ( ) const -> size_t
inlinevirtual

Get number of control points.

Returns
Control point count
Exceptions
Exceptionif not implemented for curve type
auto SFCGAL::Curve::operator= ( const Curve &  other) -> Curve &
default

Assignment operator.

Parameters
otherCurve to assign from
Returns
Reference to this curve
virtual auto SFCGAL::Curve::parameterAtLength ( FT  arcLength,
FT  tolerance = FT(1e-6) 
) const -> Parameter
pure virtual

Find parameter value at given arc length from start.

Parameters
arcLengthTarget arc length from curve start
toleranceTolerance for root finding
Returns
Parameter value at specified arc length
virtual auto SFCGAL::Curve::parameterBounds ( ) const -> std::pair< Parameter, Parameter >
pure virtual

Get the parameter bounds of the curve.

Returns
Pair containing (minParameter, maxParameter)
virtual auto SFCGAL::Curve::reparameterizeByArcLength ( ) const -> std::unique_ptr< Curve >
pure virtual

Reparameterize curve by arc length.

Returns
New curve parameterized by arc length [0, totalLength]
virtual auto SFCGAL::Curve::reverse ( ) const -> std::unique_ptr< Curve >
pure virtual

Reverse the curve direction.

Returns
Reversed curve
virtual auto SFCGAL::Curve::split ( Parameter  parameter) const -> std::pair< std::unique_ptr< Curve >, std::unique_ptr< Curve >>
pure virtual

Split curve at parameter value.

Parameters
parameterSplit location
Returns
Pair of curves (before split, after split)
auto SFCGAL::Curve::startPoint ( ) const -> Point

Get the start point of the curve.

Returns
First point of the curve
virtual auto SFCGAL::Curve::subcurve ( Parameter  from,
Parameter  to 
) const -> std::unique_ptr< Curve >
pure virtual

Extract subcurve between two parameters.

Parameters
fromStart parameter
toEnd parameter
Returns
Subcurve between parameters
virtual auto SFCGAL::Curve::tangent ( Parameter  parameter) const -> Point
pure virtual

Compute the tangent unit vector at parameter value.

Parameters
parameterParameter value
Returns
Normalized tangent vector
virtual auto SFCGAL::Curve::toLineString ( unsigned int  numSegments = 32) const -> std::unique_ptr< LineString >
pure virtual

Convert curve to a LineString approximation.

Parameters
numSegmentsNumber of line segments to use
Returns
LineString approximating the curve
virtual auto SFCGAL::Curve::toLineStringAdaptive ( FT  tolerance = FT(1e-3),
unsigned int  minSegments = 8,
unsigned int  maxSegments = 256 
) const -> std::unique_ptr< LineString >
pure virtual

Convert curve to LineString with adaptive sampling.

Parameters
toleranceMaximum deviation from actual curve
minSegmentsMinimum number of segments
maxSegmentsMaximum number of segments
Returns
Adaptively sampled LineString
virtual auto SFCGAL::Curve::torsion ( Parameter  parameter) const -> FT
pure virtual

Compute the torsion at parameter value (for 3D curves)

Parameters
parameterParameter value
Returns
Torsion value (measure of curve twisting)
virtual auto SFCGAL::Curve::weight ( size_t  index) const -> FT
inlinevirtual

Return the rational weight of the curve's control point at the given index.

Default implementation throws an Exception indicating that weight access is not supported for this curve type; concrete NURBS-derived classes must override to provide valid weights.

Parameters
indexIndex of the control point weight.
Returns
Weight value associated with the control point.
Exceptions
Exceptionif this curve type does not support weights or if the index is out of range.