Curve2D — Analytic Types
These members expose the type-specific properties of the five analytic 2D curve kinds (circle, ellipse, hyperbola, parabola, line) plus an offset-curve accessor, and provide B-spline/Bézier query and mutation methods; they are meaningful only when the underlying Curve2D wraps an OCCT object of the matching kind — accessing them on a mismatched type returns zero/nil/false silently. See the main Curve2D page for construction, evaluation, and general operations.
Topics
- BSpline Queries · Geom2d_Circle Properties · Geom2d_Ellipse Properties · Geom2d_Hyperbola Properties · Geom2d_Parabola Properties · Geom2d_Line Properties · Geom2d_OffsetCurve Properties · Geom2d_BSplineCurve Deep Methods · Bezier 2D Completions
BSpline Queries
poleCount
The number of control points (poles), or nil if the curve is not a BSpline or Bézier.
public var poleCount: Int? { get }
- Returns: Pole count, or
nilfor non-spline curve kinds. - OCCT:
Geom2d_BSplineCurve::NbPoles/Geom2d_BezierCurve::NbPoles. - Example:
if let c = Curve2D.bspline(points: [.zero, SIMD2(1, 0), SIMD2(1, 1)]) { if let n = c.poleCount { /* n == 3 */ } }
poles
The control points (poles) as an array, or nil if the curve is not a BSpline or Bézier.
public var poles: [SIMD2<Double>]? { get }
- Returns: Array of 2D pole coordinates in OCCT 1-based order (index 0 = pole 1), or
nil. - OCCT:
Geom2d_BSplineCurve::Pole(i)/Geom2d_BezierCurve::Pole(i). - Example:
if let pts = curve.poles { for p in pts { print(p) } }
degree
The curve degree, or nil if the curve is not a BSpline or Bézier.
public var degree: Int? { get }
- Returns: Polynomial degree (≥ 1), or
nilfor non-spline kinds. - OCCT:
Geom2d_BSplineCurve::Degree/Geom2d_BezierCurve::Degree. - Example:
if let deg = curve.degree { /* typically 3 for cubic */ }
Geom2d_Circle Properties (v0.108.0)
circleProperties
Access 2D circle-specific properties. Meaningful only when the underlying curve is a Geom2d_Circle.
public var circleProperties: CircleProperties { get }
- Returns: A
CirclePropertiesaccessor backed by the same internal handle. Members return zero/false for non-circle curves. - OCCT:
Geom2d_Circle— accessed viaHandle(Geom2d_Circle)::DownCast. - Example:
if let c = Curve2D.circle(center: .zero, radius: 5) { let props = c.circleProperties }
CircleProperties.radius
The radius of the 2D circle.
public var radius: Double { get }
- Returns: Radius in model units, or
0if the curve is not a circle. - OCCT:
Geom2d_Circle::Radius. - Example:
if let c = Curve2D.circle(center: .zero, radius: 5) { let r = c.circleProperties.radius // 5.0 }
CircleProperties.setRadius(_:)
Mutates the circle’s radius in place.
@discardableResult
public func setRadius(_ r: Double) -> Bool
- Parameters:
r— new radius (must be > 0). - Returns:
trueon success,falseif the curve is not a circle orris invalid. - OCCT:
Geom2d_Circle::SetRadius. - Example:
if let c = Curve2D.circle(center: .zero, radius: 5) { c.circleProperties.setRadius(8) }
CircleProperties.eccentricity
The eccentricity of the circle (always 0.0).
public var eccentricity: Double { get }
- Returns:
0.0for a valid circle, or0if the curve is not a circle. - OCCT:
Geom2d_Circle::Eccentricity. - Example:
let e = c.circleProperties.eccentricity // 0.0
CircleProperties.center
The centre point of the circle.
public var center: SIMD2<Double> { get }
- Returns: Centre in model space, or
.zeroif the curve is not a circle. - OCCT:
Geom2d_Circle::Circ2d().Location(). - Example:
if let c = Curve2D.circle(center: SIMD2(1, 2), radius: 5) { let ctr = c.circleProperties.center // SIMD2(1, 2) }
CircleProperties.xAxis
The X axis of the circle’s local coordinate system (position + direction).
public var xAxis: (position: SIMD2<Double>, direction: SIMD2<Double>) { get }
The position is a point on the axis; the direction is the unit X axis direction.
- Returns: Tuple
(position, direction). Returns(.zero, .zero)if the curve is not a circle. - OCCT:
Geom2d_Circle::XAxis→gp_Ax2d::Location+gp_Ax2d::Direction. - Example:
if let c = Curve2D.circle(center: .zero, radius: 5) { let ax = c.circleProperties.xAxis // ax.direction ≈ SIMD2(1, 0) }
Geom2d_Ellipse Properties (v0.108.0)
ellipseProperties
Access 2D ellipse-specific properties. Meaningful only when the underlying curve is a Geom2d_Ellipse.
public var ellipseProperties: EllipseProperties { get }
- Returns: An
EllipsePropertiesaccessor backed by the same internal handle. - OCCT:
Geom2d_Ellipse— accessed viaHandle(Geom2d_Ellipse)::DownCast. - Example:
if let c = Curve2D.ellipse(majorRadius: 5, minorRadius: 3) { let props = c.ellipseProperties }
EllipseProperties.majorRadius
The major (semi-major) radius of the ellipse.
public var majorRadius: Double { get }
- Returns: Major radius in model units, or
0if the curve is not an ellipse. - OCCT:
Geom2d_Ellipse::MajorRadius. - Example:
let a = c.ellipseProperties.majorRadius
EllipseProperties.minorRadius
The minor (semi-minor) radius of the ellipse.
public var minorRadius: Double { get }
- Returns: Minor radius in model units, or
0if the curve is not an ellipse. - OCCT:
Geom2d_Ellipse::MinorRadius. - Example:
let b = c.ellipseProperties.minorRadius
EllipseProperties.setMajorRadius(_:)
Mutates the ellipse’s major radius in place.
@discardableResult
public func setMajorRadius(_ r: Double) -> Bool
- Parameters:
r— new major radius (must be ≥ minor radius per OCCT). - Returns:
trueon success,falseif the curve is not an ellipse or the value is invalid. - OCCT:
Geom2d_Ellipse::SetMajorRadius. - Example:
c.ellipseProperties.setMajorRadius(10)
EllipseProperties.setMinorRadius(_:)
Mutates the ellipse’s minor radius in place.
@discardableResult
public func setMinorRadius(_ r: Double) -> Bool
- Parameters:
r— new minor radius (must be ≤ major radius per OCCT). - Returns:
trueon success,falseif the curve is not an ellipse or the value is invalid. - OCCT:
Geom2d_Ellipse::SetMinorRadius. - Example:
c.ellipseProperties.setMinorRadius(2)
EllipseProperties.eccentricity
The eccentricity of the ellipse (√(1 − (b/a)²)).
public var eccentricity: Double { get }
- Returns: Eccentricity in [0, 1), or
0if the curve is not an ellipse. - OCCT:
Geom2d_Ellipse::Eccentricity. - Example:
let e = c.ellipseProperties.eccentricity
EllipseProperties.focal
The focal distance of the ellipse (distance between the two foci).
public var focal: Double { get }
- Returns: Distance between foci (
2ae), or0if the curve is not an ellipse. - OCCT:
Geom2d_Ellipse::Focal. - Example:
let f = c.ellipseProperties.focal
EllipseProperties.focus1
The first focus of the ellipse.
public var focus1: SIMD2<Double> { get }
- Returns: First focus point in model space, or
.zeroif the curve is not an ellipse. - OCCT:
Geom2d_Ellipse::Focus1. - Example:
let f1 = c.ellipseProperties.focus1
Geom2d_Hyperbola Properties (v0.108.0)
hyperbolaProperties
Access 2D hyperbola-specific properties. Meaningful only when the underlying curve is a Geom2d_Hyperbola.
public var hyperbolaProperties: HyperbolaProperties { get }
- Returns: A
HyperbolaPropertiesaccessor backed by the same internal handle. - OCCT:
Geom2d_Hyperbola— accessed viaHandle(Geom2d_Hyperbola)::DownCast. - Example:
if let c = Curve2D.hyperbola(majorRadius: 4, minorRadius: 3) { let props = c.hyperbolaProperties }
HyperbolaProperties.majorRadius
The major radius of the hyperbola (real semi-axis).
public var majorRadius: Double { get }
- Returns: Major radius, or
0if the curve is not a hyperbola. - OCCT:
Geom2d_Hyperbola::MajorRadius. - Example:
let a = c.hyperbolaProperties.majorRadius
HyperbolaProperties.minorRadius
The minor radius of the hyperbola (imaginary semi-axis).
public var minorRadius: Double { get }
- Returns: Minor radius, or
0if the curve is not a hyperbola. - OCCT:
Geom2d_Hyperbola::MinorRadius. - Example:
let b = c.hyperbolaProperties.minorRadius
HyperbolaProperties.eccentricity
The eccentricity of the hyperbola (√(1 + (b/a)²), always > 1).
public var eccentricity: Double { get }
- Returns: Eccentricity (> 1 for a valid hyperbola), or
0if not a hyperbola. - OCCT:
Geom2d_Hyperbola::Eccentricity. - Example:
let e = c.hyperbolaProperties.eccentricity // > 1.0
HyperbolaProperties.focal
The focal distance of the hyperbola (distance between the two foci).
public var focal: Double { get }
- Returns: Distance between foci, or
0if not a hyperbola. - OCCT:
Geom2d_Hyperbola::Focal. - Example:
let f = c.hyperbolaProperties.focal
HyperbolaProperties.focus1
The first focus of the hyperbola.
public var focus1: SIMD2<Double> { get }
- Returns: First focus point, or
.zeroif not a hyperbola. - OCCT:
Geom2d_Hyperbola::Focus1. - Example:
let f1 = c.hyperbolaProperties.focus1
Geom2d_Parabola Properties (v0.108.0)
parabolaProperties
Access 2D parabola-specific properties. Meaningful only when the underlying curve is a Geom2d_Parabola.
public var parabolaProperties: ParabolaProperties { get }
- Returns: A
ParabolaPropertiesaccessor backed by the same internal handle. - OCCT:
Geom2d_Parabola— accessed viaHandle(Geom2d_Parabola)::DownCast. - Example:
if let c = Curve2D.parabola(focal: 2) { let props = c.parabolaProperties }
ParabolaProperties.focal
The focal distance of the parabola (distance from vertex to focus).
public var focal: Double { get }
- Returns: Focal distance, or
0if the curve is not a parabola. - OCCT:
Geom2d_Parabola::Focal. - Example:
let f = c.parabolaProperties.focal
ParabolaProperties.setFocal(_:)
Mutates the parabola’s focal distance in place.
@discardableResult
public func setFocal(_ f: Double) -> Bool
- Parameters:
f— new focal distance (must be > 0). - Returns:
trueon success,falseif the curve is not a parabola orfis invalid. - OCCT:
Geom2d_Parabola::SetFocal. - Example:
c.parabolaProperties.setFocal(3)
ParabolaProperties.focus
The focus point of the parabola.
public var focus: SIMD2<Double> { get }
- Returns: Focus point in model space, or
.zeroif not a parabola. - OCCT:
Geom2d_Parabola::Focus. - Example:
let fp = c.parabolaProperties.focus
ParabolaProperties.eccentricity
The eccentricity of the parabola (always 1.0).
public var eccentricity: Double { get }
- Returns:
1.0for a valid parabola, or0if not a parabola. - OCCT:
Geom2d_Parabola::Eccentricity. - Example:
let e = c.parabolaProperties.eccentricity // 1.0
ParabolaProperties.parameter
The parameter of the parabola (equal to 2 * focal).
public var parameter: Double { get }
- Returns:
2 * focal, or0if not a parabola. - OCCT:
Geom2d_Parabola::Parameter. - Example:
let p = c.parabolaProperties.parameter // == 2 * focal
Geom2d_Line Properties (v0.108.0)
lineProperties
Access 2D line-specific properties. Meaningful only when the underlying curve is a Geom2d_Line.
public var lineProperties: LineProperties { get }
- Returns: A
LinePropertiesaccessor backed by the same internal handle. - OCCT:
Geom2d_Line— accessed viaHandle(Geom2d_Line)::DownCast. - Example:
if let c = Curve2D.line(from: .zero, to: SIMD2(1, 0)) { let props = c.lineProperties }
LineProperties.direction
The unit direction of the 2D line.
public var direction: SIMD2<Double> { get }
- Returns: Unit direction vector, or
.zeroif the curve is not a line. - OCCT:
Geom2d_Line::Direction(viagp_Lin2d::Direction). - Example:
let d = c.lineProperties.direction // e.g. SIMD2(1, 0)
LineProperties.location
The origin (location) of the 2D line.
public var location: SIMD2<Double> { get }
- Returns: A point on the line through which the parametric origin passes, or
.zeroif not a line. - OCCT:
Geom2d_Line::Location(viagp_Lin2d::Location). - Example:
let loc = c.lineProperties.location
LineProperties.setDirection(_:)
Mutates the line’s direction in place.
@discardableResult
public func setDirection(_ d: SIMD2<Double>) -> Bool
- Parameters:
d— new direction (need not be unit; OCCT normalises it). - Returns:
trueon success,falseif the curve is not a line. - OCCT:
Geom2d_Line::SetDirection. - Example:
c.lineProperties.setDirection(SIMD2(0, 1))
LineProperties.setLocation(_:)
Mutates the line’s origin point in place.
@discardableResult
public func setLocation(_ p: SIMD2<Double>) -> Bool
- Parameters:
p— new location point. - Returns:
trueon success,falseif the curve is not a line. - OCCT:
Geom2d_Line::SetLocation. - Example:
c.lineProperties.setLocation(SIMD2(1, 2))
LineProperties.distance(to:)
The perpendicular distance from the line to a 2D point.
public func distance(to point: SIMD2<Double>) -> Double
- Parameters:
point— the query point in model space. - Returns: Perpendicular distance;
0if the curve is not a line. - OCCT:
Geom2d_Line::Distance(viagp_Lin2d::Distance). - Example:
let d = c.lineProperties.distance(to: SIMD2(0, 3))
LineProperties.lin2d
The gp_Lin2d representation of the line (location + direction).
public var lin2d: (location: SIMD2<Double>, direction: SIMD2<Double>) { get }
Retrieves both the origin point and direction in a single call.
- Returns: Tuple
(location, direction). Returns(.zero, .zero)if not a line. - OCCT:
Geom2d_Line::Lin2d→gp_Lin2d::Location+gp_Lin2d::Direction. - Example:
let lin = c.lineProperties.lin2d // lin.location, lin.direction
Geom2d_OffsetCurve Properties (v0.108.0)
offsetProperties
Access 2D offset-curve-specific properties. Meaningful only when the underlying curve is a Geom2d_OffsetCurve.
public var offsetProperties: OffsetProperties { get }
- Returns: An
OffsetPropertiesaccessor backed by the same internal handle. - OCCT:
Geom2d_OffsetCurve— accessed viaHandle(Geom2d_OffsetCurve)::DownCast. - Example:
if let base = Curve2D.circle(center: .zero, radius: 5), let oc = base.offset(by: 1) { let props = oc.offsetProperties }
OffsetProperties.offset
The signed offset value.
public var offset: Double { get }
Positive values offset to the left of the curve direction; negative to the right.
- Returns: Offset distance, or
0if the curve is not an offset curve. - OCCT:
Geom2d_OffsetCurve::Offset. - Example:
let v = oc.offsetProperties.offset // 1.0
OffsetProperties.setOffset(_:)
Mutates the offset value in place.
@discardableResult
public func setOffset(_ v: Double) -> Bool
- Parameters:
v— new offset distance. - Returns:
trueon success,falseif the curve is not an offset curve. - OCCT:
Geom2d_OffsetCurve::SetOffsetValue. - Example:
oc.offsetProperties.setOffset(2.0)
OffsetProperties.basisCurve
The basis curve from which this offset curve was derived.
public var basisCurve: Curve2D? { get }
- Returns: The underlying
Curve2D, ornilif the curve is not an offset curve or the basis handle is null. - OCCT:
Geom2d_OffsetCurve::BasisCurve. - Example:
if let basis = oc.offsetProperties.basisCurve { let r = basis.circleProperties.radius }
Geom2d_BSplineCurve Deep Method Completion (v0.125.0)
bsplineLocalD0(u:fromK1:toK2:)
Evaluates the curve position within a specific knot span.
public func bsplineLocalD0(u: Double, fromK1: Int, toK2: Int) -> SIMD2<Double>
- Parameters:
u— parameter value;fromK1,toK2— knot span indices (1-based, obtained frombsplineLocateU). - Returns: Point on the curve at
uwithin the span. Returns.zeroif not a BSpline. - OCCT:
Geom2d_BSplineCurve::LocalD0. - Example:
let (k1, k2) = curve.bsplineLocateU(u: 0.5, paramTol: 1e-7) let pt = curve.bsplineLocalD0(u: 0.5, fromK1: k1, toK2: k2)
bsplineLocalD1(u:fromK1:toK2:)
Evaluates position and first derivative within a knot span.
public func bsplineLocalD1(u: Double, fromK1: Int, toK2: Int)
-> (point: SIMD2<Double>, v1: SIMD2<Double>)
- Parameters:
u— parameter;fromK1,toK2— knot span indices. - Returns: Tuple
(point, v1)wherev1is the first derivative vector. - OCCT:
Geom2d_BSplineCurve::LocalD1. - Example:
let (k1, k2) = curve.bsplineLocateU(u: 0.5, paramTol: 1e-7) let r = curve.bsplineLocalD1(u: 0.5, fromK1: k1, toK2: k2) // r.point, r.v1
bsplineLocalD2(u:fromK1:toK2:)
Evaluates position and first two derivatives within a knot span.
public func bsplineLocalD2(u: Double, fromK1: Int, toK2: Int)
-> (point: SIMD2<Double>, v1: SIMD2<Double>, v2: SIMD2<Double>)
- Parameters:
u— parameter;fromK1,toK2— knot span indices. - Returns: Tuple
(point, v1, v2). - OCCT:
Geom2d_BSplineCurve::LocalD2. - Example:
let r = curve.bsplineLocalD2(u: 0.5, fromK1: k1, toK2: k2)
bsplineLocalD3(u:fromK1:toK2:)
Evaluates position and first three derivatives within a knot span.
public func bsplineLocalD3(u: Double, fromK1: Int, toK2: Int)
-> (point: SIMD2<Double>, v1: SIMD2<Double>, v2: SIMD2<Double>, v3: SIMD2<Double>)
- Parameters:
u— parameter;fromK1,toK2— knot span indices. - Returns: Tuple
(point, v1, v2, v3). - OCCT:
Geom2d_BSplineCurve::LocalD3. - Example:
let r = curve.bsplineLocalD3(u: 0.5, fromK1: k1, toK2: k2)
bsplineLocalDN(u:fromK1:toK2:n:)
Evaluates the N-th derivative within a knot span.
public func bsplineLocalDN(u: Double, fromK1: Int, toK2: Int, n: Int) -> SIMD2<Double>
- Parameters:
u— parameter;fromK1,toK2— span indices;n— derivative order. - Returns: N-th derivative vector at
uwithin the span. - OCCT:
Geom2d_BSplineCurve::LocalDN. - Example:
let d2 = curve.bsplineLocalDN(u: 0.5, fromK1: k1, toK2: k2, n: 2)
bsplineLocalValue(u:fromK1:toK2:)
Evaluates only the curve value (no derivatives) within a knot span.
public func bsplineLocalValue(u: Double, fromK1: Int, toK2: Int) -> SIMD2<Double>
- Parameters:
u— parameter;fromK1,toK2— span indices. - Returns: Point on the curve.
- OCCT:
Geom2d_BSplineCurve::LocalValue. - Example:
let pt = curve.bsplineLocalValue(u: 0.5, fromK1: k1, toK2: k2)
bsplineLocateU(u:paramTol:)
Locates the knot span indices enclosing a parameter value.
public func bsplineLocateU(u: Double, paramTol: Double) -> (i1: Int, i2: Int)
- Parameters:
u— parameter to locate;paramTol— tolerance for coincidence with a knot. - Returns: Tuple
(i1, i2)of 1-based knot indices bracketingu. Use asfromK1/toK2in local evaluation methods. - OCCT:
Geom2d_BSplineCurve::LocateU. - Example:
let (k1, k2) = curve.bsplineLocateU(u: 0.5, paramTol: 1e-7)
bsplineFirstUKnotIndex
The index of the first knot (lower bound of the valid span range).
public var bsplineFirstUKnotIndex: Int { get }
- Returns: 1-based index of the first knot;
0if not a BSpline. - OCCT:
Geom2d_BSplineCurve::FirstUKnotIndex. - Example:
let lo = curve.bsplineFirstUKnotIndex
bsplineLastUKnotIndex
The index of the last knot (upper bound of the valid span range).
public var bsplineLastUKnotIndex: Int { get }
- Returns: 1-based index of the last knot;
0if not a BSpline. - OCCT:
Geom2d_BSplineCurve::LastUKnotIndex. - Example:
let hi = curve.bsplineLastUKnotIndex
bsplineKnot(index:)
Returns the knot value at a 1-based index.
public func bsplineKnot(index: Int) -> Double
- Parameters:
index— 1-based knot index (valid range:bsplineFirstUKnotIndex ... bsplineLastUKnotIndex). - Returns: Knot parameter value;
0if not a BSpline or index is out of range. - OCCT:
Geom2d_BSplineCurve::Knot. - Example:
let k = curve.bsplineKnot(index: 2)
bsplineKnotDistribution
The knot distribution type of the BSpline.
public var bsplineKnotDistribution: Int { get }
- Returns: Integer code:
0= NonUniform,1= Uniform,2= QuasiUniform,3= PiecewiseBezier;0also if not a BSpline. - OCCT:
Geom2d_BSplineCurve::KnotDistribution. - Example:
let dist = curve.bsplineKnotDistribution
bsplineMultiplicity(index:)
The knot multiplicity at a 1-based index.
public func bsplineMultiplicity(index: Int) -> Int
- Parameters:
index— 1-based knot index. - Returns: Multiplicity at the knot;
0if not a BSpline or index is out of range. - OCCT:
Geom2d_BSplineCurve::Multiplicity. - Example:
let m = curve.bsplineMultiplicity(index: 1)
bsplineMultiplicities
All knot multiplicities as an array.
public var bsplineMultiplicities: [Int] { get }
- Returns: Array of multiplicity values in knot order; empty if not a BSpline.
- OCCT:
Geom2d_BSplineCurve::Multiplicities(via repeatedMultiplicity). - Example:
let mults = curve.bsplineMultiplicities
bsplineStartPoint
The start point of the BSpline (at first parameter).
public var bsplineStartPoint: SIMD2<Double> { get }
- Returns: Start point;
.zeroif not a BSpline. - OCCT:
Geom2d_BSplineCurve::StartPoint. - Example:
let s = curve.bsplineStartPoint
bsplineEndPoint
The end point of the BSpline (at last parameter).
public var bsplineEndPoint: SIMD2<Double> { get }
- Returns: End point;
.zeroif not a BSpline. - OCCT:
Geom2d_BSplineCurve::EndPoint. - Example:
let e = curve.bsplineEndPoint
bsplinePoles
All control points (poles) of the BSpline.
public var bsplinePoles: [SIMD2<Double>] { get }
Equivalent to iterating Pole(i) for i in 1…NbPoles. Prefer this over poles when you know the curve is a BSpline (avoids Bézier fallback).
- Returns: Array of poles in order; empty if not a BSpline.
- OCCT:
Geom2d_BSplineCurve::Pole(i). - Example:
for p in curve.bsplinePoles { print(p) }
bsplineIsClosed
Whether the BSpline is closed (start and end poles coincide within tolerance).
public var bsplineIsClosed: Bool { get }
- Returns:
trueif closed;falseif open or not a BSpline. - OCCT:
Geom2d_BSplineCurve::IsClosed. - Example:
if curve.bsplineIsClosed { /* closed loop */ }
bsplineIsPeriodic
Whether the BSpline is periodic.
public var bsplineIsPeriodic: Bool { get }
- Returns:
trueif periodic;falseotherwise. - OCCT:
Geom2d_BSplineCurve::IsPeriodic. - Example:
if curve.bsplineIsPeriodic { /* periodic */ }
bsplineContinuity
The global geometric continuity of the BSpline.
public var bsplineContinuity: Int { get }
- Returns: Integer code:
0= C0,1= C1,2= C2,3= C3,4= CN;0if not a BSpline. - OCCT:
Geom2d_BSplineCurve::Continuity. - Example:
let cont = curve.bsplineContinuity // typically 2 (C2) for cubic B-splines
bsplineIsCN(_:)
Tests whether the BSpline is at least Cn continuous.
public func bsplineIsCN(_ n: Int) -> Bool
- Parameters:
n— continuity order to test. - Returns:
trueif the curve is at least Cn;falseotherwise or if not a BSpline. - OCCT:
Geom2d_BSplineCurve::IsCN. - Example:
if curve.bsplineIsCN(2) { /* C2 continuous */ }
Bezier 2D Completions (v0.126.0)
bezierInsertPoleAfter(_:point:)
Inserts a new pole after a given 1-based index in a 2D Bézier curve.
@discardableResult
public func bezierInsertPoleAfter(_ index: Int, point: SIMD2<Double>) -> Bool
- Parameters:
index— 1-based index after which to insert;point— new pole coordinates. - Returns:
trueon success,falseif not a Bézier orindexis out of range. - OCCT:
Geom2d_BezierCurve::InsertPoleAfter. - Example:
curve.bezierInsertPoleAfter(1, point: SIMD2(0.5, 0.5))
bezierRemovePole(_:)
Removes the pole at a given 1-based index from a 2D Bézier curve.
@discardableResult
public func bezierRemovePole(_ index: Int) -> Bool
Removing a pole lowers the degree by one. A Bézier must have at least 2 poles.
- Parameters:
index— 1-based pole index to remove. - Returns:
trueon success,falseif not a Bézier or the operation would violate constraints. - OCCT:
Geom2d_BezierCurve::RemovePole. - Example:
curve.bezierRemovePole(2)
bezierSegment(u1:u2:)
Restricts a 2D Bézier curve to the parameter interval [u1, u2] in place.
@discardableResult
public func bezierSegment(u1: Double, u2: Double) -> Bool
The curve is reparametrized so the new domain is [0, 1].
- Parameters:
u1,u2— start and end parameters within the current domain[0, 1]. - Returns:
trueon success,falseif not a Bézier. - OCCT:
Geom2d_BezierCurve::Segment. - Example:
curve.bezierSegment(u1: 0.25, u2: 0.75)
bezierIncreaseDegree(_:)
Raises the degree of a 2D Bézier curve (adds poles to preserve shape).
@discardableResult
public func bezierIncreaseDegree(_ degree: Int) -> Bool
Degree elevation is exact — the curve shape does not change.
- Parameters:
degree— new degree (must be greater than the current degree). - Returns:
trueon success,falseif not a Bézier or the requested degree is not higher. - OCCT:
Geom2d_BezierCurve::Increase. - Example:
curve.bezierIncreaseDegree(4)
bezierStartPoint
The start point of the Bézier curve (first pole).
public var bezierStartPoint: SIMD2<Double> { get }
- Returns: Start point;
.zeroif not a Bézier. - OCCT:
Geom2d_BezierCurve::StartPoint. - Example:
let s = curve.bezierStartPoint
bezierEndPoint
The end point of the Bézier curve (last pole).
public var bezierEndPoint: SIMD2<Double> { get }
- Returns: End point;
.zeroif not a Bézier. - OCCT:
Geom2d_BezierCurve::EndPoint. - Example:
let e = curve.bezierEndPoint
bezierPoles
All control points of the 2D Bézier curve.
public var bezierPoles: [SIMD2<Double>] { get }
- Returns: Array of poles in order (index 0 = pole 1); empty if not a Bézier.
- OCCT:
Geom2d_BezierCurve::Pole(i). - Example:
for p in curve.bezierPoles { print(p) }
bezierReverse()
Reverses the parametric direction of a 2D Bézier curve in place.
@discardableResult
public func bezierReverse() -> Bool
Poles are reordered so the new start pole is the old end pole.
- Returns:
trueon success,falseif not a Bézier. - OCCT:
Geom2d_BezierCurve::Reverse. - Example:
curve.bezierReverse()