Project
Loading...
Searching...
No Matches
o2::cad::surface::Curve2D Struct Reference

One trimmed boundary curve in a surface's (u, v) domain: a line segment, a circular arc or a clamped (rational) B-spline. More...

#include <BoundedSurface.h>

Public Member Functions

bool isArc () const
 
bool isBSpline () const
 
double sweep () const
 
bool valid () const
 
Vec2 pointAtAngle (double angle) const
 
Vec2 pointAt (double parameter) const
 Point at curve parameter parameter in [0, 1] (0 at the start, 1 at the end).
 
Vec2 startPoint () const
 
Vec2 endPoint () const
 
Vec2 derivativeAt (double parameter) const
 dC/dt at parameter in [0, 1], unnormalised; tangentAt() is it normalised.
 
Vec2 tangentAt (double parameter) const
 Unit tangent at parameter parameter, pointing in the direction of increasing parameter.
 
bool angleInSweep (double angle) const
 True if angle lies within the arc's angular sweep (accounting for direction and wrap).
 
double angleParameter (double angle) const
 Map an angle known to lie within the sweep to a clamped parameter in [0, 1].
 
void extendBounds (Vec2 &lower, Vec2 &upper) const
 Accumulate this curve's exact extent into a parametric axis-aligned bounding box.
 
void extendTightBounds (Vec2 &lower, Vec2 &upper) const
 As extendBounds, measured on the curve: a B-spline contributes its sampled polyline, not its pole hull.
 
template<typename Include >
void includeAnalyticExtremes (const Include &include) const
 Endpoints plus an arc's axis-extreme points inside the sweep: the exact extent of a line or an arc.
 
Vec2 closestPoint (const Vec2 &point, double &parameter) const
 Closest point on the curve to point, returning the clamped parameter in parameter.
 
double distanceSq (const Vec2 &point) const
 Squared distance from point to the curve.
 
double signedAreaContribution () const
 
double representationTolerance () const
 How far this curve's representation can sit from the curve, in parametric units: kBSplineFlatness for a B-spline, else 0.
 
bool bsplineBandOrCrossings (const Vec2 &point, double bandSq, int &crossings) const
 
int rightwardCrossings (const Vec2 &point, const Vec2 &canonicalStart, const Vec2 &canonicalEnd) const
 Rightward crossings of a horizontal ray from point, with the caller's canonical endpoints so that seams stay consistent.
 
void reverseInPlace ()
 Reverse the curve's direction in place (start <-> end), keeping the same geometric image.
 
B-spline evaluation helpers (kind == BSpline)
double bsplineT0 () const
 
double bsplineT1 () const
 
bool bsplineIsClamped () const
 True when the knot vector is clamped, so the curve interpolates its first and last pole.
 
bool bsplineRational () const
 True if the curve carries non-unit weights (a rational B-spline).
 
int bsplineSpan (double knotValue) const
 Knot span index of parameter knotValue for the clamped knot vector.
 
void bsplineBasis (int span, double knotValue, std::vector< double > &basis, std::vector< double > &basisDeriv) const
 Non-zero degree-p basis functions and first derivatives at knotValue in span (The NURBS Book, DersBasisFuns).
 
void bsplineEval (double knotValue, Vec2 &pointOut, Vec2 &derivativeOut) const
 
Vec2 bsplinePointAt (double parameter) const
 B-spline point at curve parameter parameter in [0, 1].
 
void bsplineSampleInto (std::vector< Vec2 > &samples, double flatnessSq=kBSplineFlatnessSq, int maxDepth=16) const
 Adaptively sample the B-spline into an on-curve polyline, subdividing until each chord is flat to sqrt(flatnessSq).
 
bool spansInteriorKnot (double lowT, double highT) const
 Whether a knot lies strictly inside (lowT, highT); such an interval is never called flat.
 
void appendInteriorKnots (double from, double to, std::vector< double > &breakpoints) const
 Append the interior knots in (from, to), in the curve's [0, 1] parameter; none for a line or an arc.
 
double uVariation (double from, double to) const
 An upper bound on how far u travels along the curve between from and to.
 
void bsplineSampleRecursive (double t0, double t1, const Vec2 &p0, const Vec2 &p1, double flatnessSq, int depth, std::vector< Vec2 > &samples) const
 
const std::vector< Vec2 > & bsplineSamples () const
 The flattened polyline in bsplineCache, computed here if the wire has not filled it.
 

Static Public Member Functions

static Curve2D makeLine (const Vec2 &start, const Vec2 &end)
 
static Curve2D makeArc (const Vec2 &arcCenter, double arcRadius, double arcStartAngle, double arcEndAngle)
 
static Curve2D makeCircle (const Vec2 &arcCenter, double arcRadius, bool clockwise=false)
 Full circle as one arc curve (counter-clockwise unless clockwise is set).
 
static Curve2D makeBSpline (int splineDegree, std::vector< Vec2 > splinePoles, std::vector< double > splineWeights, std::vector< double > splineKnots)
 

Public Attributes

CurveKind kind = CurveKind::Line
 
Vec2 lineStart
 line: start point (unused for arcs)
 
Vec2 lineEnd
 line: end point (unused for arcs)
 
Vec2 center
 arc: circle centre (unused for lines)
 
double radius = 0.
 arc: circle radius
 
double startAngle = 0.
 arc: start angle [rad]
 
double endAngle = 0.
 arc: end angle [rad] (sweep = endAngle - startAngle)
 
B-spline data (kind == BSpline): poles, optional weights and a clamped knot vector; the curve parameter runs on [0, 1]. @{
int degree = 0
 
std::vector< Vec2poles
 
std::vector< double > weights
 
std::vector< double > knots
 
std::vector< Vec2bsplineCache
 The flattened on-curve polyline, both ends included; CurveWire::initialize fills it and reversing clears it.
 

Loop-canonical endpoints: the seam vertices the curve's neighbours agree on, substituted at the polyline's ends

Vec2 canonicalStart
 
Vec2 canonicalEnd
 
bool hasCanonicalEndpoints = false
 
void setCanonicalEndpoints (const Vec2 &start, const Vec2 &end)
 
Vec2 loopStart () const
 
Vec2 loopEnd () const
 

Detailed Description

One trimmed boundary curve in a surface's (u, v) domain: a line segment, a circular arc or a clamped (rational) B-spline.

Definition at line 981 of file BoundedSurface.h.

Member Function Documentation

◆ angleInSweep()

bool o2::cad::surface::Curve2D::angleInSweep ( double  angle) const
inline

True if angle lies within the arc's angular sweep (accounting for direction and wrap).

Definition at line 1456 of file BoundedSurface.h.

◆ angleParameter()

double o2::cad::surface::Curve2D::angleParameter ( double  angle) const
inline

Map an angle known to lie within the sweep to a clamped parameter in [0, 1].

Definition at line 1469 of file BoundedSurface.h.

◆ appendInteriorKnots()

void o2::cad::surface::Curve2D::appendInteriorKnots ( double  from,
double  to,
std::vector< double > &  breakpoints 
) const
inline

Append the interior knots in (from, to), in the curve's [0, 1] parameter; none for a line or an arc.

Definition at line 1228 of file BoundedSurface.h.

◆ bsplineBandOrCrossings()

bool o2::cad::surface::Curve2D::bsplineBandOrCrossings ( const Vec2 point,
double  bandSq,
int crossings 
) const
inline

B-spline only: true if point is within sqrt(bandSq) of the polyline, else adds its rightward crossings. One walk of the polyline with the arithmetic of closestPoint and rightwardCrossings.

Definition at line 1660 of file BoundedSurface.h.

◆ bsplineBasis()

void o2::cad::surface::Curve2D::bsplineBasis ( int  span,
double  knotValue,
std::vector< double > &  basis,
std::vector< double > &  basisDeriv 
) const
inline

Non-zero degree-p basis functions and first derivatives at knotValue in span (The NURBS Book, DersBasisFuns).

Definition at line 1118 of file BoundedSurface.h.

◆ bsplineEval()

void o2::cad::surface::Curve2D::bsplineEval ( double  knotValue,
Vec2 pointOut,
Vec2 derivativeOut 
) const
inline

Evaluate the (rational) B-spline point pointOut and its knot-parameter derivative derivativeOut at knot parameter knotValue.

Definition at line 1159 of file BoundedSurface.h.

◆ bsplineIsClamped()

bool o2::cad::surface::Curve2D::bsplineIsClamped ( ) const
inline

True when the knot vector is clamped, so the curve interpolates its first and last pole.

Definition at line 1070 of file BoundedSurface.h.

◆ bsplinePointAt()

Vec2 o2::cad::surface::Curve2D::bsplinePointAt ( double  parameter) const
inline

B-spline point at curve parameter parameter in [0, 1].

Definition at line 1187 of file BoundedSurface.h.

◆ bsplineRational()

bool o2::cad::surface::Curve2D::bsplineRational ( ) const
inline

True if the curve carries non-unit weights (a rational B-spline).

Definition at line 1083 of file BoundedSurface.h.

◆ bsplineSampleInto()

void o2::cad::surface::Curve2D::bsplineSampleInto ( std::vector< Vec2 > &  samples,
double  flatnessSq = kBSplineFlatnessSq,
int  maxDepth = 16 
) const
inline

Adaptively sample the B-spline into an on-curve polyline, subdividing until each chord is flat to sqrt(flatnessSq).

Definition at line 1197 of file BoundedSurface.h.

◆ bsplineSampleRecursive()

void o2::cad::surface::Curve2D::bsplineSampleRecursive ( double  t0,
double  t1,
const Vec2 p0,
const Vec2 p1,
double  flatnessSq,
int  depth,
std::vector< Vec2 > &  samples 
) const
inline

Definition at line 1288 of file BoundedSurface.h.

◆ bsplineSamples()

const std::vector< Vec2 > & o2::cad::surface::Curve2D::bsplineSamples ( ) const
inline

The flattened polyline in bsplineCache, computed here if the wire has not filled it.

Definition at line 1316 of file BoundedSurface.h.

◆ bsplineSpan()

int o2::cad::surface::Curve2D::bsplineSpan ( double  knotValue) const
inline

Knot span index of parameter knotValue for the clamped knot vector.

Definition at line 1094 of file BoundedSurface.h.

◆ bsplineT0()

double o2::cad::surface::Curve2D::bsplineT0 ( ) const
inline

Definition at line 1066 of file BoundedSurface.h.

◆ bsplineT1()

double o2::cad::surface::Curve2D::bsplineT1 ( ) const
inline

Definition at line 1067 of file BoundedSurface.h.

◆ closestPoint()

Vec2 o2::cad::surface::Curve2D::closestPoint ( const Vec2 point,
double &  parameter 
) const
inline

Closest point on the curve to point, returning the clamped parameter in parameter.

Definition at line 1536 of file BoundedSurface.h.

◆ derivativeAt()

Vec2 o2::cad::surface::Curve2D::derivativeAt ( double  parameter) const
inline

dC/dt at parameter in [0, 1], unnormalised; tangentAt() is it normalised.

Definition at line 1411 of file BoundedSurface.h.

◆ distanceSq()

double o2::cad::surface::Curve2D::distanceSq ( const Vec2 point) const
inline

Squared distance from point to the curve.

Definition at line 1609 of file BoundedSurface.h.

◆ endPoint()

Vec2 o2::cad::surface::Curve2D::endPoint ( ) const
inline

Definition at line 1399 of file BoundedSurface.h.

◆ extendBounds()

void o2::cad::surface::Curve2D::extendBounds ( Vec2 lower,
Vec2 upper 
) const
inline

Accumulate this curve's exact extent into a parametric axis-aligned bounding box.

Definition at line 1481 of file BoundedSurface.h.

◆ extendTightBounds()

void o2::cad::surface::Curve2D::extendTightBounds ( Vec2 lower,
Vec2 upper 
) const
inline

As extendBounds, measured on the curve: a B-spline contributes its sampled polyline, not its pole hull.

Definition at line 1501 of file BoundedSurface.h.

◆ includeAnalyticExtremes()

template<typename Include >
void o2::cad::surface::Curve2D::includeAnalyticExtremes ( const Include &  include) const
inline

Endpoints plus an arc's axis-extreme points inside the sweep: the exact extent of a line or an arc.

Definition at line 1520 of file BoundedSurface.h.

◆ isArc()

bool o2::cad::surface::Curve2D::isArc ( ) const
inline

Definition at line 1059 of file BoundedSurface.h.

◆ isBSpline()

bool o2::cad::surface::Curve2D::isBSpline ( ) const
inline

Definition at line 1060 of file BoundedSurface.h.

◆ loopEnd()

Vec2 o2::cad::surface::Curve2D::loopEnd ( ) const
inline

Definition at line 1016 of file BoundedSurface.h.

◆ loopStart()

Vec2 o2::cad::surface::Curve2D::loopStart ( ) const
inline

Where this curve begins and ends as far as the loop is concerned: the canonical seam vertex when a wire has fixed one, and the curve's own endpoint when it stands alone.

Definition at line 1015 of file BoundedSurface.h.

◆ makeArc()

static Curve2D o2::cad::surface::Curve2D::makeArc ( const Vec2 arcCenter,
double  arcRadius,
double  arcStartAngle,
double  arcEndAngle 
)
inlinestatic

Definition at line 1028 of file BoundedSurface.h.

◆ makeBSpline()

static Curve2D o2::cad::surface::Curve2D::makeBSpline ( int  splineDegree,
std::vector< Vec2 splinePoles,
std::vector< double >  splineWeights,
std::vector< double >  splineKnots 
)
inlinestatic

Clamped (rational) B-spline curve of degree splineDegree. splineWeights may be empty for a non-rational curve; splineKnots must be the clamped flat knot vector.

Definition at line 1047 of file BoundedSurface.h.

◆ makeCircle()

static Curve2D o2::cad::surface::Curve2D::makeCircle ( const Vec2 arcCenter,
double  arcRadius,
bool  clockwise = false 
)
inlinestatic

Full circle as one arc curve (counter-clockwise unless clockwise is set).

Definition at line 1040 of file BoundedSurface.h.

◆ makeLine()

static Curve2D o2::cad::surface::Curve2D::makeLine ( const Vec2 start,
const Vec2 end 
)
inlinestatic

Definition at line 1019 of file BoundedSurface.h.

◆ pointAt()

Vec2 o2::cad::surface::Curve2D::pointAt ( double  parameter) const
inline

Point at curve parameter parameter in [0, 1] (0 at the start, 1 at the end).

Definition at line 1376 of file BoundedSurface.h.

◆ pointAtAngle()

Vec2 o2::cad::surface::Curve2D::pointAtAngle ( double  angle) const
inline

Definition at line 1370 of file BoundedSurface.h.

◆ representationTolerance()

double o2::cad::surface::Curve2D::representationTolerance ( ) const
inline

How far this curve's representation can sit from the curve, in parametric units: kBSplineFlatness for a B-spline, else 0.

Definition at line 1656 of file BoundedSurface.h.

◆ reverseInPlace()

void o2::cad::surface::Curve2D::reverseInPlace ( )
inline

Reverse the curve's direction in place (start <-> end), keeping the same geometric image.

Definition at line 1795 of file BoundedSurface.h.

◆ rightwardCrossings()

int o2::cad::surface::Curve2D::rightwardCrossings ( const Vec2 point,
const Vec2 canonicalStart,
const Vec2 canonicalEnd 
) const
inline

Rightward crossings of a horizontal ray from point, with the caller's canonical endpoints so that seams stay consistent.

Definition at line 1701 of file BoundedSurface.h.

◆ setCanonicalEndpoints()

void o2::cad::surface::Curve2D::setCanonicalEndpoints ( const Vec2 start,
const Vec2 end 
)
inline

Definition at line 1005 of file BoundedSurface.h.

◆ signedAreaContribution()

double o2::cad::surface::Curve2D::signedAreaContribution ( ) const
inline

Exact contribution of this directed curve to the enclosed signed area, i.e. (1/2) * integral of (u dv - v du) along the curve (Green's theorem).

Definition at line 1617 of file BoundedSurface.h.

◆ spansInteriorKnot()

bool o2::cad::surface::Curve2D::spansInteriorKnot ( double  lowT,
double  highT 
) const
inline

Whether a knot lies strictly inside (lowT, highT); such an interval is never called flat.

Definition at line 1212 of file BoundedSurface.h.

◆ startPoint()

Vec2 o2::cad::surface::Curve2D::startPoint ( ) const
inline

Definition at line 1388 of file BoundedSurface.h.

◆ sweep()

double o2::cad::surface::Curve2D::sweep ( ) const
inline

Definition at line 1062 of file BoundedSurface.h.

◆ tangentAt()

Vec2 o2::cad::surface::Curve2D::tangentAt ( double  parameter) const
inline

Unit tangent at parameter parameter, pointing in the direction of increasing parameter.

Definition at line 1428 of file BoundedSurface.h.

◆ uVariation()

double o2::cad::surface::Curve2D::uVariation ( double  from,
double  to 
) const
inline

An upper bound on how far u travels along the curve between from and to.

Definition at line 1249 of file BoundedSurface.h.

◆ valid()

bool o2::cad::surface::Curve2D::valid ( ) const
inline

Basic structural validity (finite data, positive radius for arcs, well-formed clamped knot vector for B-splines).

Definition at line 1332 of file BoundedSurface.h.

Member Data Documentation

◆ bsplineCache

std::vector<Vec2> o2::cad::surface::Curve2D::bsplineCache
mutable

The flattened on-curve polyline, both ends included; CurveWire::initialize fills it and reversing clears it.

Definition at line 996 of file BoundedSurface.h.

◆ canonicalEnd

Vec2 o2::cad::surface::Curve2D::canonicalEnd

Definition at line 1002 of file BoundedSurface.h.

◆ canonicalStart

Vec2 o2::cad::surface::Curve2D::canonicalStart

Definition at line 1001 of file BoundedSurface.h.

◆ center

Vec2 o2::cad::surface::Curve2D::center

arc: circle centre (unused for lines)

Definition at line 985 of file BoundedSurface.h.

◆ degree

int o2::cad::surface::Curve2D::degree = 0

Definition at line 991 of file BoundedSurface.h.

◆ endAngle

double o2::cad::surface::Curve2D::endAngle = 0.

arc: end angle [rad] (sweep = endAngle - startAngle)

Definition at line 988 of file BoundedSurface.h.

◆ hasCanonicalEndpoints

bool o2::cad::surface::Curve2D::hasCanonicalEndpoints = false

Definition at line 1003 of file BoundedSurface.h.

◆ kind

CurveKind o2::cad::surface::Curve2D::kind = CurveKind::Line

Definition at line 982 of file BoundedSurface.h.

◆ knots

std::vector<double> o2::cad::surface::Curve2D::knots

Definition at line 994 of file BoundedSurface.h.

◆ lineEnd

Vec2 o2::cad::surface::Curve2D::lineEnd

line: end point (unused for arcs)

Definition at line 984 of file BoundedSurface.h.

◆ lineStart

Vec2 o2::cad::surface::Curve2D::lineStart

line: start point (unused for arcs)

Definition at line 983 of file BoundedSurface.h.

◆ poles

std::vector<Vec2> o2::cad::surface::Curve2D::poles

Definition at line 992 of file BoundedSurface.h.

◆ radius

double o2::cad::surface::Curve2D::radius = 0.

arc: circle radius

Definition at line 986 of file BoundedSurface.h.

◆ startAngle

double o2::cad::surface::Curve2D::startAngle = 0.

arc: start angle [rad]

Definition at line 987 of file BoundedSurface.h.

◆ weights

std::vector<double> o2::cad::surface::Curve2D::weights

Definition at line 993 of file BoundedSurface.h.


The documentation for this struct was generated from the following file: