Document. Math, Bounds, OSD & Conversions
This page covers the math solvers, bounding-box types, quaternion/timer utilities, point classification, curve/surface conversion helpers, and OSD utilities found in Document.swift. For the core document lifecycle, shape tools, and XCAF I/O see the main Document page.
Topics
- gp_Quaternion · OSD_Timer · Bnd_OBB · Bnd_Range · BRepClass3d Point Classification · TDataXtd_Constraint · OSD_MemInfo · ShapeFix_EdgeProjAux · Geom2dAPI_Interpolate · Geom2dAPI_PointsToBSpline · TDataXtd_PatternStd · BRepAlgo_FaceRestrictor · MathDimension · math_Matrix · math_Gauss · math_SVD · math_DirectPolynomialRoots · math_Jacobi · Convert_CircleToBSplineCurve · Convert_SphereToBSplineSurface · Convert Conic Curves to BSpline · Convert Elementary Surfaces to BSpline · math_Householder · math_Crout · ShapeFix_IntersectionTool · XCAFDoc_AssemblyItemRef · BRepAlgo_Image · OSD_Path · BRepClass_FClassifier · Bnd_BoundSortBox · TNaming_Naming · Precision Constants · IntAna Analytic Intersections · OSD_Chronometer · OSD_Process · Draft_Modification · Convert_CompBezierCurvesToBSplineCurve · Geom_OffsetSurface Extensions
gp_Quaternion
Wraps gp_Quaternion, OCCT’s unit-quaternion for representing 3D rotations. Obtain one via init(x:y:z:w:), fromAxisAngle, or fromVectors.
Quaternion.init(x:y:z:w:)
Create a quaternion from its four components.
public convenience init(x: Double = 0, y: Double = 0, z: Double = 0, w: Double = 1)
- Parameters:
x,y,z, vector part;w, scalar part. Defaults to the identity quaternion (0, 0, 0, 1). - OCCT:
gp_Quaternion(x, y, z, w)(viaOCCTQuaternionCreate). - Example:
let identity = Quaternion() let q = Quaternion(x: 0, y: 0, z: 0.7071, w: 0.7071)
Quaternion.fromAxisAngle(axis:angle:)
Create a quaternion from an axis-angle rotation.
public static func fromAxisAngle(axis: SIMD3<Double>, angle: Double) -> Quaternion
- Parameters:
axis, rotation axis (need not be normalized);angle, rotation angle in radians. - OCCT:
gp_Quaternion::SetVectorAndAngle(viaOCCTQuaternionCreateFromAxisAngle). - Example:
let q = Quaternion.fromAxisAngle(axis: SIMD3(0, 0, 1), angle: .pi / 4)
Quaternion.fromVectors(from:to:)
Create a quaternion representing the shortest-arc rotation from one vector to another.
public static func fromVectors(from: SIMD3<Double>, to: SIMD3<Double>) -> Quaternion
- Parameters:
from, source direction;to, target direction. - OCCT:
gp_Quaternion::SetRotation(viaOCCTQuaternionCreateFromVectors). - Example:
let q = Quaternion.fromVectors(from: SIMD3(1, 0, 0), to: SIMD3(0, 1, 0))
components
The four quaternion components (x, y, z, w).
public var components: (x: Double, y: Double, z: Double, w: Double) { get }
- OCCT:
gp_Quaternion::X/Y/Z/W(viaOCCTQuaternionGetComponents). - Example:
let c = q.components print(c.w) // scalar part
setEulerAngles(order:alpha:beta:gamma:)
Set the quaternion from Euler angles.
public func setEulerAngles(order: Int32, alpha: Double, beta: Double, gamma: Double)
- Parameters:
order, Euler convention index (0 = Intrinsic_XYZ, seegp_EulerSequence);alpha,beta,gamma, angles in radians. - OCCT:
gp_Quaternion::SetEulerAngles(viaOCCTQuaternionSetEulerAngles). - Example:
q.setEulerAngles(order: 0, alpha: 0.1, beta: 0.2, gamma: 0.3)
getEulerAngles(order:)
Get the Euler angle decomposition of this quaternion.
public func getEulerAngles(order: Int32) -> (alpha: Double, beta: Double, gamma: Double)
- Parameters:
order, Euler convention index (same encoding assetEulerAngles). - Returns: Tuple of three angles in radians.
- OCCT:
gp_Quaternion::GetEulerAngles(viaOCCTQuaternionGetEulerAngles). - Example:
let (a, b, g) = q.getEulerAngles(order: 0)
matrix
The 3×3 rotation matrix represented by this quaternion, in row-major order (9 elements).
public var matrix: [Double] { get }
- Returns: A 9-element
[Double]wherematrix[row*3 + col]isM[row][col]. - OCCT:
gp_Quaternion::GetMatrix/ matrix conversion (viaOCCTQuaternionGetMatrix). - Example:
let m = q.matrix // m[0] m[1] m[2] // m[3] m[4] m[5] // m[6] m[7] m[8]
rotate(_:)
Rotate a 3D vector by this quaternion.
public func rotate(_ vector: SIMD3<Double>) -> SIMD3<Double>
- Parameters:
vector, the vector to rotate. - Returns: The rotated vector.
- OCCT:
gp_Quaternion::Multiplywithgp_Vec(viaOCCTQuaternionMultiplyVec). - Example:
let rotated = q.rotate(SIMD3(1, 0, 0))
multiplied(by:)
Hamilton product of two quaternions.
public func multiplied(by other: Quaternion) -> Quaternion
- Parameters:
other, the right-hand quaternion. - Returns: A new
Quaternionrepresenting the composed rotation. - OCCT:
gp_Quaternion::Multiplied(viaOCCTQuaternionMultiply). - Example:
let composed = q1.multiplied(by: q2)
axisAngle
Axis-angle representation of this quaternion.
public var axisAngle: (axis: SIMD3<Double>, angle: Double) { get }
- Returns: Tuple of the rotation axis and angle in radians.
- OCCT:
gp_Quaternion::GetVectorAndAngle(viaOCCTQuaternionGetVectorAndAngle). - Example:
let (axis, angle) = q.axisAngle
rotationAngle
The rotation angle encoded in this quaternion.
public var rotationAngle: Double { get }
- Returns: Angle in radians.
- OCCT:
gp_Quaternion::GetRotationAngle(viaOCCTQuaternionGetRotationAngle). - Example:
print(q.rotationAngle) // e.g. 0.7853...
normalize()
Normalize this quaternion to unit length in-place.
public func normalize()
- OCCT:
gp_Quaternion::Normalize(viaOCCTQuaternionNormalize). - Example:
q.normalize()
(Internal, not public API: Quaternion.handle is an unmarked let handle: OCCTQuaternionRef (Swift default access, i.e. internal) wrapping the underlying bridge object, released in deinit. See Memory Management.)
OSD_Timer
Wraps OSD_Timer, a high-resolution wall-clock timer suitable for profiling.
Timer.init()
Create a new timer (initially stopped, elapsed = 0).
public init()
- OCCT:
OSD_Timer()(viaOCCTTimerCreate). - Example:
let t = Timer()
start()
Start (or resume) the timer.
public func start()
- OCCT:
OSD_Timer::Start(viaOCCTTimerStart). - Example:
t.start()
stop()
Stop the timer, preserving elapsed time.
public func stop()
- OCCT:
OSD_Timer::Stop(viaOCCTTimerStop). - Example:
t.stop()
reset()
Reset elapsed time to zero.
public func reset()
- OCCT:
OSD_Timer::Reset(viaOCCTTimerReset). - Example:
t.reset()
elapsedTime
Elapsed wall-clock time in seconds.
public var elapsedTime: Double { get }
- OCCT:
OSD_Timer::ElapsedTime(viaOCCTTimerElapsedTime). - Example:
t.start() // ... work ... t.stop() print(t.elapsedTime)
Timer.wallClockTime
Current wall-clock time in seconds (static, absolute).
public static var wallClockTime: Double { get }
- OCCT:
OSD_Timer::GetWallClockTime(viaOCCTTimerGetWallClockTime). - Example:
let now = Timer.wallClockTime
(Internal, not public API: Timer.handle is an unmarked let handle: OCCTTimerRef (Swift default access, i.e. internal) wrapping the underlying bridge object, released in deinit. See Memory Management.)
Bnd_OBB
Wraps Bnd_OBB, an oriented bounding box in 3D space defined by center, local axes, and half-sizes.
OBB.init(center:xDir:yDir:zDir:hx:hy:hz:)
Create an OBB from explicit center, local axes, and half-extents.
public init(center: SIMD3<Double>, xDir: SIMD3<Double>, yDir: SIMD3<Double>, zDir: SIMD3<Double>,
hx: Double, hy: Double, hz: Double)
- Parameters:
center, center point;xDir/yDir/zDir, local orthonormal axes;hx/hy/hz, half-sizes along each axis. - OCCT:
Bnd_OBB(center, xDir, yDir, zDir, hx, hy, hz)(viaOCCTOBBCreate). - Example:
let obb = OBB(center: SIMD3(0, 0, 0), xDir: SIMD3(1, 0, 0), yDir: SIMD3(0, 1, 0), zDir: SIMD3(0, 0, 1), hx: 1, hy: 2, hz: 0.5)
OBB.fromShape(_:)
Compute the tightest OBB enclosing a shape.
public static func fromShape(_ shape: Shape) -> OBB?
- Parameters:
shape, the source shape. - Returns: The OBB, or
nilif the shape has no computable bounds. - OCCT:
BRepBndLib::AddOBB(viaOCCTOBBCreateFromShape). - Example:
if let obb = OBB.fromShape(myBox) { print(obb.halfSizes) }
isVoid
Whether the OBB is empty (unset).
public var isVoid: Bool { get }
- OCCT:
Bnd_OBB::IsVoid(viaOCCTOBBIsVoid).
center
Center of the OBB in world space.
public var center: SIMD3<Double> { get }
- OCCT:
Bnd_OBB::Center(viaOCCTOBBGetCenter).
halfSizes
Half-extents along the OBB’s local X, Y, Z axes.
public var halfSizes: SIMD3<Double> { get }
- OCCT:
Bnd_OBB::XHSize / YHSize / ZHSize(viaOCCTOBBGetHalfSizes). - Example:
let volume = obb.halfSizes.x * obb.halfSizes.y * obb.halfSizes.z * 8
isOut(point:)
Check if a point lies outside the OBB.
public func isOut(point: SIMD3<Double>) -> Bool
- Parameters:
point, the 3D point to test. - Returns:
trueif the point is strictly outside. - OCCT:
Bnd_OBB::IsOut(gp_Pnt)(viaOCCTOBBIsOutPoint). - Example:
if !obb.isOut(point: SIMD3(0, 0, 0)) { /* center is inside */ }
isOut(_:) (OBB overload)
Check if another OBB has no overlap with this one.
public func isOut(_ other: OBB) -> Bool
- Parameters:
other, OBB to test. - Returns:
trueif the two OBBs are disjoint. - OCCT:
Bnd_OBB::IsOut(Bnd_OBB)(viaOCCTOBBIsOutOBB).
enlarge(by:)
Expand all half-extents by a gap value.
public func enlarge(by gap: Double)
- Parameters:
gap, expansion amount on each side. - OCCT:
Bnd_OBB::Enlarge(viaOCCTOBBEnlarge).
squareExtent
Squared length of the OBB diagonal.
public var squareExtent: Double { get }
- OCCT:
Bnd_OBB::SquareExtent(viaOCCTOBBSquareExtent).
Bnd_Range
Wraps Bnd_Range, a 1D interval [min, max] that also carries a “void” (empty) state.
Range.init(min:max:)
Create a range with explicit bounds.
public init(min: Double, max: Double)
- OCCT:
Bnd_Range(min, max)(viaOCCTRangeCreate). - Example:
let r = Range(min: 0.0, max: 10.0)
Range.init() (void)
Create a void (empty) range.
public init()
- OCCT:
Bnd_Range()(viaOCCTRangeCreateVoid).
isVoid
Whether the range is empty.
public var isVoid: Bool { get }
- OCCT:
Bnd_Range::IsVoid(viaOCCTRangeIsVoid).
bounds
Lower and upper bounds of the range.
public var bounds: (first: Double, last: Double)? { get }
- Returns:
nilif the range is void. - OCCT:
Bnd_Range::GetBounds(viaOCCTRangeGetBounds). - Example:
if let b = r.bounds { print(b.first, b.last) }
delta
Length of the range (max − min).
public var delta: Double { get }
- OCCT:
Bnd_Range::Delta(viaOCCTRangeDelta).
contains(_:)
Test whether a value falls within the range.
public func contains(_ value: Double) -> Bool
- OCCT:
Bnd_Range::IsIntersected/ point test (viaOCCTRangeContains).
add(_:) (value)
Extend the range to include a scalar value.
public func add(_ value: Double)
- OCCT:
Bnd_Range::Add(Standard_Real)(viaOCCTRangeAddValue).
add(_:) (Range)
Extend the range to include another range.
public func add(_ other: Range)
- OCCT:
Bnd_Range::Add(Bnd_Range)(viaOCCTRangeAddRange).
common(_:)
Intersect this range with another (retain overlap only).
public func common(_ other: Range)
- OCCT:
Bnd_Range::Common(viaOCCTRangeCommon).
enlarge(by:)
Expand both boundaries outward by delta.
public func enlarge(by delta: Double)
- OCCT:
Bnd_Range::Enlarge(viaOCCTRangeEnlarge).
trimFrom(_:)
Raise the lower boundary to at least lower.
public func trimFrom(_ lower: Double)
- OCCT:
Bnd_Range::TrimFrom(viaOCCTRangeTrimFrom).
trimTo(_:)
Lower the upper boundary to at most upper.
public func trimTo(_ upper: Double)
- OCCT:
Bnd_Range::TrimTo(viaOCCTRangeTrimTo).
BRepClass3d Point Classification
Extension on Shape wrapping BRepClass3d_SolidClassifier.
Shape.PointState
Classification of a 3D point relative to a solid.
public enum PointState: Int32 {
case inside = 0
case outside = 1
case on = 2
case unknown = 3
}
| Case | Meaning |
|---|---|
inside | The point lies strictly inside the solid. |
outside | The point lies strictly outside the solid. |
on | The point lies on the solid’s boundary, within the classifier’s tolerance. |
unknown | BRepClass3d_SolidClassifier::Perform could not classify the point (e.g. a non-solid or otherwise degenerate shape); also the fallback returned when the underlying raw value doesn’t decode. |
(Per-case anchors below, for cross-reference; the table above has the actual meaning of each.)
Shape.PointState.unknown
classifyPoint(_:tolerance:)
Classify a 3D point relative to this solid shape.
public func classifyPoint(_ point: SIMD3<Double>, tolerance: Double = 1e-6) -> PointState
- Parameters:
point, 3D point;tolerance, classification tolerance. - Returns:
.inside,.outside,.on, or.unknown. - OCCT:
BRepClass3d_SolidClassifier::Perform(viaOCCTShapeClassifyPoint). - Example:
let box = Shape.box(width: 10, height: 10, depth: 10)! let state = box.classifyPoint(SIMD3(5, 5, 5)) // state == .inside
TDataXtd_Constraint
Extension on Document wrapping TDataXtd_Constraint, dimensional and geometric constraints stored as OCAF attributes.
Document.ConstraintType
Constraint kind enumeration matching TDataXtd_ConstraintEnum.
public enum ConstraintType: Int32 {
case radius = 0, diameter, minorRadius, majorRadius
case tangent, parallel, perpendicular, concentric
case coincident, distance, angle, equalRadius
case symmetry, midPoint, equalDistance, fix
case rigid, from
}
| Case | TDataXtd_ConstraintEnum | Meaning |
|---|---|---|
radius | TDataXtd_RADIUS | Circle/arc radius value |
diameter | TDataXtd_DIAMETER | Circle/arc diameter value |
minorRadius | TDataXtd_MINOR_RADIUS | Ellipse minor-axis radius value |
majorRadius | TDataXtd_MAJOR_RADIUS | Ellipse major-axis radius value |
tangent | TDataXtd_TANGENT | Two entities forced tangent |
parallel | TDataXtd_PARALLEL | Two lines/planes forced parallel |
perpendicular | TDataXtd_PERPENDICULAR | Two lines/planes forced perpendicular |
concentric | TDataXtd_CONCENTRIC | Two circular/curved entities forced to share a centre |
coincident | TDataXtd_COINCIDENT | Two point/curve entities forced to the same location |
distance | TDataXtd_DISTANCE | Linear distance value between two entities |
angle | TDataXtd_ANGLE | Angular value between two entities |
equalRadius | TDataXtd_EQUAL_RADIUS | Two circles/arcs forced to equal radius |
symmetry | TDataXtd_SYMMETRY | Two entities forced symmetric about a third |
midPoint | TDataXtd_MIDPOINT | A point forced to the midpoint of two others |
equalDistance | TDataXtd_EQUAL_DISTANCE | Two distances forced equal |
fix | TDataXtd_FIX | An entity’s position/orientation forced fixed |
rigid | TDataXtd_RIGID | An entity forced not to deform under the solver |
from | TDataXtd_FROM | A distance/angle constraint’s reference origin entity |
Eighteen of the 26 TDataXtd_ConstraintEnum cases are wrapped; TDataXtd_AXIS, TDataXtd_MATE, TDataXtd_ALIGN_FACES, TDataXtd_ALIGN_AXES, TDataXtd_AXES_ANGLE, TDataXtd_FACES_ANGLE, TDataXtd_ROUND, and TDataXtd_OFFSET have no Swift case yet. The upstream header carries no per-case documentation beyond the enumerator names themselves, so the meanings above are read directly off the OCCT constraint-solver vocabulary each name names.
Document.ConstraintType.symmetry
Two entities forced symmetric about a third.
setConstraint(labelId:)
Attach a TDataXtd_Constraint attribute to a label.
@discardableResult
public func setConstraint(labelId: Int64) -> Bool
- Parameters:
labelId, target label identifier. - Returns:
trueon success. - OCCT:
TDataXtd_Constraint::Set(viaOCCTDocumentSetConstraint). - Example:
doc.setConstraint(labelId: labelId)
constraintSetType(labelId:type:)
Set the constraint type on an existing constraint attribute.
@discardableResult
public func constraintSetType(labelId: Int64, type: ConstraintType) -> Bool
- OCCT:
TDataXtd_Constraint::SetType(viaOCCTDocumentConstraintSetType).
constraintGetType(labelId:)
Retrieve the constraint type.
public func constraintGetType(labelId: Int64) -> ConstraintType?
- Returns:
nilif no constraint attribute exists on the label. - OCCT:
TDataXtd_Constraint::GetType(viaOCCTDocumentConstraintGetType).
constraintNbGeometries(labelId:)
Number of geometry references attached to this constraint.
public func constraintNbGeometries(labelId: Int64) -> Int
- OCCT:
TDataXtd_Constraint::NbGeometries(viaOCCTDocumentConstraintNbGeometries).
constraintIsPlanar(labelId:)
Whether the constraint is a planar (2D) constraint.
public func constraintIsPlanar(labelId: Int64) -> Bool
- OCCT:
TDataXtd_Constraint::IsPlanar(viaOCCTDocumentConstraintIsPlanar).
constraintIsDimension(labelId:)
Whether the constraint carries a dimensional value.
public func constraintIsDimension(labelId: Int64) -> Bool
- OCCT:
TDataXtd_Constraint::IsDimension(viaOCCTDocumentConstraintIsDimension).
constraintSetVerified(labelId:verified:)
Set the verified flag on a constraint.
@discardableResult
public func constraintSetVerified(labelId: Int64, verified: Bool) -> Bool
- OCCT:
TDataXtd_Constraint::Verified(viaOCCTDocumentConstraintSetVerified).
constraintGetVerified(labelId:)
Get the verified flag of a constraint.
public func constraintGetVerified(labelId: Int64) -> Bool
- OCCT:
TDataXtd_Constraint::Verifiedaccessor (viaOCCTDocumentConstraintGetVerified).
constraintClearGeometries(labelId:)
Remove all geometry references from a constraint attribute.
@discardableResult
public func constraintClearGeometries(labelId: Int64) -> Bool
- OCCT:
TDataXtd_Constraintgeometry list clear (viaOCCTDocumentConstraintClearGeometries).
OSD_MemInfo
Namespace wrapping OSD_MemInfo, process memory statistics.
MemInfo.heapUsage
Heap allocated bytes for the current process.
public static var heapUsage: Int64 { get }
- OCCT:
OSD_MemInfo::Value(OSD_MemInfo::MemHeapUsage)(viaOCCTMemInfoHeapUsage).
MemInfo.workingSet
Working set (resident memory) in bytes.
public static var workingSet: Int64 { get }
- OCCT:
OSD_MemInfo::Value(OSD_MemInfo::MemWorkingSet)(viaOCCTMemInfoWorkingSet).
MemInfo.heapUsageMiB
Heap usage as a precise Double in mebibytes.
public static var heapUsageMiB: Double { get }
- OCCT:
OSD_MemInfo::ValuePreciseMiB(OSD_MemInfo::MemHeapUsage)(viaOCCTMemInfoHeapUsageMiB).
MemInfo.infoString
Full formatted memory report string from OCCT.
public static var infoString: String? { get }
- Returns: A multi-line string with all tracked counters, or
nilon error. - OCCT:
OSD_MemInfo::ToString(viaOCCTMemInfoString). - Example:
if let info = MemInfo.infoString { print(info) }
ShapeFix_EdgeProjAux
Extension on Shape wrapping ShapeFix_EdgeProjAux, projects edge endpoints back onto the 2D pcurve on a face.
edgeProjAux(faceIndex:edgeIndex:precision:)
Project edge endpoints onto a face’s 2D parameter space.
public func edgeProjAux(faceIndex: Int, edgeIndex: Int, precision: Double = 1e-6) -> (first: Double, last: Double)?
- Parameters:
faceIndex, 0-based face index;edgeIndex, 0-based edge index within that face;precision, projection precision. - Returns:
(firstParam, lastParam)on the pcurve, ornilif projection fails. - OCCT:
ShapeFix_EdgeProjAux::Compute(viaOCCTShapeFixEdgeProjAux). - Example:
if let (p1, p2) = shape.edgeProjAux(faceIndex: 0, edgeIndex: 0) { print("params:", p1, p2) }
Geom2dAPI_Interpolate
Extension on Curve2D wrapping Geom2dAPI_Interpolate, exact interpolation through 2D points.
Curve2D.interpolate2D(points:periodic:tolerance:)
Interpolate a 2D BSpline curve exactly through the given points.
public static func interpolate2D(points: [(Double, Double)], periodic: Bool = false, tolerance: Double = 1e-6) -> Curve2D?
- Parameters:
points, ordered (x, y) pairs to pass through;periodic, iftrue, produce a closed periodic curve;tolerance, interpolation tolerance. - Returns: The interpolated
Curve2D, ornilon failure. - OCCT:
Geom2dAPI_Interpolate::Perform(viaOCCTCurve2DInterpolate2D). - Example:
let pts = [(0.0, 0.0), (1.0, 1.0), (2.0, 0.0)] if let curve = Curve2D.interpolate2D(points: pts) { // curve passes exactly through all three points }
Geom2dAPI_PointsToBSpline
Extension on Curve2D wrapping Geom2dAPI_PointsToBSpline, least-squares approximation through 2D points.
Curve2D.approximate2D(points:)
Approximate a 2D BSpline curve through a set of points (least-squares fit).
public static func approximate2D(points: [(Double, Double)]) -> Curve2D?
- Parameters:
points, ordered (x, y) pairs to approximate. - Returns: The approximating
Curve2D, ornilon failure. - OCCT:
Geom2dAPI_PointsToBSpline::Curve(viaOCCTCurve2DApproximate2D). - Note: Unlike
interpolate2D, the curve does not pass exactly through all points; it minimises squared deviation. - Example:
let pts = [(0.0, 0.0), (0.5, 0.8), (1.0, 0.1), (1.5, 0.9), (2.0, 0.0)] if let approx = Curve2D.approximate2D(points: pts) { // smooth fit curve }
TDataXtd_PatternStd
Extension on Document wrapping TDataXtd_PatternStd, pattern replication attributes stored in the OCAF document tree.
Document.PatternSignature
Pattern type enumeration.
public enum PatternSignature: Int32 {
case linear = 1
case circular = 2
case rectangular = 3
case radialCircular = 4
case mirror = 5
}
TDataXtd_PatternStd shares one attribute shape (Axis1/Axis2, Value1/Value2, NbInstances1/NbInstances2, Mirror) across all five signatures; which fields are meaningful depends on this value.
| Case | Meaning |
|---|---|
linear | Instances translated along Axis1 by Value1, repeated NbInstances1 times (a second, independent direction via Axis2/Value2/NbInstances2 gives a 1D array along two directions rather than a grid). |
circular | Instances rotated about Axis1 by the angular increment Value1, repeated NbInstances1 times. |
rectangular | A 2D grid: Axis1/Value1/NbInstances1 and Axis2/Value2/NbInstances2 each define one grid direction, spacing, and instance count. |
radialCircular | Combined radial and circular pattern: Axis1/Value1/NbInstances1 step outward radially while Axis2/Value2/NbInstances2 rotate about an axis. |
mirror | A single mirrored copy reflected across the plane or axis referenced by Mirror. |
(Per-case anchors below, for cross-reference; the table above has the actual meaning of each.)
Document.PatternSignature.rectangular
setPattern(labelId:)
Attach a TDataXtd_PatternStd attribute to a label.
@discardableResult
public func setPattern(labelId: Int64) -> Bool
- OCCT:
TDataXtd_PatternStd::Set(viaOCCTDocumentSetPatternStd).
hasPattern(labelId:)
Check whether a label carries a pattern attribute.
public func hasPattern(labelId: Int64) -> Bool
- OCCT:
TDF_Label::FindAttribute(TDataXtd_Pattern::GetID())(viaOCCTDocumentHasPattern).TDataXtd_PatternStddeclares noFind, and the lookup is by the abstract base’s GUID.
patternSetSignature(labelId:signature:)
Set the pattern type.
@discardableResult
public func patternSetSignature(labelId: Int64, signature: PatternSignature) -> Bool
- OCCT:
TDataXtd_PatternStd::Signature(viaOCCTDocumentPatternSetSignature). There is noSetSignature; the setter is the one-argumentSignature(int)overload.
patternGetSignature(labelId:)
Retrieve the pattern type.
public func patternGetSignature(labelId: Int64) -> PatternSignature?
- Returns:
nilif no pattern attribute exists. - OCCT:
TDataXtd_PatternStd::Signature(viaOCCTDocumentPatternGetSignature).
patternNbTrsfs(labelId:)
Number of transforms (instances) defined by this pattern.
public func patternNbTrsfs(labelId: Int64) -> Int
- OCCT:
TDataXtd_PatternStd::NbTrsfs(viaOCCTDocumentPatternNbTrsfs).
BRepAlgo_FaceRestrictor
Extension on Shape wrapping BRepAlgo_FaceRestrictor, rebuilds a face bounded by its wires.
faceRestrictAlgo(faceIndex:)
Restrict a face to its wire boundaries and return the resulting face count.
public func faceRestrictAlgo(faceIndex: Int) -> Int
- Parameters:
faceIndex, 0-based index of the face to restrict. - Returns: Number of result faces produced by the restrictor (1 for a face with one outer wire, with or without holes), or -1 when
faceIndexnames no face or the restrictor does not finish. - OCCT:
BRepAlgo_FaceRestrictorInit/Add/Perform, thenMore/Nextcounted (viaOCCTShapeFaceRestrictAlgo). - Example:
let n = shape.faceRestrictAlgo(faceIndex: 0) print("result faces:", n)
MathDimension
(internal, not part of the public API): internal enum MathDimension in MathDimension.swift, the one problem-dimension validator every n/rows/cols argument in MathMatrix, math_Gauss, math_SVD and the rest of this page’s MathLibrary/MathSolver wrappers is checked against. Has no stored state: four static validators over one shared shape (“does this dimension agree with the array(s) it sizes”), factored out so eighteen previously hand-duplicated call sites can’t drift apart again (#640).
- Example:
- Example:
- Example:
Wraps math_Matrix, a dense general matrix with 1-based row and column indexing.
MathMatrix.init(rows:cols:initialValue:)
Create a matrix of given dimensions, all cells initialised to initialValue.
public init(rows: Int, cols: Int, initialValue: Double = 0.0)
- OCCT:
math_Matrix(rows, cols, initialValue)(viaOCCTMathMatrixCreate). - Example:
let m = MathMatrix(rows: 3, cols: 3)
rows, cols
Number of rows / columns.
public var rows: Int { get }
public var cols: Int { get }
- OCCT:
math_Matrix::RowNumber / ColNumber(viaOCCTMathMatrixRows / OCCTMathMatrixCols).
rows is MathMatrix.rows; the combined heading above only registers that one, so cols gets its own anchor here: it is the same kind of public accessor, just the column-count half of the pair.
(Internal, not public API: MathMatrix.handle is an unmarked let handle: OCCTMathMatrixRef (Swift default access, i.e. internal) wrapping the underlying bridge object, released in deinit. See Memory Management.)
MathMatrix.cols
isSquare
true when the matrix is square and has at least one row, which is the precondition determinant, invert() and transpose() all require.
public var isSquare: Bool { get }
- A 0x0 matrix, which
init(rows:cols:initialValue:)accepts, is not square by this definition even though its counts agree:math_Matrix::Determinant()reports a determinant of 1 for it (#2860). - Derived in Swift, from
rowsandcols; no bridge function of its own.
value(row:col:)
Read the element at (row, col), 1-based. nil when either index is out of range.
public func value(row: Int, col: Int) -> Double?
- Returns: the element, or
nilwhenrowis outside1...rows,colis outside1...cols, or either does not fit anInt32.nilrather than aDoublebecause every value in range is a legitimate entry and no number could mean “that cell does not exist”. - Unguarded before #2860, and nothing underneath tested the pair of indices:
NCollection_Array2::Valueflattens them to one position and bounds that against the total element count only. An index that left the buffer,(9, 9)on a 3x3, threw, and sinceNCollection_Array1::atis inline the throw was live in the bridge’s own translation unit and crossed into Swift-generated frames as an uncatchable SIGABRT (#345). An index that stayed inside it,(1, 4)on a 3x3, returned a different cell’s value: measured,1.0, the element at(2, 1). - OCCT:
math_Matrix::Value(viaOCCTMathMatrixGetValue). - Example:
let m = MathMatrix(rows: 3, cols: 3, initialValue: 2.0) let v = m.value(row: 1, col: 1) // 2.0 let none = m.value(row: 9, col: 9) // nil
setValue(row:col:value:)
Write the element at (row, col), 1-based. false, storing nothing, when either index is out of range.
@discardableResult
public func setValue(row: Int, col: Int, value: Double) -> Bool
- Returns:
truewhen stored;falseon the indicesvalue(row:col:)refuses, for the same reason (#2860). - OCCT:
math_Matrix::Value(viaOCCTMathMatrixSetValue).
determinant
Determinant of the matrix, or nil unless it isSquare.
public var determinant: Double? { get }
- Returns: the determinant, or
nilfor a non-square matrix and for a 0x0. nilrather than0.0, for the reasonMathGauss.determinant(matrix:n:)is already optional (#640):0.0is also the determinant of a genuinely singular square matrix, so it cannot carry a refusal.math_Matrix::Determinant()has no squareness check of any kind, not even a compiled-out one, so before #2860 a 3x2 returned -1 and a 100x1 returnednanwith the heap corrupted behind it.- OCCT:
math_Matrix::Determinant(viaOCCTMathMatrixDeterminant).
invert()
Invert the matrix in-place.
@discardableResult
public func invert() -> Bool
- Returns:
trueon success;falseif the matrix is singular, is not square, or is 0x0. - A 100x1 was a SIGBUS before #2860:
math_Matrix::Invert’s ownmath_NotSquare_Raise_ifsits inmath_Matrix.cxxand is compiled out of the pinned kernel, so the matrix reachedmath_Gauss, which writesa(i, j)forjup toRowNumber(). - OCCT:
math_Matrix::Invert(viaOCCTMathMatrixInvert).
multiply(by:)
Scale all elements by a scalar in-place.
public func multiply(by scalar: Double)
- OCCT:
math_Matrix::Multiply(scalar)(viaOCCTMathMatrixMultiplyScalar).
transpose()
Transpose the matrix in-place.
@discardableResult
public func transpose() -> Bool
- Returns:
truewhen transposed;false, changing nothing, unless the matrixisSquare. - A 3x2 was an uncatchable SIGABRT before #2860:
math_Matrix::Transpose’smath_NotSquare_Raise_ifis inline, so it is live in the bridge’s own translation unit and threw straight into Swift-generated frames (#345). - OCCT:
math_Matrix::Transpose(viaOCCTMathMatrixTranspose).
OSD_Environment
Namespace wrapping OSD_Environment, read, set, and remove process environment variables through OCCT’s platform-neutral OSD layer (rather than POSIX getenv/setenv directly). Useful for toggling OCCT’s own environment switches (e.g. CSF_* resource paths) from Swift.
Environment.get(_:)
Get the value of an environment variable.
public static func get(_ name: String) -> String?
- Parameters:
name, the variable name. - Returns: The value, or
nilif the variable is unset. - OCCT:
OSD_Environment(name).Value()(viaOCCTEnvironmentGet). - Example:
let paths = Environment.get("CSF_PluginDefaults")
Environment.set(_:value:)
Set (create or overwrite) an environment variable in the current process.
@discardableResult
public static func set(_ name: String, value: String) -> Bool
- Parameters:
name, the variable name;value, the value to store. - Returns:
trueon success. The result is discardable. - OCCT:
OSD_Environment(name, value).Build()(viaOCCTEnvironmentSet). - Example:
Environment.set("CSF_MDTVFontDirectory", value: "/usr/share/fonts")
Environment.remove(_:)
Remove an environment variable from the current process.
public static func remove(_ name: String)
- Parameters:
name, the variable name to unset. - OCCT:
OSD_Environment(name).Remove()(viaOCCTEnvironmentRemove).
math_Gauss
Namespace wrapping math_Gauss, direct Gaussian elimination for square linear systems.
MathGauss.solve(matrix:rhs:)
Solve Ax = b using Gaussian elimination.
public static func solve(matrix: [Double], rhs: [Double]) -> [Double]?
- Parameters:
matrix, row-major N×N coefficient matrix (N² elements);rhs, right-hand side vector (N elements). - Returns: Solution vector of length N, or
nilon failure (singular matrix). - OCCT:
math_Gauss::Solve(viaOCCTMathGaussSolve). - Example:
// Solve 2x + y = 5, x + 3y = 10 let A = [2.0, 1.0, 1.0, 3.0] let b = [5.0, 10.0] if let x = MathGauss.solve(matrix: A, rhs: b) { print(x) // [1.0, 3.0] }
MathGauss.determinant(matrix:n:)
Compute the determinant of an N×N matrix using Gaussian elimination.
public static func determinant(matrix: [Double], n: Int) -> Double?
- Parameters:
matrix, row-major N×N matrix;n, dimension. - Returns: The determinant, or
nilifn/matrixare invalid. - Bounds:
nmust be positive andmatrix.countmust equaln * nexactly, or this returnsnil(#640, revised by #716’s review finding 7). Before this bound, a mismatched positivenread past the end ofmatrixinside the bridge.nil, not0.0:0.0is also the determinant of a genuinely singular matrix, so a bareDoublesentinel could not distinguish an invalid dimension from a real, correctly-computed zero.n * nis itself checked for overflow, son: .maxis rejected rather than trapping the multiplication. - OCCT:
math_Gauss::Determinant(viaOCCTMathGaussDeterminant).
math_SVD
Namespace wrapping math_SVD, Singular Value Decomposition for least-squares problems.
MathSVD.solve(matrix:rows:cols:rhs:)
Solve the overdetermined or exactly determined system Ax ≈ b in the least-squares sense.
public static func solve(matrix: [Double], rows: Int, cols: Int, rhs: [Double]) -> [Double]?
- Parameters:
matrix, row-major M×N matrix;rows, M;cols, N;rhs, right-hand side (length M). - Returns: Solution vector of length N, or
nilon failure. - Bounds:
rowsandcolsmust both be positive, andmatrix.count == rows * cols/rhs.count == rowsmust hold, or this returnsnil(#640). A consistency check alone is not enough:rows: 0, cols: -1satisfiesmatrix.count == rows * colsfor anymatrix, so the positivity bound is required too.rows * colsis itself checked for overflow, so a huge positiverows/colsis rejected rather than trapping the multiplication (#716’s review finding 8). - OCCT:
math_SVD::Solve(viaOCCTMathSVDSolve). - Example:
// Over-determined 3x2 system let A = [1.0, 0, 0, 1, 1, 1] let b = [1.0, 2.0, 3.0] if let x = MathSVD.solve(matrix: A, rows: 3, cols: 2, rhs: b) { print(x) }
math_DirectPolynomialRoots
Namespace wrapping math_DirectPolynomialRoots, closed-form real root finding for polynomials of degree 1–4.
MathPolynomialRoots.solve(coefficients:)
Find real roots of a polynomial a·xⁿ + b·xⁿ⁻¹ + … = 0.
public static func solve(coefficients: [Double]) -> [Double]?
- Parameters:
coefficients,[a, b, c, …]with the leading coefficient first; must have 2–5 elements (degree 1–4). - Returns: Array of real roots (possibly empty), or
nilon error. - OCCT:
math_DirectPolynomialRoots(viaOCCTMathPolynomialRoots). - Example:
// Solve x² - 5x + 6 = 0 → roots 2, 3 if let roots = MathPolynomialRoots.solve(coefficients: [1.0, -5.0, 6.0]) { print(roots) // [2.0, 3.0] (order may vary) }
math_Jacobi
Namespace wrapping math_Jacobi, Jacobi iterative eigenvalue decomposition for symmetric matrices.
MathJacobi.eigenvalues(matrix:n:)
Compute eigenvalues of an N×N symmetric matrix.
public static func eigenvalues(matrix: [Double], n: Int) -> [Double]?
- Parameters:
matrix, row-major N×N symmetric matrix;n, dimension. - Returns: Eigenvalue array of length N, or
nilon failure. - Bounds:
nmust be positive andmatrix.countmust equaln * nexactly, or this returnsnil(#640).eigenvalues(matrix: [1.0], n: -1)satisfies the consistency check alone (1 == (-1) * (-1)), which is why positivity is checked separately rather than folded into it.n * nis itself checked for overflow, son: .maxis rejected rather than trapping the multiplication (#716’s review finding 8). - OCCT:
math_Jacobi::Values(viaOCCTMathJacobiEigenvalues). - Example:
let sym = [2.0, 1.0, 1.0, 2.0] // 2x2 identity-ish if let ev = MathJacobi.eigenvalues(matrix: sym, n: 2) { print(ev) // [1.0, 3.0] }
Convert_CircleToBSplineCurve
Extension on Curve2D wrapping Convert_CircleToBSplineCurve.
Curve2D.fromCircleArc(centerX:centerY:radius:u1:u2:)
Convert a 2D circular arc to a BSpline curve.
public static func fromCircleArc(centerX: Double, centerY: Double, radius: Double,
u1: Double, u2: Double) -> Curve2D?
- Parameters:
centerX,centerY: arc centre;radius: circle radius, must be greater than zero;u1,u2: start and end parameter (in radians). - Returns: The BSpline representation, or
nilon failure or a degenerate radius. - OCCT:
Convert_CircleToBSplineCurve(viaOCCTConvertCircleToBSpline2D). - Example:
// Half-circle if let arc = Curve2D.fromCircleArc(centerX: 0, centerY: 0, radius: 1.0, u1: 0, u2: .pi) { print(arc.degree) }
Convert_SphereToBSplineSurface
Extension on Surface wrapping Convert_SphereToBSplineSurface.
Surface.fromSphere(origin:axis:radius:)
Convert a sphere to a BSpline surface.
public static func fromSphere(origin: SIMD3<Double>, axis: SIMD3<Double>, radius: Double) -> Surface?
- Parameters:
origin, sphere centre;axis, sphere axis direction;radius, radius. - Returns: The BSpline surface, or
nilon failure. - OCCT:
Convert_SphereToBSplineSurface(viaOCCTConvertSphereToBSplineSurface). - Example:
if let bsp = Surface.fromSphere(origin: .zero, axis: SIMD3(0, 0, 1), radius: 5.0) { print(bsp.surfaceKind) // .bsplineSurface }
Convert Conic Curves to BSpline
Extensions on Curve2D for exact BSpline representations of 2D conics.
Every one of these returns nil for a degenerate dimension. None of the Convert_* algorithms refuses one on its own: measured (#514), a zero-radius ellipse converts to a degree-2 curve that evaluates to its own centre at every parameter, and a zero focal length converts to a curve whose poles are all NaN.
Curve2D.fromEllipseArc(centerX:centerY:majorRadius:minorRadius:u1:u2:)
Convert a 2D ellipse arc to a BSpline curve.
public static func fromEllipseArc(centerX: Double, centerY: Double,
majorRadius: Double, minorRadius: Double,
u1: Double, u2: Double) -> Curve2D?
- Parameters:
centerX,centerY: ellipse centre;majorRadius,minorRadius: semi-axes, both greater than zero withminorRadius <= majorRadius(equal radii are a circle and are valid);u1,u2: parameter range, whose sweepu2 - u1must be greater than zero and no more than a full turn. - Returns: BSpline curve, or
nilon failure, on a degenerate ellipse, or on a sweep outside0 < u2 - u1 <= 2 * .pi. - Range:
Convert_EllipseToBSplineCurvestates that precondition and this Release kernel compiles its check away along with the two locals it tested, so the bridge applies it (#2884). Measured on the pinned kernel: a sweep of-2 * .pi, which isu1andu2swapped on a full ellipse, took the process down uncatchably; a sweep of1e9asked for 763,943,729 poles; a NaN bound produced a curve whose poles were all NaN, and OCCT’s own predicate would not have refused that one either, because both of its comparisons are false on a NaN. - OCCT:
Convert_EllipseToBSplineCurve(viaOCCTConvertEllipseToBSpline2D). - Example:
if let e = Curve2D.fromEllipseArc(centerX: 0, centerY: 0, majorRadius: 3.0, minorRadius: 1.5, u1: 0, u2: .pi) { }
Curve2D.fromHyperbolaArc(centerX:centerY:majorRadius:minorRadius:u1:u2:)
Convert a 2D hyperbola arc to a BSpline curve.
public static func fromHyperbolaArc(centerX: Double, centerY: Double,
majorRadius: Double, minorRadius: Double,
u1: Double, u2: Double) -> Curve2D?
- Parameters:
majorRadius,minorRadius: both greater than zero, in either order. A hyperbola puts no ordering on its radii, so a minor radius larger than the major is an ordinary hyperbola, not an inverted one. - Returns: BSpline curve, or
nilon failure or a degenerate hyperbola. - OCCT:
Convert_HyperbolaToBSplineCurve(viaOCCTConvertHyperbolaToBSpline2D). - Example:
if let h = Curve2D.fromHyperbolaArc(centerX: 0, centerY: 0, majorRadius: 10, minorRadius: 5, u1: -1, u2: 1) { }
Curve2D.fromParabolaArc(centerX:centerY:focal:u1:u2:)
Convert a 2D parabola arc to a BSpline curve.
public static func fromParabolaArc(centerX: Double, centerY: Double, focal: Double,
u1: Double, u2: Double) -> Curve2D?
- Parameters:
focal: focal distance of the parabola, must be greater than zero. - Returns: BSpline curve, or
nilon failure or a zero focal length, which OCCT converts into a curve with NaN poles rather than rejecting. - OCCT:
Convert_ParabolaToBSplineCurve(viaOCCTConvertParabolaToBSpline2D). - Example:
if let p = Curve2D.fromParabolaArc(centerX: 0, centerY: 0, focal: 5, u1: -2, u2: 2) { }
Convert Elementary Surfaces to BSpline
Extensions on Surface for exact BSpline representations of analytic surfaces.
Surface.fromCylinder(origin:axis:radius:u1:u2:v1:v2:)
Convert a cylinder patch to a BSpline surface.
public static func fromCylinder(origin: SIMD3<Double>, axis: SIMD3<Double>, radius: Double,
u1: Double, u2: Double, v1: Double, v2: Double) -> Surface?
- Parameters:
origin,axis, cylinder position and orientation;radius, cylinder radius;u1/u2, angular range (radians), ordered, withu2 - u1in0...2 * .pi;v1/v2, axial parameter range, which must differ by more thanEpsilon(v1). - Returns:
nilif the range is not oneConvert_CylinderToBSplineSurfaceaccepts. - OCCT:
Convert_CylinderToBSplineSurface(viaOCCTConvertCylinderToBSplineSurface). - Example:
if let cyl = Surface.fromCylinder(origin: .zero, axis: SIMD3(0, 0, 1), radius: 2.0, u1: 0, u2: 2 * .pi, v1: 0, v2: 5.0) { }
The ordering is not decoration. Convert_CylinderToBSplineSurface states the constraint as a Standard_DomainError_Raise_if, which the pinned kernel compiles to nothing (occt-validation-is-compiled-out), and its pole and knot arrays are fixed by its base class before it derives their real extent from the range it was handed. Before #2861 added the check on our side of the bridge: swapping the two arguments (u1: 2 * .pi, u2: 0) SIGSEGVed uncatchably, u2 - u1 >= 10.472 wrote about 3.4 KB past a 432-byte allocation before returning nil, and 2 * .pi < u2 - u1 < 10.472 returned a non-nil surface whose poles sat 11.7 to 12.7 from the axis of a radius-5 cylinder.
Surface.fromCone(origin:axis:semiAngle:refRadius:u1:u2:v1:v2:)
Convert a cone patch to a BSpline surface.
public static func fromCone(origin: SIMD3<Double>, axis: SIMD3<Double>,
semiAngle: Double, refRadius: Double,
u1: Double, u2: Double, v1: Double, v2: Double) -> Surface?
- Parameters:
semiAngle, half-angle in radians;refRadius, reference radius at the base;u1/u2andv1/v2carry exactly the constraint documented forfromCylinderabove, andConvert_ConeToBSplineSurface.cxx:94is the same compiled-outStandard_DomainError_Raise_if. - Returns:
nilif the range is not oneConvert_ConeToBSplineSurfaceaccepts. - OCCT:
Convert_ConeToBSplineSurface(viaOCCTConvertConeToBSplineSurface).
Surface.fromTorus(origin:axis:majorRadius:minorRadius:)
Convert a full torus to a BSpline surface.
public static func fromTorus(origin: SIMD3<Double>, axis: SIMD3<Double>,
majorRadius: Double, minorRadius: Double) -> Surface?
- OCCT:
Convert_TorusToBSplineSurface(viaOCCTConvertTorusToBSplineSurface). - Example:
if let t = Surface.fromTorus(origin: .zero, axis: SIMD3(0, 0, 1), majorRadius: 5.0, minorRadius: 1.5) { }
math_Householder
Namespace wrapping math_Householder, QR decomposition via Householder reflections for overdetermined systems.
MathHouseholder.solve(matrix:rows:cols:rhs:)
Solve Ax ≈ b (M ≥ N) using Householder QR.
public static func solve(matrix: [Double], rows: Int, cols: Int, rhs: [Double]) -> [Double]?
- Parameters:
matrix, row-major M×N matrix;rows, M (must be ≥cols);cols, N;rhs, right-hand side (length M). - Returns: Solution vector of length N, or
nilon failure or under-determined input. - Bounds:
rowsandcolsmust both be positive, in addition torows >= colsand the existingmatrix/rhslength checks, or this returnsnil(#640):rows >= colsalone does not excluderows: 0, cols: -1.rows * colsis itself checked for overflow (#716’s review finding 8). - OCCT:
math_Householder::Perform(viaOCCTMathHouseholderSolve). - Example:
let A = [1.0, 1, 1, 2, 1, 3] // 3x2 let b = [6.0, 5.0, 7.0] if let x = MathHouseholder.solve(matrix: A, rows: 3, cols: 2, rhs: b) { print(x) }
math_Crout
Namespace wrapping math_Crout, LDLᵀ Crout decomposition for symmetric positive-definite systems.
MathCrout.solve(matrix:rhs:)
Solve symmetric Ax = b using Crout decomposition.
public static func solve(matrix: [Double], rhs: [Double]) -> [Double]?
- Parameters:
matrix, row-major N×N symmetric matrix;rhs, right-hand side (length N). - Returns: Solution vector of length N, or
nilon failure. - OCCT:
math_Crout::Solve(viaOCCTMathCroutSolve). - Example:
let A = [4.0, 2, 2, 3] // 2x2 SPD let b = [8.0, 5.0] if let x = MathCrout.solve(matrix: A, rhs: b) { print(x) // [1.8571..., 0.4285...] }
MathCrout.determinant(matrix:n:)
Compute the determinant of a symmetric matrix via Crout factorisation.
public static func determinant(matrix: [Double], n: Int) -> Double?
- Returns: The determinant, or
nilifn/matrixare invalid. - Bounds:
nmust be positive andmatrix.countmust equaln * nexactly, or this returnsnil(#640, revised by #716’s review finding 7), the same fix and for the same reason asMathGauss.determinant:nil, not0.0, so an invalid dimension cannot be confused with a genuinely singular matrix.n * nis itself checked for overflow (#716’s review finding 8). - OCCT:
math_Crout::Determinant(viaOCCTMathCroutDeterminant).
ShapeFix_IntersectionTool
Extension on Shape wrapping ShapeFix_IntersectionTool, repairs self-intersecting wires on a face.
fixIntersectingWires(faceIndex:precision:)
Fix intersecting wires on a face of this shape.
@discardableResult
public func fixIntersectingWires(faceIndex: Int, precision: Double = 1e-6) -> Bool
- Parameters:
faceIndex, 0-based face index;precision, fix tolerance. - Returns:
trueif any fixes were applied. - OCCT:
ShapeFix_IntersectionTool::FixSelfIntersectWire(viaOCCTShapeFixIntersectingWires). - Example:
shape.fixIntersectingWires(faceIndex: 0)
XCAFDoc_AssemblyItemRef
Extension on Document wrapping XCAFDoc_AssemblyItemRef, a persistent reference to a specific item (and optionally a subshape) within an assembly hierarchy.
setAssemblyItemRef(labelId:itemPath:)
Attach an assembly item reference attribute to a label.
@discardableResult
public func setAssemblyItemRef(labelId: Int64, itemPath: String) -> Bool
- Parameters:
labelId, target label;itemPath, colon-separated label-entry path string. - OCCT:
XCAFDoc_AssemblyItemRef::Set(viaOCCTDocumentSetAssemblyItemRef).
assemblyItemRefPath(labelId:)
Get the assembly item reference path string.
public func assemblyItemRefPath(labelId: Int64) -> String?
- Returns: Path string, or
nilif no attribute exists. - OCCT:
XCAFDoc_AssemblyItemRef::GetItem()plusXCAFDoc_AssemblyItemId::ToString()(viaOCCTDocumentGetAssemblyItemRef).XCAFDoc_AssemblyItemRefdeclares noGetPath;GetPathisXCAFDoc_AssemblyItemId’s, and returns a list rather than a string.
assemblyItemRefSetSubshape(labelId:index:)
Set a subshape index on an assembly item reference.
@discardableResult
public func assemblyItemRefSetSubshape(labelId: Int64, index: Int32) -> Bool
- OCCT:
XCAFDoc_AssemblyItemRef::SetSubshapeIndex(viaOCCTDocumentAssemblyItemRefSetSubshape).
assemblyItemRefGetSubshape(labelId:)
Get the subshape index, if set.
public func assemblyItemRefGetSubshape(labelId: Int64) -> Int32?
- Returns: The subshape index, or
nilif not set (raw value < 0). - OCCT:
XCAFDoc_AssemblyItemRef::GetSubshapeIndex(viaOCCTDocumentAssemblyItemRefGetSubshape).
assemblyItemRefHasExtra(labelId:)
Check whether the assembly item reference carries an extra attribute reference.
public func assemblyItemRefHasExtra(labelId: Int64) -> Bool
- OCCT:
XCAFDoc_AssemblyItemRef::HasExtraRef(viaOCCTDocumentAssemblyItemRefHasExtra).
assemblyItemRefClearExtra(labelId:)
Remove the extra attribute reference from an assembly item ref.
@discardableResult
public func assemblyItemRefClearExtra(labelId: Int64) -> Bool
- OCCT:
XCAFDoc_AssemblyItemRef::ClearExtraRef(viaOCCTDocumentAssemblyItemRefClearExtra). There is noRemoveExtraRef.
assemblyItemRefIsOrphan(labelId:)
Whether the assembly item reference points to a label that no longer exists.
public func assemblyItemRefIsOrphan(labelId: Int64) -> Bool
- OCCT:
XCAFDoc_AssemblyItemRef::IsOrphan(viaOCCTDocumentAssemblyItemRefIsOrphan).
BRepAlgo_Image
Wraps BRepAlgo_Image, a bidirectional mapping that tracks how shapes evolve through Boolean or healing operations (shape history).
ShapeImage.init()
Create an empty shape image map.
public init()
- OCCT:
BRepAlgo_Image()(viaOCCTBRepAlgoImageCreate).
setRoot(_:)
Record the root (input) shape of the mapping.
public func setRoot(_ shape: Shape)
- OCCT:
BRepAlgo_Image::SetRoot(viaOCCTBRepAlgoImageSetRoot).
bind(old:new:)
Record that old was replaced by new.
public func bind(old: Shape, new: Shape)
- OCCT:
BRepAlgo_Image::Bind(viaOCCTBRepAlgoImageBind).
hasImage(_:)
Check if a shape has a recorded replacement image.
public func hasImage(_ shape: Shape) -> Bool
- OCCT:
BRepAlgo_Image::HasImage(viaOCCTBRepAlgoImageHasImage).
isImage(_:)
Check if a shape is itself a recorded image of some root shape.
public func isImage(_ shape: Shape) -> Bool
- OCCT:
BRepAlgo_Image::IsImage(viaOCCTBRepAlgoImageIsImage).
clear()
Clear all recorded mappings.
public func clear()
- OCCT:
BRepAlgo_Image::Clear(viaOCCTBRepAlgoImageClear).
(Internal, not public API: ShapeImage.handle is an unmarked let handle: OCCTBRepAlgoImageRef (Swift default access, i.e. internal) wrapping the underlying bridge object, released in deinit. See Memory Management.)
OSD_Path
Namespace wrapping OSD_Path, platform-independent file path parsing.
OSDPath.name(_:)
Extract the filename (without extension) from a path string.
public static func name(_ path: String) -> String?
- OCCT:
OSD_Path::Name(viaOCCTOSDPathName). - Example:
OSDPath.name("/tmp/part.stp") // "part"
OSDPath.fileExtension(_:)
Extract the file extension (with leading dot) from a path string.
public static func fileExtension(_ path: String) -> String?
- OCCT:
OSD_Path::Extension(viaOCCTOSDPathExtension). - Example:
OSDPath.fileExtension("/tmp/part.stp") // ".stp"
OSDPath.trek(_:)
Extract the directory trek portion of a path.
public static func trek(_ path: String) -> String?
- OCCT:
OSD_Path::Trek(viaOCCTOSDPathTrek).
OSDPath.systemName(_:)
Get the system-formatted (OS-native) path string.
public static func systemName(_ path: String) -> String?
- OCCT:
OSD_Path::SystemName(viaOCCTOSDPathSystemName).
OSDPath.folderAndFile(_:)
Split a path into its folder and filename components.
public static func folderAndFile(_ path: String) -> (folder: String, file: String)?
- Returns: Tuple of folder and filename strings, or
nilif splitting fails. - OCCT:
OSD_Pathtrek/name split (viaOCCTOSDPathFolderAndFile). - Example:
if let (folder, file) = OSDPath.folderAndFile("/tmp/parts/bolt.stp") { print(folder, file) }
OSDPath.folder(_:)
Get the directory part of a path, as a real path with its trailing separator: the filesystem-usable counterpart of trek(_:).
public static func folder(_ path: String) -> String?
- Parameters:
path: path string. - Returns: The directory part with its trailing separator, or
""ifpathhas no directory part;nilifpathcannot be parsed. - OCCT:
OSD_Path::TrekValuereassembled with a trailing separator (viaOCCTOSDPathFolderAndFile, discarding the filename). - Example:
OSDPath.folder("/home/user/model.step") // "/home/user/" OSDPath.folder("model.step") // ""
OSDPath.isValid(_:)
Whether the path string is syntactically valid.
public static func isValid(_ path: String) -> Bool
- OCCT:
OSD_Path::IsValid(viaOCCTOSDPathIsValid).
OSDPath.isUnixPath(_:)
Whether the path uses Unix conventions.
public static func isUnixPath(_ path: String) -> Bool
- OCCT:
OSD_Pathsystem type check (viaOCCTOSDPathIsUnixPath).
OSDPath.isRelative(_:)
Whether the path is relative (does not start at the filesystem root).
public static func isRelative(_ path: String) -> Bool
- OCCT:
OSD_Path::IsRelativePath(viaOCCTOSDPathIsRelative).
OSDPath.isAbsolute(_:)
Whether the path is absolute.
public static func isAbsolute(_ path: String) -> Bool
- OCCT:
OSD_Path::IsAbsolutePath(viaOCCTOSDPathIsAbsolute).
BRepClass_FClassifier
Extension on Shape providing 2D face-parameter-space classification and loop building.
classifyPoint2D(faceIndex:u:v:tolerance:)
Classify a UV parameter-space point on a face.
public func classifyPoint2D(faceIndex: Int, u: Double, v: Double, tolerance: Double = 1e-6) -> PointState
- Parameters:
faceIndex, 0-based face index;u,v, UV parameters on the face;tolerance, classification tolerance (default 1e-6). - Returns:
.inside,.outside,.on, or.unknown(samePointStateenum asclassifyPoint). - OCCT:
BRepClass_FClassifier::Perform(viaOCCTShapeClassifyPoint2D). - Note: Answers the same question as
Face.classify(u:v:tolerance:)(see “Shape-Healing”) andShape.classifyPoint2d(u:v:tolerance:)(see “Shape-Builders-2”); all three now share this1e-6default (#840). - Example:
let state = shape.classifyPoint2D(faceIndex: 0, u: 0.5, v: 0.5)
buildLoops(faceIndex:)
Build edge loops (wires) from the free edges on a face.
public func buildLoops(faceIndex: Int) -> Int
- Parameters:
faceIndex, 0-based face index. - Returns: Number of loops built, or -1 on error.
- OCCT:
BRepAlgo_Loop(viaOCCTShapeBuildLoops).
faceDomainEdgeCount(faceIndex:)
Count the boundary edges of a face using BRepGProp_Domain.
public func faceDomainEdgeCount(faceIndex: Int) -> Int
- OCCT:
BRepGProp_Domainiteration (Init/More/Next) viaOCCTShapeFaceDomainEdgeCount.
Bnd_BoundSortBox
Wraps Bnd_BoundSortBox, a spatial index for fast AABB-vs-AABB intersection queries.
BoundSortBox.init(boxes:)
Create a sort box from an array of axis-aligned bounding boxes.
public init(boxes: [[Double]])
- Parameters:
boxes, each element is[xmin, ymin, zmin, xmax, ymax, zmax]. - OCCT:
Bnd_BoundSortBox::Initialize(viaOCCTBoundSortBoxCreate). - Example:
let bsb = BoundSortBox(boxes: [ [0, 0, 0, 1, 1, 1], [2, 2, 2, 3, 3, 3], ])
compare(xmin:ymin:zmin:xmax:ymax:zmax:)
Find the 0-based indices of stored boxes that intersect a query box.
public func compare(xmin: Double, ymin: Double, zmin: Double,
xmax: Double, ymax: Double, zmax: Double) -> [Int]
- Returns: Array of 0-based indices into the array supplied at construction.
- OCCT:
Bnd_BoundSortBox::Compare(viaOCCTBoundSortBoxCompare). - Example:
let hits = bsb.compare(xmin: 0.5, ymin: 0.5, zmin: 0.5, xmax: 1.5, ymax: 1.5, zmax: 1.5) // hits == [0]
(Internal, not public API: BoundSortBox.handle is an unmarked let handle: OCCTBoundSortBoxRef (Swift default access, i.e. internal) wrapping the underlying bridge object, released in deinit. See Memory Management.)
TNaming_Naming
Extension on Document wrapping TNaming_Naming, persistent topological naming that survives shape modifications.
insertNaming(labelId:)
Insert a TNaming_Naming attribute on a label.
@discardableResult
public func insertNaming(labelId: Int64) -> Bool
- OCCT:
TNaming_Naming::Insert(viaOCCTDocumentInsertNaming). - Example:
doc.insertNaming(labelId: shapeLabel)
namingIsDefined(labelId:)
Check whether a naming attribute is defined and valid on a label.
public func namingIsDefined(labelId: Int64) -> Bool
- OCCT:
TNaming_Naming::IsDefined(viaOCCTDocumentNamingIsDefined).
Precision Constants
Namespace exposing OCCT’s global precision tolerances from Precision.hxx.
OCCTPrecision.confusion
General positional/distance confusion tolerance (1×10⁻⁷ by default).
public static var confusion: Double { get }
- OCCT:
Precision::Confusion()(viaOCCTPrecisionConfusion).
OCCTPrecision.angular
Angular direction comparison tolerance (1×10⁻¹² by default).
public static var angular: Double { get }
- OCCT:
Precision::Angular()(viaOCCTPrecisionAngular).
OCCTPrecision.intersection
Tolerance used by intersection algorithms. Precision::Confusion() / 100, that is 1×10⁻⁹.
public static var intersection: Double { get }
- OCCT:
Precision::Intersection()(viaOCCTPrecisionIntersection).
OCCTPrecision.approximation
Tolerance used by approximation algorithms. Precision::Confusion() * 10, that is 1×10⁻⁶, so it is deliberately looser than confusion.
public static var approximation: Double { get }
- OCCT:
Precision::Approximation()(viaOCCTPrecisionApproximation).
OCCTPrecision.infinite
Sentinel value representing “infinite” (2×10¹⁰⁰).
public static var infinite: Double { get }
- OCCT:
Precision::Infinite()(viaOCCTPrecisionInfinite).
OCCTPrecision.pConfusion
Parametric-space confusion tolerance: a constant 1×10⁻⁹.
public static var pConfusion: Double { get }
Precision::PConfusion() is confusion converted to parametric space for a curve whose mean tangent length is OCCT’s default of 100, so it is Precision::Confusion() / 100 and depends on nothing the caller passes. This entry said “scaled by curve-space bounds” until #1399 measured it; the overload that does take a tangent length, Precision::PConfusion(T), is not wrapped.
- OCCT:
Precision::PConfusion()(viaOCCTPrecisionPConfusion).
OCCTPrecision.isInfinite(_:)
Test whether a value should be treated as infinite.
public static func isInfinite(_ value: Double) -> Bool
- OCCT:
Precision::IsInfinite(viaOCCTPrecisionIsInfinite). - Example:
OCCTPrecision.isInfinite(1e200) // true OCCTPrecision.isInfinite(10.0) // false
IntAna Analytic Intersections
Namespace of static methods wrapping OCCT’s IntAna package, closed-form intersections between lines, planes, spheres, and tori.
IntAna.ConicQuadResult
Result of a line-with-quadric intersection.
public struct ConicQuadResult {
public let points: [SIMD3<Double>]
public let params: [Double]
public let isParallel: Bool
public let isInQuadric: Bool
}
| Field | Meaning |
|---|---|
points | Intersection points in 3D |
params | Parameter on the line for each point, aligned index-for-index with points |
isParallel | The line is parallel to the quadric surface |
isInQuadric | Only meaningful when isParallel is true: the line lies entirely within the surface (an infinite intersection), rather than merely being parallel and disjoint from it (#1582). points/params stay empty either way. Only linePlane(...) computes this (mirrors OCCT’s own IntAna_IntConicQuad::IsInQuadric()); lineSphere(...) always reports false. |
IntAna.ConicQuadResult.params
Parameter on the line for each intersection point, index-aligned with points.
IntAna.linePlane(lineOrigin:lineDir:planeOrigin:planeNormal:)
Intersect a parametric line with a plane.
public static func linePlane(lineOrigin: SIMD3<Double>, lineDir: SIMD3<Double>,
planeOrigin: SIMD3<Double>, planeNormal: SIMD3<Double>) -> ConicQuadResult
- Returns: Up to 1 intersection point;
isParallelistruewhen the line lies in or is parallel to the plane. WhenisParallelistrue, checkisInQuadricto tell a line embedded entirely within the plane apart from one that is merely parallel and disjoint (#1582); both otherwise report the identical emptypoints/params. - OCCT:
IntAna_IntConicQuad(viaOCCTIntAnaLineQuad). - Example:
let r = IntAna.linePlane(lineOrigin: SIMD3(0, 0, 5), lineDir: SIMD3(0, 0, -1), planeOrigin: .zero, planeNormal: SIMD3(0, 0, 1)) // r.points[0] ≈ (0, 0, 0) let embedded = IntAna.linePlane(lineOrigin: SIMD3(1, 2, 0), lineDir: SIMD3(1, 0, 0), planeOrigin: .zero, planeNormal: SIMD3(0, 0, 1)) // embedded.isParallel == true, embedded.isInQuadric == true (the line lies in the plane)
IntAna.lineSphere(lineOrigin:lineDir:sphereCenter:sphereAxis:radius:)
Intersect a parametric line with a sphere.
public static func lineSphere(lineOrigin: SIMD3<Double>, lineDir: SIMD3<Double>,
sphereCenter: SIMD3<Double>, sphereAxis: SIMD3<Double>,
radius: Double) -> ConicQuadResult
- Returns: Up to 2 intersection points.
- OCCT:
IntAna_IntConicQuadwith sphere quadric (viaOCCTIntAnaLineSphere).
IntAna.ResultType
Which shape IntAna_QuadQuadGeo actually reported, mirroring OCCT’s IntAna_ResultType.
public enum ResultType: Int32, Sendable {
case point = 0
case line = 1
case circle = 2
case pointAndCircle = 3
case ellipse = 4
case parabola = 5
case hyperbola = 6
case empty = 7
case same = 8
case noGeometricSolution = 9
}
IntAna.QuadQuadResult
Result of a quadric-quadric intersection.
public struct QuadQuadResult {
public let count: Int
public let resultType: ResultType
public let lines: [(origin: SIMD3<Double>, direction: SIMD3<Double>)]
public let points: [SIMD3<Double>]
public let circles: [(center: SIMD3<Double>, axis: SIMD3<Double>, radius: Double)]
}
count: number of solutionsIntAna_QuadQuadGeofound.resultTypeis only meaningful when this is at least 1.resultType: the kind of intersection OCCT reported (.linefor plane-plane,.pointor.circlefor plane-sphere).lines: solution lines (origin + direction), populated whenresultType == .line(plane-plane).points: solution points, populated whenresultType == .point(e.g. a plane tangent to a sphere).circles: solution circles (center, axis, radius), populated whenresultType == .circle(e.g. a plane secant to a sphere — the common case, #1495:IntAna_QuadQuadGeo::Point()silently returns(0, 0, 0)for this case in OCCT itself, so this wrapper readsCircle()instead).
(Per-field anchor below, for cross-reference; the list above has the actual meaning of each.)
IntAna.QuadQuadResult.lines
IntAna.planePlane(p1Origin:p1Normal:p2Origin:p2Normal:)
Intersect two planes, result is typically a line.
public static func planePlane(p1Origin: SIMD3<Double>, p1Normal: SIMD3<Double>,
p2Origin: SIMD3<Double>, p2Normal: SIMD3<Double>) -> QuadQuadResult
- OCCT:
IntAna_QuadQuadGeoplane-plane (viaOCCTIntAnaPlanePlane). - Example:
let r = IntAna.planePlane(p1Origin: .zero, p1Normal: SIMD3(0, 0, 1), p2Origin: .zero, p2Normal: SIMD3(0, 1, 0)) // r.lines[0] is the X-axis intersection line
IntAna.planeSphere(planeOrigin:planeNormal:sphereCenter:sphereAxis:radius:)
Intersect a plane with a sphere, result is typically a circle.
public static func planeSphere(planeOrigin: SIMD3<Double>, planeNormal: SIMD3<Double>,
sphereCenter: SIMD3<Double>, sphereAxis: SIMD3<Double>,
radius: Double) -> QuadQuadResult
- Returns:
resultType == .circle(center/axis/radius incircles) for the ordinary secant case,.point(inpoints) only when the plane is tangent to the sphere. - OCCT:
IntAna_QuadQuadGeoplane-sphere (viaOCCTIntAnaPlaneSphere). - Example:
let r = IntAna.planeSphere(planeOrigin: SIMD3(0, 0, 3), planeNormal: SIMD3(0, 0, 1), sphereCenter: .zero, sphereAxis: SIMD3(0, 0, 1), radius: 10) // r.resultType == .circle, r.circles[0].center ≈ (0, 0, 3), r.circles[0].radius ≈ 9.539
IntAna.threePlanes(p1Origin:p1Normal:p2Origin:p2Normal:p3Origin:p3Normal:)
Compute the unique intersection point of three planes.
public static func threePlanes(p1Origin: SIMD3<Double>, p1Normal: SIMD3<Double>,
p2Origin: SIMD3<Double>, p2Normal: SIMD3<Double>,
p3Origin: SIMD3<Double>, p3Normal: SIMD3<Double>) -> SIMD3<Double>?
- Returns: The point, or
nilif the planes are not in general position. - OCCT:
IntAna_Int3Pln(viaOCCTIntAna3Planes).
IntAna.lineTorus(lineOrigin:lineDir:torusCenter:torusAxis:majorRadius:minorRadius:)
Intersect a parametric line with a torus (up to 4 points).
public static func lineTorus(lineOrigin: SIMD3<Double>, lineDir: SIMD3<Double>,
torusCenter: SIMD3<Double>, torusAxis: SIMD3<Double>,
majorRadius: Double, minorRadius: Double) -> [SIMD3<Double>]
- Returns: Array of 0–4 intersection points.
- OCCT:
IntAna_IntLinTorus(viaOCCTIntAnaLineTorus).
OSD_Chronometer
Namespace wrapping OSD_Chronometer, per-process and per-thread CPU time measurement.
CPUTime.processCPU()
Get total process CPU time split into user and system seconds.
public static func processCPU() -> (user: Double, system: Double)
- OCCT:
OSD_Chronometer::GetProcessCPU(viaOCCTGetProcessCPU). - Example:
let (user, sys) = CPUTime.processCPU()
CPUTime.threadCPU()
Get current thread CPU time split into user and system seconds.
public static func threadCPU() -> (user: Double, system: Double)
- OCCT:
OSD_Chronometer::GetThreadCPU(viaOCCTGetThreadCPU).
OSD_Process
Namespace wrapping OSD_Process, process identification and path utilities.
ProcessInfo.processId
Current process identifier.
public static var processId: Int { get }
- OCCT:
OSD_Process::ProcessId(viaOCCTProcessId).
ProcessInfo.userName
Login name of the process owner.
public static var userName: String? { get }
- OCCT:
OSD_Process::UserName(viaOCCTProcessUserName).
ProcessInfo.executablePath
Full path to the running executable.
public static var executablePath: String? { get }
- OCCT:
OSD_Process::ExecutablePath(viaOCCTProcessExecutablePath).
ProcessInfo.executableFolder
Folder containing the running executable.
public static var executableFolder: String? { get }
- OCCT:
OSD_Process::ExecutableFolder(viaOCCTProcessExecutableFolder).
Draft_Modification
Extension on Shape wrapping Draft_Modification, applies a draft angle to a face, tapering it toward a neutral plane.
draftModification(faceIndex:direction:angle:neutralPlaneOrigin:neutralPlaneNormal:)
Apply a draft angle modification to a face of this shape.
public func draftModification(faceIndex: Int, direction: SIMD3<Double>, angle: Double,
neutralPlaneOrigin: SIMD3<Double>,
neutralPlaneNormal: SIMD3<Double>) -> Shape?
- Parameters:
faceIndex, 0-based index of the face to draft;direction, pull direction for demoulding;angle, draft angle in radians;neutralPlaneOrigin/neutralPlaneNormal, the plane that stays fixed during drafting. - Returns: The modified shape, or
nilon failure (incompatible geometry). - OCCT:
Draft_Modification::Add / Perform(viaOCCTShapeDraftModification). - Example:
if let drafted = shape.draftModification(faceIndex: 0, direction: SIMD3(0, 0, 1), angle: 0.05, neutralPlaneOrigin: .zero, neutralPlaneNormal: SIMD3(0, 0, 1)) { // drafted face tapers at 0.05 rad ≈ 2.86° }
Convert_CompBezierCurvesToBSplineCurve
Structures and namespace for converting multi-segment Bezier curves to a single BSpline curve.
BezierToBSplineResult
Result of a 3D composite Bezier → BSpline conversion.
public struct BezierToBSplineResult {
public let degree: Int
public let poles: [SIMD3<Double>]
public let knots: [Double]
public let multiplicities: [Int]
}
BezierToBSpline2dResult
Result of a 2D composite Bezier → BSpline conversion.
public struct BezierToBSpline2dResult {
public let degree: Int
public let poles: [SIMD2<Double>]
public let knots: [Double]
public let multiplicities: [Int]
}
CompBezierConverter.toBSpline(segments:)
Convert a sequence of connected 3D Bezier segments to a single BSpline curve.
public static func toBSpline(segments: [[SIMD3<Double>]]) -> BezierToBSplineResult?
- Parameters:
segments, each element is the ordered control points of one Bezier segment; all segments must have the same number of control points. - Returns: The merged BSpline data, or
nilon failure. - OCCT:
Convert_CompBezierCurvesToBSplineCurve(viaOCCTConvertCompBezierToBSpline). - Example:
let seg1: [SIMD3<Double>] = [SIMD3(0,0,0), SIMD3(1,1,0), SIMD3(2,0,0)] let seg2: [SIMD3<Double>] = [SIMD3(2,0,0), SIMD3(3,-1,0), SIMD3(4,0,0)] if let result = CompBezierConverter.toBSpline(segments: [seg1, seg2]) { print("degree:", result.degree, "poles:", result.poles.count) }
CompBezierConverter.toBSpline2d(segments:)
Convert a sequence of connected 2D Bezier segments to a single BSpline curve.
public static func toBSpline2d(segments: [[SIMD2<Double>]]) -> BezierToBSpline2dResult?
- Parameters:
segments, each element is the ordered 2D control points of one Bezier segment; all segments must have the same number of control points. - Returns: The merged 2D BSpline data, or
nilon failure. - OCCT:
Convert_CompBezierCurves2dToBSplineCurve2d(viaOCCTConvertCompBezier2dToBSpline2d).
Geom_OffsetSurface Extensions
Extensions on Surface for querying and modifying offset surface parameters.
offsetValue
The offset distance of this surface (only meaningful for offset surfaces).
public var offsetValue: Double { get }
- Returns: Offset distance; returns 0 for non-offset surfaces.
- OCCT:
Geom_OffsetSurface::Offset(viaOCCTSurfaceOffsetValue). - Example:
if surface.isOffsetSurface { print("offset:", surface.offsetValue) }
setOffsetValue(_:)
Change the offset distance of an offset surface.
public func setOffsetValue(_ value: Double)
- Note: No-op on non-offset surfaces.
- OCCT:
Geom_OffsetSurface::SetOffsetValue(viaOCCTSurfaceSetOffsetValue). - Example:
surface.setOffsetValue(2.0)
offsetBasis
The underlying basis surface of an offset surface.
public var offsetBasis: Surface? { get }
- Returns: The basis
Surface, ornilif this surface is not an offset surface. - OCCT:
Geom_OffsetSurface::BasisSurface(viaOCCTSurfaceOffsetBasis). - Example:
if let basis = surface.offsetBasis { print("basis kind:", basis.surfaceKind) }