SFCGAL 2.3.0
SFCGAL::Curve Class Referenceabstract

Abstract base class for parametric curves. More...

#include <Curve.h>

Public Types

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

Public Member Functions

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

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

◆ FT

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

Floating-point type for curve calculations.

◆ Parameter

Parameter type for curve parameterization.

Member Enumeration Documentation

◆ Continuity

enum class 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

◆ Curve() [1/2]

SFCGAL::Curve::Curve ( )
default

Default constructor.

◆ Curve() [2/2]

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

Copy constructor.

Parameters
otherCurve to copy from

◆ ~Curve()

SFCGAL::Curve::~Curve ( )
overridedefault

Virtual destructor.

Member Function Documentation

◆ binormal()

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

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

Parameters
parameterParameter value
Returns
Binormal vector (tangent × normal)

◆ closestPoint()

virtual auto SFCGAL::Curve::closestPoint ( const Point & point,
Parameter * parameter = nullptr ) const -> Point
nodiscardpure virtual

Project point onto curve.

Parameters
pointPoint to project
parameterOutput parameter at closest point
Returns
Closest point on curve

◆ controlPointN() [1/2]

virtual auto SFCGAL::Curve::controlPointN ( size_t index) -> Point &
inlinenodiscardvirtual

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.

◆ controlPointN() [2/2]

virtual auto SFCGAL::Curve::controlPointN ( size_t index) const -> const Point &
inlinenodiscardvirtual

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.

◆ coordinateDimension()

auto SFCGAL::Curve::coordinateDimension ( ) const -> int
inlinenodiscardoverride

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).

◆ curvature()

virtual auto SFCGAL::Curve::curvature ( Parameter parameter) const -> FT
nodiscardpure virtual

Compute the curvature at parameter value.

Parameters
parameterParameter value
Returns
Curvature value (1/radius of curvature)

◆ degree()

virtual auto SFCGAL::Curve::degree ( ) const -> unsigned int
nodiscardpure virtual

Get the degree of the curve.

Returns
Polynomial degree

◆ denormalizeParameter()

auto SFCGAL::Curve::denormalizeParameter ( const FT & normalizedParameter) const -> Parameter
nodiscard

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

Parameters
normalizedParameterParameter in [0,1]
Returns
Actual parameter value

◆ derivative()

virtual auto SFCGAL::Curve::derivative ( Parameter parameter,
unsigned int order = 1 ) const -> Point
nodiscardpure 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

◆ dimension()

auto SFCGAL::Curve::dimension ( ) const -> int
inlinenodiscardoverride

Return the topological dimension of this geometry.

For Curve objects this is always 1.

Returns
The integer dimension (always 1 for curves).

◆ endPoint()

auto SFCGAL::Curve::endPoint ( ) const -> Point
nodiscard

Get the end point of the curve.

Returns
Last point of the curve

◆ evaluate()

virtual auto SFCGAL::Curve::evaluate ( Parameter parameter) const -> Point
nodiscardpure 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

◆ frenetFrame()

virtual auto SFCGAL::Curve::frenetFrame ( Parameter parameter) const -> std::tuple< Point, Point, Point >
nodiscardpure virtual

Get the Frenet-Serret frame at parameter value.

Parameters
parameterParameter value
Returns
Tuple of (tangent, normal, binormal) vectors

◆ isLinear()

virtual auto SFCGAL::Curve::isLinear ( ) const -> bool
nodiscardpure virtual

Check if the curve is linear (straight line).

Returns
true if curve is a straight line segment

◆ isPeriodic()

virtual auto SFCGAL::Curve::isPeriodic ( ) const -> bool
nodiscardpure virtual

Check if the curve is periodic.

Returns
true if curve has periodic parameterization

◆ isPlanar()

virtual auto SFCGAL::Curve::isPlanar ( std::vector< FT > * plane = nullptr) const -> bool
nodiscardpure virtual

Check if the curve is planar.

Parameters
planeOutput parameter for the plane equation if planar
Returns
true if curve lies in a plane

◆ isRational()

virtual auto SFCGAL::Curve::isRational ( ) const -> bool
inlinenodiscardvirtual

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

◆ isValidParameter()

auto SFCGAL::Curve::isValidParameter ( const Parameter & parameter) const -> bool
nodiscard

Check if a parameter value is within curve bounds.

Parameters
parameterParameter to check
Returns
true if parameter is valid for this curve

◆ join()

virtual auto SFCGAL::Curve::join ( const Curve & other,
Continuity continuity = Continuity::C0,
FT tolerance = FT(1e-6) ) const -> std::unique_ptr< Curve >
nodiscardpure 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

◆ length()

virtual auto SFCGAL::Curve::length ( Parameter from = Parameter(-1),
Parameter to = Parameter(-1),
FT tolerance = FT(1e-6) ) const -> FT
nodiscardpure virtual

Get the curve length.

Parameters
fromStart parameter (default: curve start)
toEnd parameter (default: curve end)
toleranceIntegration tolerance
Returns
Arc length between parameters

◆ midPoint()

auto SFCGAL::Curve::midPoint ( ) const -> Point
nodiscard

Get the midpoint of the curve.

Returns
Point at middle parameter value

◆ normal()

virtual auto SFCGAL::Curve::normal ( Parameter parameter) const -> Point
nodiscardpure virtual

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

Parameters
parameterParameter value
Returns
Normal vector perpendicular to tangent

◆ normalizeParameter()

auto SFCGAL::Curve::normalizeParameter ( const Parameter & parameter) const -> FT
nodiscard

Normalize parameter to [0,1] range.

Parameters
parameterRaw parameter value
Returns
Normalized parameter in [0,1]

◆ numControlPoints()

virtual auto SFCGAL::Curve::numControlPoints ( ) const -> size_t
inlinenodiscardvirtual

Get number of control points.

Returns
Control point count
Exceptions
Exceptionif not implemented for curve type

◆ operator=()

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

Assignment operator.

Parameters
otherCurve to assign from
Returns
Reference to this curve

◆ parameterAtLength()

virtual auto SFCGAL::Curve::parameterAtLength ( FT arcLength,
FT tolerance = FT(1e-6) ) const -> Parameter
nodiscardpure 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

◆ parameterBounds()

virtual auto SFCGAL::Curve::parameterBounds ( ) const -> std::pair< Parameter, Parameter >
nodiscardpure virtual

Get the parameter bounds of the curve.

Returns
Pair containing (minParameter, maxParameter)

◆ reparameterizeByArcLength()

virtual auto SFCGAL::Curve::reparameterizeByArcLength ( ) const -> std::unique_ptr< Curve >
nodiscardpure virtual

Reparameterize curve by arc length.

Returns
New curve parameterized by arc length [0, totalLength]

◆ reverse()

virtual auto SFCGAL::Curve::reverse ( ) const -> std::unique_ptr< Curve >
nodiscardpure virtual

Reverse the curve direction.

Returns
Reversed curve

◆ split()

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

Split curve at parameter value.

Parameters
parameterSplit location
Returns
Pair of curves (before split, after split)

◆ startPoint()

auto SFCGAL::Curve::startPoint ( ) const -> Point
nodiscard

Get the start point of the curve.

Returns
First point of the curve

◆ subcurve()

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

Extract subcurve between two parameters.

Parameters
fromStart parameter
toEnd parameter
Returns
Subcurve between parameters

◆ tangent()

virtual auto SFCGAL::Curve::tangent ( Parameter parameter) const -> Point
nodiscardpure virtual

Compute the tangent unit vector at parameter value.

Parameters
parameterParameter value
Returns
Normalized tangent vector

◆ toLineString()

virtual auto SFCGAL::Curve::toLineString ( unsigned int numSegments = 32) const -> std::unique_ptr< LineString >
nodiscardpure virtual

Convert curve to a LineString approximation.

Parameters
numSegmentsNumber of line segments to use
Returns
LineString approximating the curve

◆ toLineStringAdaptive()

virtual auto SFCGAL::Curve::toLineStringAdaptive ( FT tolerance = FT(1e-3),
unsigned int minSegments = 8,
unsigned int maxSegments = 256 ) const -> std::unique_ptr< LineString >
nodiscardpure 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

◆ torsion()

virtual auto SFCGAL::Curve::torsion ( Parameter parameter) const -> FT
nodiscardpure virtual

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

Parameters
parameterParameter value
Returns
Torsion value (measure of curve twisting)

◆ weight()

virtual auto SFCGAL::Curve::weight ( size_t index) const -> FT
inlinenodiscardvirtual

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.