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 lines 4959–6350 of 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 · 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::GetVectorPart/ 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()
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
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
}
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(dx: 10, dy: 10, dz: 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
}
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_Heap)(viaOCCTMemInfoHeapUsage).
MemInfo.workingSet
Working set (resident memory) in bytes.
public static var workingSet: Int64 { get }
- OCCT:
OSD_MemInfo::Value(OSD_MemInfo_WSet)(viaOCCTMemInfoWorkingSet).
MemInfo.heapUsageMiB
Heap usage as a precise Double in mebibytes.
public static var heapUsageMiB: Double { get }
- OCCT:
OSD_MemInfo::ValueMiB(OSD_MemInfo_Heap)(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
}
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:
TDataXtd_PatternStd::Find(viaOCCTDocumentHasPattern).
patternSetSignature(labelId:signature:)
Set the pattern type.
@discardableResult
public func patternSetSignature(labelId: Int64, signature: PatternSignature) -> Bool
- OCCT:
TDataXtd_PatternStd::SetSignature(viaOCCTDocumentPatternSetSignature).
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.
- OCCT:
BRepAlgo_FaceRestrictor::Perform / NbFaces(viaOCCTShapeFaceRestrictAlgo). - Example:
let n = shape.faceRestrictAlgo(faceIndex: 0) print("result faces:", n)
math_Matrix
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).
value(row:col:)
Read the element at (row, col) — 1-based.
public func value(row: Int, col: Int) -> Double
- OCCT:
math_Matrix::Value(viaOCCTMathMatrixGetValue). - Example:
let v = m.value(row: 1, col: 1)
setValue(row:col:value:)
Write the element at (row, col) — 1-based.
public func setValue(row: Int, col: Int, value: Double)
- OCCT:
math_Matrix::SetValue(viaOCCTMathMatrixSetValue).
determinant
Determinant of the matrix.
public var determinant: Double { get }
- OCCT:
math_Matrix::Determinant(viaOCCTMathMatrixDeterminant).
invert()
Invert the matrix in-place.
@discardableResult
public func invert() -> Bool
- Returns:
trueon success;falseif the matrix is singular. - 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.
public func transpose()
- OCCT:
math_Matrix::Transpose(viaOCCTMathMatrixTranspose).
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. - 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. - 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. - 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;u1,u2— start and end parameter (in radians). - Returns: The BSpline representation, or
nilon failure. - 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.
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;u1,u2— parameter range. - Returns: BSpline curve, or
nilon failure. - 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?
- OCCT:
Convert_HyperbolaToBSplineCurve(viaOCCTConvertHyperbolaToBSpline2D).
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. - OCCT:
Convert_ParabolaToBSplineCurve(viaOCCTConvertParabolaToBSpline2D).
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);v1/v2— axial parameter range. - 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) { }
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. - 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. - OCCT:
math_Householder::Solve(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
- 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::GetPath(viaOCCTDocumentGetAssemblyItemRef).
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::RemoveExtraRef(viaOCCTDocumentAssemblyItemRefClearExtra).
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).
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.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::IsRelative(viaOCCTOSDPathIsRelative).
OSDPath.isAbsolute(_:)
Whether the path is absolute.
public static func isAbsolute(_ path: String) -> Bool
- OCCT:
OSD_Path::IsAbsolute(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. - Returns:
.inside,.outside,.on, or.unknown(samePointStateenum asclassifyPoint). - OCCT:
BRepClass_FClassifier::Perform(viaOCCTShapeClassifyPoint2D). - 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_Domain::NbEdges(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]
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.
public static var intersection: Double { get }
- OCCT:
Precision::Intersection()(viaOCCTPrecisionIntersection).
OCCTPrecision.approximation
Tolerance used by approximation algorithms.
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 (scaled by curve-space bounds).
public static var pConfusion: Double { get }
- 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
}
points— intersection points in 3D;params— corresponding parameters on the line;isParallel— the line is parallel to the quadric surface.
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. - 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)
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.QuadQuadResult
Result of a quadric-quadric intersection.
public struct QuadQuadResult {
public let count: Int
public let lines: [(origin: SIMD3<Double>, direction: SIMD3<Double>)]
public let points: [SIMD3<Double>]
}
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
- OCCT:
IntAna_QuadQuadGeoplane-sphere (viaOCCTIntAnaPlaneSphere).
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_CompPolynomialToPoles/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) }