Document — Builders, Fillet/Chamfer & glTF
This page covers the v0.120–v0.126 additions to Document.swift: continuity/parameter extras on Curve3D, Curve2D, and Surface; gp_Vec static helpers on Shape; BSpline mutation completions on all three geometry types; the standalone FilletBuilder and ChamferBuilder classes (BRepFilletAPI_MakeFillet/MakeChamfer); the WireAnalyzer class (ShapeAnalysis_Wire); and glTF/GLB import and export on Shape, Exporter, and Document. See the main Document page for the XCAF core and assembly hierarchy.
Topics
- Final cleanup — IsCN, ReversedParameter, ParametricTransformation
- BSpline completions
- FilletBuilder
- ChamferBuilder
- ChamferBuilder completions
- FilletBuilder completions
- WireAnalyzer
- FilletBuilder completions (v0.126.0)
- GLTF Import/Export
Final cleanup — IsCN, ReversedParameter, ParametricTransformation
Extensions on Curve3D, Curve2D, and Surface exposing continuity checks, reversed-parameter mappings, parametric-transformation scale factors, and Bezier/BSpline static limits.
Curve3D.continuityOrder
The overall continuity order of this curve (0=C0, 1=C1, 2=C2, etc.).
public var continuityOrder: Int { get }
- OCCT:
Geom_Curve::Continuity→GeomAbs_Shapemapped to an integer (viaOCCTCurve3DContinuity).
Curve3D.isCN(_:)
Check if this curve has at least Cn continuity.
public func isCN(_ n: Int) -> Bool
- Parameters:
n— minimum continuity order required. - Returns:
trueif the curve is at least Cn continuous. - OCCT:
Geom_Curve::IsCN(viaOCCTCurve3DIsCN). - Example:
let curve: Curve3D = ... if curve.isCN(2) { print("C2 continuous") }
Curve3D.reversedParameter(_:)
Get the parameter on the reversed curve corresponding to parameter u on this curve.
public func reversedParameter(_ u: Double) -> Double
- Parameters:
u— parameter on the original curve. - Returns: Corresponding parameter on the reversed curve.
- OCCT:
Geom_Curve::ReversedParameter(viaOCCTCurve3DReversedParameter).
Curve3D.parametricTransformation(rotation:translation:)
Get the parametric transformation scale factor under a geometric transform.
public func parametricTransformation(rotation: [Double], translation: SIMD3<Double>) -> Double
- Parameters:
rotation— 3×3 rotation matrix in row-major order (9 elements).translation— translation vector.
- Returns: Scale factor for parameter intervals under the transform; returns
1.0ifrotation.count != 9. - OCCT:
Geom_Curve::ParametricTransformation(viaOCCTCurve3DParametricTransformation).
Curve3D.bezierResolution(tolerance3d:)
Resolution for 3D Bezier curves: the parameter step corresponding to tolerance3d in 3D space.
public func bezierResolution(tolerance3d: Double) -> Double
- Parameters:
tolerance3d— desired 3D tolerance. - OCCT:
Geom_BezierCurve::Resolution(viaOCCTCurve3DBezierResolution).
Curve3D.bezierMaxDegree
Maximum degree for 3D Bezier curves (static).
public static var bezierMaxDegree: Int { get }
- OCCT:
Geom_BezierCurve::MaxDegree(viaOCCTCurve3DBezierMaxDegree).
Curve2D.continuityOrder
The overall continuity order of this 2D curve (0=C0, 1=C1, 2=C2, etc.).
public var continuityOrder: Int { get }
- OCCT:
Geom2d_Curve::Continuity(viaOCCTCurve2DContinuity).
Curve2D.isCN(_:)
Check if this 2D curve has at least Cn continuity.
public func isCN(_ n: Int) -> Bool
- Parameters:
n— minimum continuity order required. - OCCT:
Geom2d_Curve::IsCN(viaOCCTCurve2DIsCN).
Curve2D.reversedParameter(_:)
Get the parameter on the reversed 2D curve corresponding to parameter u on this curve.
public func reversedParameter(_ u: Double) -> Double
- OCCT:
Geom2d_Curve::ReversedParameter(viaOCCTCurve2DReversedParameter).
Curve2D.bezierMaxDegree
Maximum degree for 2D Bezier curves (static).
public static var bezierMaxDegree: Int { get }
- OCCT:
Geom2d_BezierCurve::MaxDegree(viaOCCTCurve2DBezierMaxDegree).
Curve2D.bsplineMaxDegree
Maximum degree for 2D BSpline curves (static).
public static var bsplineMaxDegree: Int { get }
- OCCT:
Geom2d_BSplineCurve::MaxDegree(viaOCCTCurve2DBSplineMaxDegree).
Surface.isCNu(_:)
Check if this surface has at least Cn continuity in the U direction.
public func isCNu(_ n: Int) -> Bool
- Parameters:
n— minimum continuity order required. - OCCT:
Geom_Surface::IsCNu(viaOCCTSurfaceIsCNu).
Surface.isCNv(_:)
Check if this surface has at least Cn continuity in the V direction.
public func isCNv(_ n: Int) -> Bool
- OCCT:
Geom_Surface::IsCNv(viaOCCTSurfaceIsCNv).
Surface.uReversed()
Create a U-reversed copy of this surface.
public func uReversed() -> Surface?
- Returns: A new
Surfacewith reversed U parameterization, ornilon failure. - OCCT:
Geom_Surface::UReversed(viaOCCTSurfaceUReversed).
Surface.vReversed()
Create a V-reversed copy of this surface.
public func vReversed() -> Surface?
- Returns: A new
Surfacewith reversed V parameterization, ornilon failure. - OCCT:
Geom_Surface::VReversed(viaOCCTSurfaceVReversed).
Surface.uReversedParameter(_:)
Get the reversed U parameter value corresponding to u on the original surface.
public func uReversedParameter(_ u: Double) -> Double
- OCCT:
Geom_Surface::UReversedParameter(viaOCCTSurfaceUReversedParameter).
Surface.vReversedParameter(_:)
Get the reversed V parameter value corresponding to v on the original surface.
public func vReversedParameter(_ v: Double) -> Double
- OCCT:
Geom_Surface::VReversedParameter(viaOCCTSurfaceVReversedParameter).
Surface.bsplineRemoveVKnot(index:mult:tolerance:)
Remove a V knot from a BSpline surface, reducing its multiplicity to mult.
@discardableResult
public func bsplineRemoveVKnot(index: Int, mult: Int, tolerance: Double) -> Bool
- Parameters:
index— 1-based V knot index;mult— target multiplicity;tolerance— geometric tolerance. - Returns:
trueif the knot was successfully removed. - OCCT:
Geom_BSplineSurface::RemoveVKnot(viaOCCTSurfaceBSplineRemoveVKnot).
Surface.bezierResolution(tolerance3d:)
Resolution for Bezier surfaces: parameter steps in U and V corresponding to tolerance3d in 3D space.
public func bezierResolution(tolerance3d: Double) -> (u: Double, v: Double)
- Returns: Tuple of
(u, v)parameter steps. - OCCT:
Geom_BezierSurface::Resolution(viaOCCTSurfaceBezierResolution).
Surface.bezierMaxDegree
Maximum degree for Bezier surfaces (static).
public static var bezierMaxDegree: Int { get }
- OCCT:
Geom_BezierSurface::MaxDegree(viaOCCTSurfaceBezierMaxDegree).
Surface.bsplineMaxDegree
Maximum degree for BSpline surfaces (static).
public static var bsplineMaxDegree: Int { get }
- OCCT:
Geom_BSplineSurface::MaxDegree(viaOCCTSurfaceBSplineMaxDegree).
Shape.vecCrossMagnitude(_:_:)
Compute the magnitude of the cross product of two 3D vectors.
public static func vecCrossMagnitude(_ v1: SIMD3<Double>, _ v2: SIMD3<Double>) -> Double
- OCCT:
gp_Vec::CrossMagnitude(viaOCCTVecCrossMagnitude). - Example:
let mag = Shape.vecCrossMagnitude(SIMD3(1, 0, 0), SIMD3(0, 1, 0)) // 1.0
Shape.vecCrossSquareMagnitude(_:_:)
Compute the square magnitude of the cross product of two 3D vectors.
public static func vecCrossSquareMagnitude(_ v1: SIMD3<Double>, _ v2: SIMD3<Double>) -> Double
- OCCT:
gp_Vec::CrossSquareMagnitude(viaOCCTVecCrossSquareMagnitude).
Shape.dirIsOpposite(_:_:tolerance:)
Check if two directions are opposite within angular tolerance (radians).
public static func dirIsOpposite(_ d1: SIMD3<Double>, _ d2: SIMD3<Double>,
tolerance: Double = 1e-10) -> Bool
- Parameters:
d1,d2— unit direction vectors;tolerance— angular tolerance in radians. - Returns:
trueif the angle betweend1andd2is withintoleranceof π. - OCCT:
gp_Dir::IsOpposite(viaOCCTDirIsOpposite).
Shape.dirIsNormal(_:_:tolerance:)
Check if two directions are normal (perpendicular) within angular tolerance (radians).
public static func dirIsNormal(_ d1: SIMD3<Double>, _ d2: SIMD3<Double>,
tolerance: Double = 1e-10) -> Bool
- Parameters:
tolerance— angular tolerance in radians. - Returns:
trueif the angle between the two directions is withintoleranceof π/2. - OCCT:
gp_Dir::IsNormal(viaOCCTDirIsNormal).
BSpline completions
BSpline mutation helpers added to Surface, Curve3D, and Curve2D.
Surface.bsplineSetUNotPeriodic()
Remove U periodicity from a BSpline surface.
@discardableResult
public func bsplineSetUNotPeriodic() -> Bool
- OCCT:
Geom_BSplineSurface::SetUNotPeriodic(viaOCCTSurfaceBSplineSetUNotPeriodic).
Surface.bsplineSetVNotPeriodic()
Remove V periodicity from a BSpline surface.
@discardableResult
public func bsplineSetVNotPeriodic() -> Bool
- OCCT:
Geom_BSplineSurface::SetVNotPeriodic(viaOCCTSurfaceBSplineSetVNotPeriodic).
Surface.bsplineSetUOrigin(index:)
Set the origin knot index in the U direction on a periodic BSpline surface (1-based).
@discardableResult
public func bsplineSetUOrigin(index: Int) -> Bool
- OCCT:
Geom_BSplineSurface::SetUOrigin(viaOCCTSurfaceBSplineSetUOrigin).
Surface.bsplineSetVOrigin(index:)
Set the origin knot index in the V direction on a periodic BSpline surface (1-based).
@discardableResult
public func bsplineSetVOrigin(index: Int) -> Bool
- OCCT:
Geom_BSplineSurface::SetVOrigin(viaOCCTSurfaceBSplineSetVOrigin).
Surface.bsplineIncreaseUMultiplicity(index:multiplicity:)
Increase U multiplicity at a knot index to at least multiplicity (1-based).
@discardableResult
public func bsplineIncreaseUMultiplicity(index: Int, multiplicity: Int) -> Bool
- OCCT:
Geom_BSplineSurface::IncreaseUMultiplicity(viaOCCTSurfaceBSplineIncreaseUMultiplicity).
Surface.bsplineIncreaseVMultiplicity(index:multiplicity:)
Increase V multiplicity at a knot index to at least multiplicity (1-based).
@discardableResult
public func bsplineIncreaseVMultiplicity(index: Int, multiplicity: Int) -> Bool
- OCCT:
Geom_BSplineSurface::IncreaseVMultiplicity(viaOCCTSurfaceBSplineIncreaseVMultiplicity).
Surface.bsplineInsertUKnots(_:multiplicities:tolerance:)
Batch insert U knots with their multiplicities.
@discardableResult
public func bsplineInsertUKnots(_ knots: [Double], multiplicities: [Int], tolerance: Double = 1e-10) -> Bool
- Parameters:
knots— sorted knot values to insert;multiplicities— corresponding multiplicities;tolerance— knot merging tolerance. - Returns:
falseif either array is empty. - OCCT:
Geom_BSplineSurface::InsertUKnots(viaOCCTSurfaceBSplineInsertUKnots).
Surface.bsplineInsertVKnots(_:multiplicities:tolerance:)
Batch insert V knots with their multiplicities.
@discardableResult
public func bsplineInsertVKnots(_ knots: [Double], multiplicities: [Int], tolerance: Double = 1e-10) -> Bool
- OCCT:
Geom_BSplineSurface::InsertVKnots(viaOCCTSurfaceBSplineInsertVKnots).
Surface.bsplineMovePoint(u:v:to:uPoleRange:vPoleRange:)
Move a BSpline surface to pass through a point at (u, v), adjusting poles within the given ranges.
@discardableResult
public func bsplineMovePoint(u: Double, v: Double, to point: SIMD3<Double>,
uPoleRange: ClosedRange<Int>, vPoleRange: ClosedRange<Int>) -> Bool
- Parameters:
u,v— parameter at which the surface should pass throughpoint.point— target 3D point.uPoleRange,vPoleRange— 1-based ranges of poles allowed to move.
- OCCT:
Geom_BSplineSurface::MovePoint(viaOCCTSurfaceBSplineMovePoint).
Surface.bsplineSetPoleCol(vIndex:poles:)
Set an entire column of poles (all U poles at vIndex, 1-based).
@discardableResult
public func bsplineSetPoleCol(vIndex: Int, poles: [SIMD3<Double>]) -> Bool
- Parameters:
vIndex— 1-based V index;poles— array ofNbUPolespoints. - OCCT:
Geom_BSplineSurface::SetPoleCol(viaOCCTSurfaceBSplineSetPoleCol).
Surface.bsplineSetPoleRow(uIndex:poles:)
Set an entire row of poles (all V poles at uIndex, 1-based).
@discardableResult
public func bsplineSetPoleRow(uIndex: Int, poles: [SIMD3<Double>]) -> Bool
- Parameters:
uIndex— 1-based U index;poles— array ofNbVPolespoints. - OCCT:
Geom_BSplineSurface::SetPoleRow(viaOCCTSurfaceBSplineSetPoleRow).
Surface.bsplineSetWeightCol(vIndex:weights:)
Set a column of weights on a BSpline surface (vIndex 1-based, count = NbUPoles).
@discardableResult
public func bsplineSetWeightCol(vIndex: Int, weights: [Double]) -> Bool
- OCCT:
Geom_BSplineSurface::SetWeightCol(viaOCCTSurfaceBSplineSetWeightCol).
Surface.bsplineSetWeightRow(uIndex:weights:)
Set a row of weights on a BSpline surface (uIndex 1-based, count = NbVPoles).
@discardableResult
public func bsplineSetWeightRow(uIndex: Int, weights: [Double]) -> Bool
- OCCT:
Geom_BSplineSurface::SetWeightRow(viaOCCTSurfaceBSplineSetWeightRow).
Surface.bsplineIncrementUMultiplicity(fromIndex:toIndex:step:)
Increment U knot multiplicities in the range [fromIndex, toIndex] by step (1-based).
@discardableResult
public func bsplineIncrementUMultiplicity(fromIndex: Int, toIndex: Int, step: Int) -> Bool
- OCCT:
Geom_BSplineSurface::IncrementUMultiplicity(viaOCCTSurfaceBSplineIncrementUMultiplicity).
Surface.bsplineIncrementVMultiplicity(fromIndex:toIndex:step:)
Increment V knot multiplicities in the range [fromIndex, toIndex] by step (1-based).
@discardableResult
public func bsplineIncrementVMultiplicity(fromIndex: Int, toIndex: Int, step: Int) -> Bool
- OCCT:
Geom_BSplineSurface::IncrementVMultiplicity(viaOCCTSurfaceBSplineIncrementVMultiplicity).
Surface.bsplineFirstUKnotIndex
First U knot index of the BSpline surface.
public var bsplineFirstUKnotIndex: Int { get }
- OCCT:
Geom_BSplineSurface::FirstUKnotIndex(viaOCCTSurfaceBSplineFirstUKnotIndex).
Surface.bsplineLastUKnotIndex
Last U knot index of the BSpline surface.
public var bsplineLastUKnotIndex: Int { get }
- OCCT:
Geom_BSplineSurface::LastUKnotIndex(viaOCCTSurfaceBSplineLastUKnotIndex).
Surface.bsplineFirstVKnotIndex
First V knot index of the BSpline surface.
public var bsplineFirstVKnotIndex: Int { get }
- OCCT:
Geom_BSplineSurface::FirstVKnotIndex(viaOCCTSurfaceBSplineFirstVKnotIndex).
Surface.bsplineLastVKnotIndex
Last V knot index of the BSpline surface.
public var bsplineLastVKnotIndex: Int { get }
- OCCT:
Geom_BSplineSurface::LastVKnotIndex(viaOCCTSurfaceBSplineLastVKnotIndex).
Surface.bsplineCheckAndSegment(u1:u2:v1:v2:uTolerance:vTolerance:)
Validate parameter ranges and segment the BSpline surface to [u1,u2] × [v1,v2].
@discardableResult
public func bsplineCheckAndSegment(u1: Double, u2: Double, v1: Double, v2: Double,
uTolerance: Double = 1e-10, vTolerance: Double = 1e-10) -> Bool
- OCCT:
Geom_BSplineSurface::CheckAndSegment(viaOCCTSurfaceBSplineCheckAndSegment).
Curve3D.bsplineSetNotPeriodic()
Remove periodicity from a 3D BSpline curve.
@discardableResult
public func bsplineSetNotPeriodic() -> Bool
- OCCT:
Geom_BSplineCurve::SetNotPeriodic(viaOCCTCurve3DBSplineSetNotPeriodic).
Curve3D.bsplineSetOrigin(index:)
Set the origin knot index (1-based) on a periodic 3D BSpline curve.
@discardableResult
public func bsplineSetOrigin(index: Int) -> Bool
- OCCT:
Geom_BSplineCurve::SetOrigin(viaOCCTCurve3DBSplineSetOrigin).
Curve3D.bsplineIncreaseMultiplicity(index:multiplicity:)
Increase the multiplicity of knot at index to at least multiplicity (1-based).
@discardableResult
public func bsplineIncreaseMultiplicity(index: Int, multiplicity: Int) -> Bool
- OCCT:
Geom_BSplineCurve::IncreaseMultiplicity(viaOCCTCurve3DBSplineIncreaseMultiplicity).
Curve3D.bsplineIncrementMultiplicity(from:to:step:)
Increment multiplicity of all knots from from to to by step (1-based).
@discardableResult
public func bsplineIncrementMultiplicity(from: Int, to: Int, step: Int = 1) -> Bool
- OCCT:
Geom_BSplineCurve::IncrementMultiplicity(viaOCCTCurve3DBSplineIncrementMultiplicity).
Curve3D.bsplineSetKnots(_:)
Set all knot values at once; count must match NbKnots.
@discardableResult
public func bsplineSetKnots(_ knots: [Double]) -> Bool
- OCCT:
Geom_BSplineCurve::SetKnots(viaOCCTCurve3DBSplineSetKnots).
Curve3D.bsplineReverse()
Reverse the parameterization of this 3D BSpline curve in place.
@discardableResult
public func bsplineReverse() -> Bool
- OCCT:
Geom_BSplineCurve::Reverse(viaOCCTCurve3DBSplineReverse).
Curve3D.bsplineMovePointAndTangent(u:point:tangent:tolerance:poleRange:)
Move the point and tangent at parameter u on a 3D BSpline curve, adjusting poles within poleRange.
@discardableResult
public func bsplineMovePointAndTangent(u: Double, point: SIMD3<Double>, tangent: SIMD3<Double>,
tolerance: Double, poleRange: ClosedRange<Int>) -> Bool
- Parameters:
u— parameter value.point— desired 3D position atu.tangent— desired tangent direction atu.tolerance— geometric tolerance.poleRange— 1-based range of poles allowed to move.
- OCCT:
Geom_BSplineCurve::MovePointAndTangent(viaOCCTCurve3DBSplineMovePointAndTangent).
Curve2D.bsplineSetNotPeriodic()
Remove periodicity from a 2D BSpline curve.
@discardableResult
public func bsplineSetNotPeriodic() -> Bool
- OCCT:
Geom2d_BSplineCurve::SetNotPeriodic(viaOCCTCurve2DBSplineSetNotPeriodic).
Curve2D.bsplineSetOrigin(index:)
Set the origin knot index (1-based) on a periodic 2D BSpline curve.
@discardableResult
public func bsplineSetOrigin(index: Int) -> Bool
- OCCT:
Geom2d_BSplineCurve::SetOrigin(viaOCCTCurve2DBSplineSetOrigin).
Curve2D.bsplineIncreaseMultiplicity(index:multiplicity:)
Increase the multiplicity of knot at index to at least multiplicity (1-based).
@discardableResult
public func bsplineIncreaseMultiplicity(index: Int, multiplicity: Int) -> Bool
- OCCT:
Geom2d_BSplineCurve::IncreaseMultiplicity(viaOCCTCurve2DBSplineIncreaseMultiplicity).
Curve2D.bsplineIncrementMultiplicity(from:to:step:)
Increment multiplicity of all knots from from to to by step (1-based).
@discardableResult
public func bsplineIncrementMultiplicity(from: Int, to: Int, step: Int = 1) -> Bool
- OCCT:
Geom2d_BSplineCurve::IncrementMultiplicity(viaOCCTCurve2DBSplineIncrementMultiplicity).
Curve2D.bsplineSetKnots(_:)
Set all knot values at once; count must match NbKnots.
@discardableResult
public func bsplineSetKnots(_ knots: [Double]) -> Bool
- OCCT:
Geom2d_BSplineCurve::SetKnots(viaOCCTCurve2DBSplineSetKnots).
Curve2D.bsplineReverse()
Reverse the parameterization of this 2D BSpline curve in place.
@discardableResult
public func bsplineReverse() -> Bool
- OCCT:
Geom2d_BSplineCurve::Reverse(viaOCCTCurve2DBSplineReverse).
Curve2D.bsplineMovePointAndTangent(u:point:tangent:tolerance:poleRange:)
Move the point and tangent at parameter u on a 2D BSpline curve.
@discardableResult
public func bsplineMovePointAndTangent(u: Double, point: SIMD2<Double>, tangent: SIMD2<Double>,
tolerance: Double, poleRange: ClosedRange<Int>) -> Bool
- Parameters:
pointandtangentare 2D here (unlike theCurve3Dvariant). - OCCT:
Geom2d_BSplineCurve::MovePointAndTangent(viaOCCTCurve2DBSplineMovePointAndTangent).
FilletBuilder
Builder for applying rounded fillets to selected edges of a solid, wrapping BRepFilletAPI_MakeFillet.
FilletBuilder.init?(shape:)
Create a fillet builder on the given shape.
public init?(shape: Shape)
- Parameters:
shape— the solid or shell to fillet. - Returns:
nilif the bridge cannot initialise the builder for this shape. - OCCT:
BRepFilletAPI_MakeFillet(viaOCCTFilletBuilderCreate). - Example:
guard let box = Shape.box(width: 20, height: 20, depth: 20), let builder = FilletBuilder(shape: box) else { return } for edge in box.edges() { _ = builder.addEdge(edge, radius: 2.0) } if let filleted = builder.build() { print("filleted shape valid:", filleted.isValid) }
FilletBuilder.addEdge(_:radius:)
Add an edge with a constant fillet radius.
@discardableResult
public func addEdge(_ edge: Edge, radius: Double) -> Bool
- Parameters:
edge— the edge to fillet;radius— constant fillet radius (> 0). - OCCT:
BRepFilletAPI_MakeFillet::Add(viaOCCTFilletBuilderAddEdge).
FilletBuilder.addEdge(_:radius1:radius2:)
Add an edge with an evolving fillet radius (r1 at the start vertex, r2 at the end vertex).
@discardableResult
public func addEdge(_ edge: Edge, radius1: Double, radius2: Double) -> Bool
- OCCT:
BRepFilletAPI_MakeFillet::Addwith two radii (viaOCCTFilletBuilderAddEdgeEvolving).
FilletBuilder.build()
Build the filleted result shape.
public func build() -> Shape?
- Returns: The filleted solid, or
nilif no edges have been added or all contours failed. - Note: Check
hasResultfirst when a partial result is acceptable. - OCCT:
BRepFilletAPI_MakeFillet::Shape(viaOCCTFilletBuilderBuild).
FilletBuilder.contourCount
Number of contours registered in the builder.
public var contourCount: Int { get }
- OCCT:
BRepFilletAPI_MakeFillet::NbContours(viaOCCTFilletBuilderNbContours).
FilletBuilder.edgeCount(contour:)
Number of edges in a contour (1-based index).
public func edgeCount(contour: Int) -> Int
- OCCT:
BRepFilletAPI_MakeFillet::NbEdges(viaOCCTFilletBuilderNbEdges).
FilletBuilder.hasResult
Whether the builder has a result — may be a partial result even if some contours failed.
public var hasResult: Bool { get }
- OCCT:
BRepFilletAPI_MakeFillet::HasResult(viaOCCTFilletBuilderHasResult).
FilletBuilder.badShape
The shape that caused failure (if any).
public var badShape: Shape? { get }
- Returns: The problematic sub-shape, or
nilif no failure has been recorded. - OCCT:
BRepFilletAPI_MakeFillet::BadShape(viaOCCTFilletBuilderBadShape).
FilletBuilder.faultyContourCount
Number of faulty contours after a build attempt.
public var faultyContourCount: Int { get }
- OCCT:
BRepFilletAPI_MakeFillet::NbFaultyContours(viaOCCTFilletBuilderNbFaultyContours).
FilletBuilder.faultyVertexCount
Number of faulty vertices after a build attempt.
public var faultyVertexCount: Int { get }
- OCCT:
BRepFilletAPI_MakeFillet::NbFaultyVertices(viaOCCTFilletBuilderNbFaultyVertices).
FilletBuilder.radius(contour:)
Get the radius of a contour (1-based index).
public func radius(contour: Int) -> Double
- OCCT:
BRepFilletAPI_MakeFillet::GetFilletShape/ radius query (viaOCCTFilletBuilderGetRadius).
FilletBuilder.length(contour:)
Get the length of a contour (1-based index).
public func length(contour: Int) -> Double
- OCCT:
BRepFilletAPI_MakeFillet::Length(viaOCCTFilletBuilderGetLength).
FilletBuilder.isConstant(contour:)
Whether a contour has a constant radius (1-based index).
public func isConstant(contour: Int) -> Bool
- OCCT:
BRepFilletAPI_MakeFillet::IsConstant(viaOCCTFilletBuilderIsConstant).
FilletBuilder.removeEdge(_:)
Remove an edge from its contour.
@discardableResult
public func removeEdge(_ edge: Edge) -> Bool
- OCCT:
BRepFilletAPI_MakeFillet::Remove(viaOCCTFilletBuilderRemoveEdge).
FilletBuilder.reset()
Reset all contours, clearing all registered edges.
public func reset()
- OCCT:
BRepFilletAPI_MakeFillet::Reset(viaOCCTFilletBuilderReset).
ChamferBuilder
Builder for applying chamfers to selected edges of a solid, wrapping BRepFilletAPI_MakeChamfer.
ChamferBuilder.init?(shape:)
Create a chamfer builder on the given shape.
public init?(shape: Shape)
- OCCT:
BRepFilletAPI_MakeChamfer(viaOCCTChamferBuilderCreate). - Example:
guard let box = Shape.box(width: 10, height: 10, depth: 10), let builder = ChamferBuilder(shape: box) else { return } for edge in box.edges() { _ = builder.addEdge(edge, distance: 1.0) } if let chamfered = builder.build() { print("valid:", chamfered.isValid) }
ChamferBuilder.addEdge(_:distance:)
Add an edge with a symmetric chamfer distance.
@discardableResult
public func addEdge(_ edge: Edge, distance: Double) -> Bool
- OCCT:
BRepFilletAPI_MakeChamfer::Add(viaOCCTChamferBuilderAddEdge).
ChamferBuilder.addEdge(_:face:distance1:distance2:)
Add an edge with two distances (requires a face for orientation).
@discardableResult
public func addEdge(_ edge: Edge, face: Face, distance1: Double, distance2: Double) -> Bool
- Parameters:
face— adjacent face that determines which side getsdistance1. - OCCT:
BRepFilletAPI_MakeChamfer::Addwith two distances (viaOCCTChamferBuilderAddEdgeTwoDists).
ChamferBuilder.addEdge(_:face:distance:angle:)
Add an edge with a distance and angle (requires a face for orientation).
@discardableResult
public func addEdge(_ edge: Edge, face: Face, distance: Double, angle: Double) -> Bool
- Parameters:
angle— chamfer angle in radians. - OCCT:
BRepFilletAPI_MakeChamfer::AddDA(viaOCCTChamferBuilderAddEdgeDistAngle).
ChamferBuilder.build()
Build the chamfered result shape.
public func build() -> Shape?
- Returns: The chamfered solid, or
nilon failure. - OCCT:
BRepFilletAPI_MakeChamfer::Shape(viaOCCTChamferBuilderBuild).
ChamferBuilder.contourCount
Number of contours registered in the builder.
public var contourCount: Int { get }
- OCCT:
BRepFilletAPI_MakeChamfer::NbContours(viaOCCTChamferBuilderNbContours).
ChamferBuilder.isDistanceAngle(contour:)
Whether a contour uses distance-angle mode (1-based index).
public func isDistanceAngle(contour: Int) -> Bool
- OCCT:
BRepFilletAPI_MakeChamfer::IsDistAngle(viaOCCTChamferBuilderIsDistAngle).
ChamferBuilder completions
Additional inspection and mutation methods on ChamferBuilder.
ChamferBuilder.edgeCount(contour:)
Number of edges in a contour (1-based index).
public func edgeCount(contour: Int) -> Int
- OCCT:
BRepFilletAPI_MakeChamfer::NbEdges(viaOCCTChamferBuilderNbEdges).
ChamferBuilder.getDistance(contour:)
Get the symmetric chamfer distance for a contour (1-based).
public func getDistance(contour: Int) -> Double
- Returns: The distance, or
-1.0if not set. - OCCT:
BRepFilletAPI_MakeChamfer::GetDist(viaOCCTChamferBuilderGetDist).
ChamferBuilder.getDistances(contour:)
Get the two distances for a contour (1-based).
public func getDistances(contour: Int) -> (d1: Double, d2: Double)
- Returns: Tuple of
(d1, d2); both-1.0if not set. - OCCT:
BRepFilletAPI_MakeChamfer::GetDists(viaOCCTChamferBuilderGetDists).
ChamferBuilder.getDistAngle(contour:)
Get the distance and angle for a contour (1-based).
public func getDistAngle(contour: Int) -> (distance: Double, angle: Double)
- Returns: Tuple of
(distance, angle); both-1.0if not set. - OCCT:
BRepFilletAPI_MakeChamfer::GetDistAngle(viaOCCTChamferBuilderGetDistAngle).
ChamferBuilder.setDistance(_:contour:face:)
Set symmetric distance on a contour (1-based, requires face for orientation).
@discardableResult
public func setDistance(_ dist: Double, contour: Int, face: Face) -> Bool
- OCCT:
BRepFilletAPI_MakeChamfer::SetDist(viaOCCTChamferBuilderSetDist).
ChamferBuilder.setDistances(_:_:contour:face:)
Set two distances on a contour (1-based, requires face for orientation).
@discardableResult
public func setDistances(_ d1: Double, _ d2: Double, contour: Int, face: Face) -> Bool
- OCCT:
BRepFilletAPI_MakeChamfer::SetDists(viaOCCTChamferBuilderSetDists).
ChamferBuilder.setDistAngle(distance:angle:contour:face:)
Set distance and angle on a contour (1-based, requires face for orientation).
@discardableResult
public func setDistAngle(distance: Double, angle: Double, contour: Int, face: Face) -> Bool
- OCCT:
BRepFilletAPI_MakeChamfer::SetDistAngle(viaOCCTChamferBuilderSetDistAngle).
ChamferBuilder.length(contour:)
Length of a contour (1-based).
public func length(contour: Int) -> Double
- OCCT:
BRepFilletAPI_MakeChamfer::Length(viaOCCTChamferBuilderLength).
ChamferBuilder.removeEdge(_:)
Remove the contour containing the given edge.
@discardableResult
public func removeEdge(_ edge: Edge) -> Bool
- OCCT:
BRepFilletAPI_MakeChamfer::Remove(viaOCCTChamferBuilderRemoveEdge).
ChamferBuilder.reset()
Reset all contours, canceling the effects of a previous build.
public func reset()
- OCCT:
BRepFilletAPI_MakeChamfer::Reset(viaOCCTChamferBuilderReset).
ChamferBuilder.isClosed(contour:)
Whether a contour (1-based) is closed.
public func isClosed(contour: Int) -> Bool
- OCCT:
BRepFilletAPI_MakeChamfer::Closed(viaOCCTChamferBuilderClosed).
ChamferBuilder.isClosedAndTangent(contour:)
Whether a contour (1-based) is closed and tangent at closure.
public func isClosedAndTangent(contour: Int) -> Bool
- OCCT:
BRepFilletAPI_MakeChamfer::ClosedAndTangent(viaOCCTChamferBuilderClosedAndTangent).
ChamferBuilder.isSymmetric(contour:)
Whether a contour (1-based) uses a symmetric (single-distance) chamfer.
public func isSymmetric(contour: Int) -> Bool
- OCCT:
BRepFilletAPI_MakeChamfer::IsSymmetric(viaOCCTChamferBuilderIsSymmetric).
ChamferBuilder.isTwoDistances(contour:)
Whether a contour (1-based) uses the two-distance mode.
public func isTwoDistances(contour: Int) -> Bool
- OCCT:
BRepFilletAPI_MakeChamfer::IsTwoDists(viaOCCTChamferBuilderIsTwoDists).
ChamferBuilder.edge(contour:index:)
Get edge index in contour contour (both 1-based) as a Shape.
public func edge(contour: Int, index: Int) -> Shape?
- Returns: The edge as a
Shape, ornilif the indices are out of range. - OCCT:
BRepFilletAPI_MakeChamfer::Edge(viaOCCTChamferBuilderEdge).
ChamferBuilder.firstVertex(contour:)
Get the first vertex of a contour (1-based) as a Shape.
public func firstVertex(contour: Int) -> Shape?
- OCCT:
BRepFilletAPI_MakeChamfer::FirstVertex(viaOCCTChamferBuilderFirstVertex).
ChamferBuilder.lastVertex(contour:)
Get the last vertex of a contour (1-based) as a Shape.
public func lastVertex(contour: Int) -> Shape?
- OCCT:
BRepFilletAPI_MakeChamfer::LastVertex(viaOCCTChamferBuilderLastVertex).
ChamferBuilder.contour(for:)
Get the contour index for an edge (returns 0 if not found).
public func contour(for edge: Edge) -> Int
- OCCT:
BRepFilletAPI_MakeChamfer::Contour(viaOCCTChamferBuilderContour).
ChamferBuilder.abscissa(contour:vertex:)
Curvilinear abscissa of a vertex on a contour (1-based).
public func abscissa(contour: Int, vertex: Shape) -> Double
- OCCT:
BRepFilletAPI_MakeChamfer::Abscissa(viaOCCTChamferBuilderAbscissa).
ChamferBuilder.relativeAbscissa(contour:vertex:)
Relative abscissa (0–1) of a vertex on a contour (1-based).
public func relativeAbscissa(contour: Int, vertex: Shape) -> Double
- OCCT:
BRepFilletAPI_MakeChamfer::RelativeAbscissa(viaOCCTChamferBuilderRelativeAbscissa).
FilletBuilder completions
Additional inspection and mutation methods on FilletBuilder.
FilletBuilder.setRadius(_:contour:edge:)
Set a radius on a specific edge in a contour (1-based).
@discardableResult
public func setRadius(_ radius: Double, contour: Int, edge: Edge) -> Bool
- OCCT:
BRepFilletAPI_MakeFillet::SetRadiuson edge (viaOCCTFilletBuilderSetRadiusOnEdge).
FilletBuilder.setRadius(_:contour:vertex:)
Set a radius at a specific vertex in a contour (1-based).
@discardableResult
public func setRadius(_ radius: Double, contour: Int, vertex: Shape) -> Bool
- OCCT:
BRepFilletAPI_MakeFillet::SetRadiusat vertex (viaOCCTFilletBuilderSetRadiusAtVertex).
FilletBuilder.setTwoRadii(_:_:contour:edgeInContour:)
Set two evolving radii on a specific edge in a contour (both 1-based).
@discardableResult
public func setTwoRadii(_ r1: Double, _ r2: Double, contour: Int, edgeInContour: Int) -> Bool
- OCCT:
BRepFilletAPI_MakeFillet::SetRadiustwo-radius variant (viaOCCTFilletBuilderSetTwoRadii).
FilletBuilder.contour(for:)
Get the contour index for an edge (returns 0 if not found).
public func contour(for edge: Edge) -> Int
- OCCT:
BRepFilletAPI_MakeFillet::Contour(viaOCCTFilletBuilderContour).
FilletBuilder.edge(contour:index:)
Get edge index in contour contour (both 1-based) as a Shape.
public func edge(contour: Int, index: Int) -> Shape?
- OCCT:
BRepFilletAPI_MakeFillet::Edge(viaOCCTFilletBuilderEdge).
FilletBuilder.firstVertex(contour:)
Get the first vertex of a contour (1-based) as a Shape.
public func firstVertex(contour: Int) -> Shape?
- OCCT:
BRepFilletAPI_MakeFillet::FirstVertex(viaOCCTFilletBuilderFirstVertex).
FilletBuilder.lastVertex(contour:)
Get the last vertex of a contour (1-based) as a Shape.
public func lastVertex(contour: Int) -> Shape?
- OCCT:
BRepFilletAPI_MakeFillet::LastVertex(viaOCCTFilletBuilderLastVertex).
FilletBuilder.abscissa(contour:vertex:)
Curvilinear abscissa of a vertex on a contour (1-based).
public func abscissa(contour: Int, vertex: Shape) -> Double
- OCCT:
BRepFilletAPI_MakeFillet::Abscissa(viaOCCTFilletBuilderAbscissa).
FilletBuilder.relativeAbscissa(contour:vertex:)
Relative abscissa (0–1) of a vertex on a contour (1-based).
public func relativeAbscissa(contour: Int, vertex: Shape) -> Double
- OCCT:
BRepFilletAPI_MakeFillet::RelativeAbscissa(viaOCCTFilletBuilderRelativeAbscissa).
FilletBuilder.isClosedAndTangent(contour:)
Whether a contour (1-based) is closed and tangent at its closure.
public func isClosedAndTangent(contour: Int) -> Bool
- OCCT:
BRepFilletAPI_MakeFillet::ClosedAndTangent(viaOCCTFilletBuilderClosedAndTangent).
FilletBuilder.isClosed(contour:)
Whether a contour (1-based) is closed.
public func isClosed(contour: Int) -> Bool
- OCCT:
BRepFilletAPI_MakeFillet::Closed(viaOCCTFilletBuilderClosed).
FilletBuilder.surfaceCount
Number of fillet surfaces computed after build.
public var surfaceCount: Int { get }
- OCCT:
BRepFilletAPI_MakeFillet::NbSurfaces(viaOCCTFilletBuilderNbSurfaces).
FilletBuilder.computedSurfaceCount(contour:)
Number of computed fillet surfaces for a contour (1-based).
public func computedSurfaceCount(contour: Int) -> Int
- OCCT:
BRepFilletAPI_MakeFillet::NbComputedSurfaces(viaOCCTFilletBuilderNbComputedSurfaces).
FilletBuilder.stripeStatus(contour:)
Error status for a contour (1-based), returned as ChFiDS_ErrorStatus encoded as Int.
public func stripeStatus(contour: Int) -> Int
- Returns:
0= no error; other values correspond toChFiDS_ErrorStatusenumerators. - OCCT:
BRepFilletAPI_MakeFillet::StripeStatus(viaOCCTFilletBuilderStripeStatus).
FilletBuilder.faultyContour(index:)
Get the faulty contour index for the i-th fault (1-based).
public func faultyContour(index: Int) -> Int
- OCCT:
BRepFilletAPI_MakeFillet::FaultyContour(viaOCCTFilletBuilderFaultyContour).
FilletBuilder.faultyVertex(index:)
Get the faulty vertex for the i-th fault (1-based).
public func faultyVertex(index: Int) -> Shape?
- OCCT:
BRepFilletAPI_MakeFillet::FaultyVertex(viaOCCTFilletBuilderFaultyVertex).
WireAnalyzer
Analyzer for wire geometry and topology, wrapping ShapeAnalysis_Wire.
WireAnalyzer.init?(wire:face:precision:)
Create a wire analyzer from a wire shape, a face it lies on, and precision.
public init?(wire: Wire, face: Shape, precision: Double = 1e-7)
- Parameters:
wire— the wire to analyse.face— the face context (used for 2D checks).precision— geometric precision (default1e-7).
- Returns:
nilif initialisation fails. - OCCT:
ShapeAnalysis_Wire(viaOCCTWireAnalyzerCreate). - Example:
if let face = Shape.box(width: 10, height: 10, depth: 1)?.faces().first, let wire = Wire.rectangle(width: 5, height: 5), let analyzer = WireAnalyzer(wire: wire, face: face) { _ = analyzer.perform() print("self-intersects:", analyzer.checkSelfIntersection()) }
WireAnalyzer.perform()
Run all checks (order, small, connected, degenerated, self-intersection, lacking, closed).
public func perform() -> Bool
- Returns:
trueif all checks pass. - OCCT:
ShapeAnalysis_Wire::Perform(viaOCCTWireAnalyzerPerform).
WireAnalyzer.checkOrder()
Check edge ordering (each edge’s start matches the previous edge’s end).
public func checkOrder() -> Bool
- OCCT:
ShapeAnalysis_Wire::CheckOrder(viaOCCTWireAnalyzerCheckOrder).
WireAnalyzer.checkConnected(edgeNum:)
Check if edge edgeNum (1-based) is connected to the previous one.
public func checkConnected(edgeNum: Int) -> Bool
- OCCT:
ShapeAnalysis_Wire::CheckConnected(viaOCCTWireAnalyzerCheckConnected).
WireAnalyzer.checkSmall(edgeNum:)
Check if edge edgeNum (1-based) is degenerate-small (shorter than precision).
public func checkSmall(edgeNum: Int) -> Bool
- OCCT:
ShapeAnalysis_Wire::CheckSmall(viaOCCTWireAnalyzerCheckSmall).
WireAnalyzer.checkDegenerated(edgeNum:)
Check if edge edgeNum (1-based) is topologically degenerated.
public func checkDegenerated(edgeNum: Int) -> Bool
- OCCT:
ShapeAnalysis_Wire::CheckDegenerated(viaOCCTWireAnalyzerCheckDegenerated).
WireAnalyzer.checkGap3d(edgeNum:)
Check for a 3D gap at edge edgeNum (1-based; pass 0 to check all edges).
public func checkGap3d(edgeNum: Int = 0) -> Bool
- OCCT:
ShapeAnalysis_Wire::CheckGap3d(viaOCCTWireAnalyzerCheckGap3d).
WireAnalyzer.checkGap2d(edgeNum:)
Check for a 2D gap at edge edgeNum (1-based; pass 0 to check all edges).
public func checkGap2d(edgeNum: Int = 0) -> Bool
- OCCT:
ShapeAnalysis_Wire::CheckGap2d(viaOCCTWireAnalyzerCheckGap2d).
WireAnalyzer.checkSeam(edgeNum:)
Check if edge edgeNum (1-based) is a seam edge.
public func checkSeam(edgeNum: Int) -> Bool
- OCCT:
ShapeAnalysis_Wire::CheckSeam(viaOCCTWireAnalyzerCheckSeam).
WireAnalyzer.checkLacking(edgeNum:)
Check if edge edgeNum (1-based) is lacking (missing a 2D curve on the face).
public func checkLacking(edgeNum: Int) -> Bool
- OCCT:
ShapeAnalysis_Wire::CheckLacking(viaOCCTWireAnalyzerCheckLacking).
WireAnalyzer.checkSelfIntersection()
Check whether the wire self-intersects.
public func checkSelfIntersection() -> Bool
- OCCT:
ShapeAnalysis_Wire::CheckSelfIntersection(viaOCCTWireAnalyzerCheckSelfIntersection).
WireAnalyzer.checkClosed()
Check whether the wire is topologically closed.
public func checkClosed() -> Bool
- OCCT:
ShapeAnalysis_Wire::CheckClosed(viaOCCTWireAnalyzerCheckClosed).
WireAnalyzer.minDistance3d
The minimum 3D gap distance found across all checked edges.
public var minDistance3d: Double { get }
- OCCT:
ShapeAnalysis_Wire::MinDistance3d(viaOCCTWireAnalyzerMinDistance3d).
WireAnalyzer.maxDistance3d
The maximum 3D gap distance found across all checked edges.
public var maxDistance3d: Double { get }
- OCCT:
ShapeAnalysis_Wire::MaxDistance3d(viaOCCTWireAnalyzerMaxDistance3d).
WireAnalyzer.edgeCount
Number of edges in the wire.
public var edgeCount: Int { get }
- OCCT:
ShapeAnalysis_Wire::NbEdges(viaOCCTWireAnalyzerNbEdges).
WireAnalyzer.isLoaded
Whether the wire is loaded into the analyzer.
public var isLoaded: Bool { get }
- OCCT:
ShapeAnalysis_Wire::IsLoaded(viaOCCTWireAnalyzerIsLoaded).
WireAnalyzer.isReady
Whether the analyzer is ready (wire and face both loaded).
public var isReady: Bool { get }
- OCCT:
ShapeAnalysis_Wire::IsReady(viaOCCTWireAnalyzerIsReady).
FilletBuilder completions (v0.126.0)
Advanced parameter and simulation controls for FilletBuilder.
FilletBuilder.setParams(tang:tesp:t2d:tApp3d:tApp2d:fleche:)
Set fillet tolerances for the builder.
public func setParams(tang: Double, tesp: Double, t2d: Double,
tApp3d: Double, tApp2d: Double, fleche: Double)
- Parameters:
tang— tangency tolerance;tesp— surface tolerance;t2d— 2D tolerance;tApp3d— 3D approximation tolerance;tApp2d— 2D approximation tolerance;fleche— sag for approximation. - OCCT:
BRepFilletAPI_MakeFillet::SetParams(viaOCCTFilletBuilderSetParams).
FilletBuilder.setContinuity(_:angularTolerance:)
Set the fillet surface continuity: 0=C0, 1=C1, 2=C2.
public func setContinuity(_ internalContinuity: Int, angularTolerance: Double)
- Parameters:
internalContinuity— target continuity class;angularTolerance— angular tolerance for the join. - OCCT:
BRepFilletAPI_MakeFillet::SetContinuity(viaOCCTFilletBuilderSetContinuity).
FilletBuilder.setFilletShape(_:)
Set the fillet shape type: 0=Rational, 1=QuasiAngular, 2=Polynomial.
public func setFilletShape(_ filletShape: Int)
- OCCT:
BRepFilletAPI_MakeFillet::SetFilletShape(viaOCCTFilletBuilderSetFilletShape).
FilletBuilder.filletShape
Get the current fillet shape type: 0=Rational, 1=QuasiAngular, 2=Polynomial.
public var filletShape: Int { get }
- OCCT:
BRepFilletAPI_MakeFillet::GetFilletShape(viaOCCTFilletBuilderGetFilletShape).
FilletBuilder.resetContour(_:)
Reset radius info on a specific contour (1-based).
public func resetContour(_ contourIndex: Int)
- OCCT:
BRepFilletAPI_MakeFillet::ResetContour(viaOCCTFilletBuilderResetContour).
FilletBuilder.simulate(contour:)
Simulate filleting on a contour — computes cross-sections without building the final shape.
public func simulate(contour: Int)
- Parameters:
contour— 1-based contour index. - OCCT:
BRepFilletAPI_MakeFillet::Simulate(viaOCCTFilletBuilderSimulate).
FilletBuilder.simulatedSurfaceCount(contour:)
Get the number of simulated surfaces for a contour (1-based) after simulate(contour:).
public func simulatedSurfaceCount(contour: Int) -> Int
- OCCT:
BRepFilletAPI_MakeFillet::NbSimulatedSurf(viaOCCTFilletBuilderNbSimulatedSurf). - Example:
guard let box = Shape.box(width: 30, height: 30, depth: 30), let builder = FilletBuilder(shape: box) else { return } let edge = box.edges().first! _ = builder.addEdge(edge, radius: 3.0) builder.simulate(contour: 1) print("simulated sections:", builder.simulatedSurfaceCount(contour: 1))
GLTF Import/Export
glTF/GLB import on Shape and Document, plus glTF/GLB export on Exporter and Document.
Shape.loadGLTF(fromPath:)
Load a shape from a glTF or GLB file path.
public static func loadGLTF(fromPath path: String) -> Shape?
- Parameters:
path— file system path to a.gltfor.glbfile. - Returns: The imported shape, or
nilon failure. - OCCT:
RWGltf_CafReader(viaOCCTImportGLTF). - Note: Colors and materials are not preserved; use
Document.loadGLTF(fromPath:)to retain those.
Shape.loadGLTF(from:)
Load a shape from a glTF or GLB file URL.
public static func loadGLTF(from url: URL) -> Shape?
- OCCT:
RWGltf_CafReader(viaOCCTImportGLTF). - Example:
let url = URL(fileURLWithPath: "/tmp/model.glb") if let shape = Shape.loadGLTF(from: url) { print("loaded shape valid:", shape.isValid) }
Exporter.writeGLTF(shape:to:binary:deflection:)
Export a shape to glTF or GLB format.
public static func writeGLTF(shape: Shape, to url: URL, binary: Bool = true, deflection: Double = 0.1) throws
- Parameters:
shape— shape to export (meshed internally by the bridge).url— output file URL (.gltfor.glb).binary—truewrites binary GLB;falsewrites text glTF.deflection— mesh linear deflection tolerance.
- Throws:
Exporter.ExportError.exportFailedif writing fails. - OCCT:
RWGltf_CafWriter(viaOCCTExportGLTF). - Example:
guard let box = Shape.box(width: 10, height: 10, depth: 10) else { return } let out = URL(fileURLWithPath: "/tmp/box.glb") try Exporter.writeGLTF(shape: box, to: out, binary: true, deflection: 0.05)
Document.loadGLTF(fromPath:)
Load a glTF or GLB file into an XDE document, preserving names, materials, and colors.
public static func loadGLTF(fromPath path: String) -> Document?
- Parameters:
path— file system path to a.gltfor.glbfile. - Returns: A
Documentwith the assembly hierarchy, ornilon failure. - OCCT:
RWGltf_CafReaderintoTDocStd_Document(viaOCCTDocumentLoadGLTF).
Document.loadGLTF(from:)
Load a glTF or GLB file URL into an XDE document.
public static func loadGLTF(from url: URL) -> Document?
- OCCT:
RWGltf_CafReader(viaOCCTDocumentLoadGLTF). - Example:
let url = URL(fileURLWithPath: "/tmp/model.glb") if let doc = Document.loadGLTF(from: url) { for node in doc.rootNodes { print(node.name ?? "<unnamed>") } }
Document.writeGLTF(to:binary:)
Write this XDE document to glTF or GLB format.
public func writeGLTF(to url: URL, binary: Bool = true) -> Bool
- Parameters:
url— output file URL (.gltfor.glb).binary—truewrites binary GLB;falsewrites text glTF.
- Returns:
trueif the file was written successfully. - OCCT:
RWGltf_CafWriter(viaOCCTDocumentWriteGLTF). - Example:
let doc = try Document.load(from: stepURL) let glb = URL(fileURLWithPath: "/tmp/out.glb") if doc.writeGLTF(to: glb) { print("exported GLB to", glb.path) }