Shape — HLR, Intervals, Mesh Props & Geom Primitives
This page documents the v0.73 / v0.76 batch of Shape-adjacent APIs covering hidden-line removal, interval arithmetic, curve/surface/ray intersection, mesh properties, geometric inertia, and the standalone Geom_* entity wrappers. See the main Shape type page for the primary Shape class (constructors, transforms, booleans, etc.).
Topics
- v0.73.0: TKHlr — Extended HLR, ReflectLines, TopCnx, Intrv · Intrv_Interval (Interval with Tolerances) · Intrv_Intervals (Sorted Non-Overlapping Interval Sequence) · ShapeRayIntersection (BRepIntCurveSurface_Inter) · ShapeConstruct (Triangulation) · Surface Extensions (ShapeCustom_Surface periodic + gap) · MeshCinert (Linear Mass Properties from Mesh) · MeshProps (Surface/Volume Properties from Mesh) · MeshShapeTool (Static Mesh Utilities) · ValidateEdge (BRepLib_ValidateEdge) · BiTgte_Blend (Rolling-Ball Blend) · GeomConvert_ApproxCurve/Surface · GCPnts_QuasiUniformAbscissa · GCPnts_TangentialDeflection · BRepGProp_Cinert (Curve Inertia per Edge) · BRepGProp_Sinert (Surface Inertia per Face) · BRepGProp_Vinert (Volume Inertia per Face) · ShapeConstruct_ProjectCurveOnSurface · BRepPreviewAPI_MakeBox · GeomPoint3D (Geom_CartesianPoint) · GeomDirection (Geom_Direction) · GeomVector3D (Geom_VectorWithMagnitude) · Axis1Placement (Geom_Axis1Placement)
v0.73.0: TKHlr — Extended HLR, ReflectLines, TopCnx, Intrv
HLREdgeCategory
Fine-grained HLR edge categories for exact and polygon-based hidden line removal.
public enum HLREdgeCategory: Int32, Sendable {
case visibleSharp = 0
case visibleSmooth = 1
case visibleSewn = 2
case visibleOutline = 3
case visibleIso = 4
case visibleOutline3d = 5
case hiddenSharp = 6
case hiddenSmooth = 7
case hiddenSewn = 8
case hiddenOutline = 9
case hiddenIso = 10
}
Used with hlrEdges(direction:category:) and hlrPolyEdges(direction:category:deflection:) to select which edge class to extract. .visibleIso, .hiddenIso, and .visibleOutline3d are available for exact HLR only.
| Case | Edge class |
|---|---|
.visibleSharp | Visible C0-continuity (sharp) edges. |
.visibleSmooth | Visible G1-continuity (smooth) edges. |
.visibleSewn | Visible CN-continuity (sewn) edges. |
.visibleOutline | Visible silhouette/outline edges. |
.visibleIso | Visible isoparameter lines (exact HLR only). |
.visibleOutline3d | Visible outline edges in 3D (exact HLR only). |
.hiddenSharp | Hidden C0-continuity (sharp) edges. |
.hiddenSmooth | Hidden G1-continuity (smooth) edges. |
.hiddenSewn | Hidden CN-continuity (sewn) edges. |
.hiddenOutline | Hidden silhouette/outline edges. |
.hiddenIso | Hidden isoparameter lines (exact HLR only). |
HLREdgeCategory.hiddenIso
HLREdgeType
HLR result edge type for the generic CompoundOfEdges and ReflectLines APIs.
public enum HLREdgeType: Int32, Sendable {
case undefined = 0
case isoLine = 1
case outLine = 2
case rg1Line = 3
case rgNLine = 4
case sharp = 5
}
Used with hlrCompoundOfEdges(direction:edgeType:visible:in3d:) and the reflectLinesFiltered family. Case meanings, from HLRBRep_TypeOfResultingEdge:
HLREdgeType.isoLine
An isoparametric line.
HLREdgeType.outLine
An outline (silhouette) edge.
HLREdgeType.rg1Line
A smooth edge of G1 continuity between two surfaces.
HLREdgeType.rgNLine
A sewn edge of CN continuity on one surface.
HLREdgeType.sharp
A sharp edge, of C0 continuity.
hlrEdges(direction:category:)
Extracts edges by fine-grained category using exact HLR (hidden line removal).
public func hlrEdges(direction: SIMD3<Double>, category: HLREdgeCategory) -> Shape?
- Parameters:
direction— view direction vector;category— which class of edges to extract. - Returns: Compound of extracted edges, or
nilif none exist for that category. - OCCT:
HLRBRep_Algo/HLRBRep_HLRToShapeviaOCCTHLRGetEdgesByCategory. - Example:
if let edges = shape.hlrEdges(direction: SIMD3(0, 0, -1), category: .visibleSharp) { // edges is a compound of visible sharp edges in the -Z view }
hlrPolyEdges(direction:category:deflection:)
Extracts edges by fine-grained category using fast polygon-based (poly) HLR.
public func hlrPolyEdges(direction: SIMD3<Double>, category: HLREdgeCategory,
deflection: Double = 0.1) -> Shape?
Poly HLR projects the shape’s triangulation rather than its exact geometry, making it dramatically faster on curved solids (e.g. ~48× on an analytic helicoid). Prefer this for 2D drawings of threaded or curved parts. .visibleIso, .hiddenIso, and .visibleOutline3d are not available for poly HLR.
- Parameters:
direction— view direction vector.category— edge class to extract.deflection— linear mesh deflection (mm) for the internal triangulation. Smaller = finer drawing; larger = coarser and faster. Default0.1. Meshing is incremental: existing finer triangulations are not coarsened.
- Returns: Compound of extracted edges, or
nilif none exist. - OCCT:
HLRBRep_PolyAlgo/HLRBRep_PolyHLRToShapeviaOCCTHLRPolyGetEdgesByCategory. - Example:
if let vis = shape.hlrPolyEdges(direction: SIMD3(0, 0, -1), category: .visibleSharp, deflection: 0.05) { // vis contains visible sharp edges, finely meshed }
hlrCompoundOfEdges(direction:edgeType:visible:in3d:)
Extracts a compound of edges using the generic CompoundOfEdges API from exact HLR.
public func hlrCompoundOfEdges(direction: SIMD3<Double>, edgeType: HLREdgeType,
visible: Bool, in3d: Bool) -> Shape?
- Parameters:
direction— view direction vector.edgeType— edge type filter (HLREdgeType).visible—truefor visible edges,falsefor hidden.in3d—trueto return 3D edges;falsefor projected 2D edges.
- Returns: Compound of matching edges, or
nilon failure. - OCCT:
HLRBRep_HLRToShape::CompoundOfEdgesviaOCCTHLRCompoundOfEdges. - Example:
if let outlines = shape.hlrCompoundOfEdges(direction: SIMD3(0, 0, -1), edgeType: .outLine, visible: true, in3d: true) { // outlines contains the visible silhouette edges in 3D }
reflectLines(normal:viewPoint:up:)
Computes reflect (silhouette) lines on a shape for a given view.
public func reflectLines(normal: SIMD3<Double>, viewPoint: SIMD3<Double>,
up: SIMD3<Double>) -> Shape?
- Parameters:
normal— view plane normal direction.viewPoint— eye/target position.up— up direction for the view frame.
- Returns: Compound of reflect line edges in 3D, or
nilon failure. - OCCT:
HLRAppli_ReflectLinesviaOCCTHLRReflectLines. - Example:
if let silhouette = shape.reflectLines(normal: SIMD3(0, 0, 1), viewPoint: SIMD3(0, 0, 100), up: SIMD3(0, 1, 0)) { // silhouette is a compound of outline curves }
reflectLinesFiltered(normal:viewPoint:up:edgeType:visible:in3d:)
Computes reflect lines and filters the result by edge type and visibility.
public func reflectLinesFiltered(normal: SIMD3<Double>, viewPoint: SIMD3<Double>,
up: SIMD3<Double>, edgeType: HLREdgeType,
visible: Bool, in3d: Bool) -> Shape?
- Parameters:
normal— view plane normal direction.viewPoint— eye/target position.up— up direction.edgeType— edge type to extract.visible—truefor visible,falsefor hidden.in3d—truefor 3D edges,falsefor projected.
- Returns: Filtered compound of reflect line edges, or
nilon failure. - OCCT:
HLRAppli_ReflectLines/CompoundOfEdgesviaOCCTHLRReflectLinesFiltered.
EdgeFaceTransitionResult
Result of an edge-face transition computation.
public struct EdgeFaceTransitionResult: Sendable {
public let transition: Int // TopAbs_Orientation: 0=FORWARD, 1=REVERSED, 2=INTERNAL, 3=EXTERNAL
public let boundaryTransition: Int // TopAbs_Orientation for boundary
}
| Field | Meaning |
|---|---|
transition | Cumulated TopAbs_Orientation code (0=FORWARD, 1=REVERSED, 2=INTERNAL, 3=EXTERNAL) across all supplied faces. |
boundaryTransition | Cumulated TopAbs_Orientation code for the boundary transition across all supplied faces. |
Shape.EdgeFaceTransitionResult.boundaryTransition
FaceInterference
Face interference description passed to edgeFaceTransition(edgeTangent:edgeNormal:edgeCurvature:faces:).
public struct FaceInterference: Sendable {
public let tangent: SIMD3<Double>
public let normal: SIMD3<Double>
public let curvature: Double
public let orientation: Int32 // TopAbs_Orientation
public let transition: Int32 // TopAbs_Orientation
public let boundaryTransition: Int32 // TopAbs_Orientation
public let tolerance: Double
public init(tangent: SIMD3<Double>, normal: SIMD3<Double>, curvature: Double,
orientation: Int32, transition: Int32, boundaryTransition: Int32,
tolerance: Double)
}
| Field | Meaning |
|---|---|
transition | TopAbs_Orientation code for how the edge crosses this face at the interference point. |
boundaryTransition | TopAbs_Orientation code for how the edge crosses this face’s boundary. |
tolerance | Geometric tolerance for this face’s contribution to the interference test. |
Shape.FaceInterference.tolerance
Shape.edgeFaceTransition(edgeTangent:edgeNormal:edgeCurvature:faces:)
Computes the cumulated edge-face transition orientation for multiple face interferences on an edge.
public static func edgeFaceTransition(edgeTangent: SIMD3<Double>,
edgeNormal: SIMD3<Double>,
edgeCurvature: Double,
faces: [FaceInterference]) -> EdgeFaceTransitionResult
- Parameters:
edgeTangent— edge tangent direction.edgeNormal— edge normal direction (use.zerofor linear edges).edgeCurvature— edge curvature (0 for linear edges).faces— array ofFaceInterferencedescriptors.
- Returns:
EdgeFaceTransitionResultwith cumulatedtransitionandboundaryTransitionorientations. - OCCT:
TopCnx_EdgeFaceTransitionviaOCCTTopCnxEdgeFaceTransition.
Intrv_Interval (Interval with Tolerances)
Interval
A real interval [start, end] with optional per-endpoint tolerances, wrapping Intrv_Interval.
public final class Interval: @unchecked Sendable
Interval.init(start:end:tolStart:tolEnd:)
Creates an interval with bounds and optional tolerances.
public init(start: Double, end: Double, tolStart: Float = 0, tolEnd: Float = 0)
- Parameters:
start— lower bound;end— upper bound;tolStart— tolerance at start;tolEnd— tolerance at end. - OCCT:
Intrv_Interval(start, end, tolStart, tolEnd)viaOCCTIntrvIntervalCreate. - Example:
let iv = Interval(start: 0.0, end: 1.0, tolStart: 1e-6, tolEnd: 1e-6)
Interval.Bounds
The bounds and tolerances of an interval.
public struct Bounds: Sendable {
public let start: Double
public let end: Double
public let tolStart: Float
public let tolEnd: Float
}
Interval.Bounds.end
The interval’s end parameter.
Interval.Bounds.tolStart
Tolerance at the start parameter.
Interval.Bounds.tolEnd
Tolerance at the end parameter.
bounds
Gets the interval bounds and tolerances.
public var bounds: Bounds { get }
- Returns:
Boundsstruct withstart,end,tolStart,tolEnd. - OCCT:
Intrv_Interval::Start,End,TolStart,TolEndviaOCCTIntrvIntervalBounds.
isProbablyEmpty
Whether the interval is probably empty.
public var isProbablyEmpty: Bool { get }
- Returns:
trueifstart + tolStart > end - tolEnd. - OCCT:
Intrv_Interval::IsVoidviaOCCTIntrvIntervalIsProbablyEmpty.
position(relativeTo:)
Position of this interval relative to another.
public func position(relativeTo other: Interval) -> Int
- Parameters:
other— the reference interval. - Returns:
Intrv_Positionenum raw value (0 = Before … 12 = After). - OCCT:
Intrv_Interval::PositionviaOCCTIntrvIntervalPosition.
isBefore(_:)
Whether this interval is entirely before another.
public func isBefore(_ other: Interval) -> Bool
- OCCT:
Intrv_Interval::IsBeforeviaOCCTIntrvIntervalIsBefore.
isAfter(_:)
Whether this interval is entirely after another.
public func isAfter(_ other: Interval) -> Bool
- OCCT:
Intrv_Interval::IsAfterviaOCCTIntrvIntervalIsAfter.
isInside(_:)
Whether this interval is entirely inside another.
public func isInside(_ other: Interval) -> Bool
- OCCT:
Intrv_Interval::IsInsideviaOCCTIntrvIntervalIsInside.
isEnclosing(_:)
Whether this interval entirely encloses another.
public func isEnclosing(_ other: Interval) -> Bool
- OCCT:
Intrv_Interval::IsEnclosingviaOCCTIntrvIntervalIsEnclosing.
isSimilar(to:)
Whether this interval has the same bounds as another (within tolerances).
public func isSimilar(to other: Interval) -> Bool
- OCCT:
Intrv_Interval::IsSimilarviaOCCTIntrvIntervalIsSimilar.
setStart(_:tolerance:)
Sets the start bound.
public func setStart(_ start: Double, tolerance: Float = 0)
- Parameters:
start— new start value;tolerance— new start tolerance. - OCCT:
Intrv_Interval::SetStartviaOCCTIntrvIntervalSetStart.
setEnd(_:tolerance:)
Sets the end bound.
public func setEnd(_ end: Double, tolerance: Float = 0)
- Parameters:
end— new end value;tolerance— new end tolerance. - OCCT:
Intrv_Interval::SetEndviaOCCTIntrvIntervalSetEnd.
fuseAtStart(_:tolerance:)
Extends the start bound outward (union at start).
public func fuseAtStart(_ start: Double, tolerance: Float = 0)
- Parameters:
start— new start bound (must be ≤ current start to extend);tolerance— new tolerance. - OCCT:
Intrv_Interval::FuseAtStartviaOCCTIntrvIntervalFuseAtStart.
fuseAtEnd(_:tolerance:)
Extends the end bound outward (union at end).
public func fuseAtEnd(_ end: Double, tolerance: Float = 0)
- OCCT:
Intrv_Interval::FuseAtEndviaOCCTIntrvIntervalFuseAtEnd.
cutAtStart(_:tolerance:)
Trims the start bound inward.
public func cutAtStart(_ start: Double, tolerance: Float = 0)
- OCCT:
Intrv_Interval::CutAtStartviaOCCTIntrvIntervalCutAtStart.
cutAtEnd(_:tolerance:)
Trims the end bound inward.
public func cutAtEnd(_ end: Double, tolerance: Float = 0)
- OCCT:
Intrv_Interval::CutAtEndviaOCCTIntrvIntervalCutAtEnd.
Intrv_Intervals (Sorted Non-Overlapping Interval Sequence)
IntervalSet
A sorted sequence of non-overlapping Intrv_Interval objects supporting set-theoretic operations.
public final class IntervalSet: @unchecked Sendable
| Member | Kind | Meaning |
|---|---|---|
handle | public stored property | The opaque OCCTIntrvIntervalsRef this wrapper owns; released in deinit. |
IntervalSet.handle
IntervalSet.init(start:end:)
Creates an interval set containing a single interval.
public init(start: Double, end: Double)
- OCCT:
Intrv_Intervals(Intrv_Interval)viaOCCTIntrvIntervalsCreate. - Example:
let set = IntervalSet(start: 0.0, end: 10.0)
IntervalSet.init()
Creates an empty interval set.
public init()
- OCCT:
Intrv_Intervals()viaOCCTIntrvIntervalsCreateEmpty.
count
Number of non-overlapping intervals in the set.
public var count: Int { get }
- OCCT:
Intrv_Intervals::LengthviaOCCTIntrvIntervalsCount.
bounds(at:)
Gets the bounds of the interval at a zero-based index.
public func bounds(at index: Int) -> Interval.Bounds
- Parameters:
index— zero-based interval index (internally maps to 1-based OCCT indexing). - Returns:
Interval.Boundsfor that interval. - OCCT:
Intrv_Intervals::ValueviaOCCTIntrvIntervalsValue.
unite(start:end:)
Adds an interval to the set (union).
public func unite(start: Double, end: Double)
- OCCT:
Intrv_Intervals::UniteviaOCCTIntrvIntervalsUnite. - Example:
let set = IntervalSet(start: 0.0, end: 5.0) set.unite(start: 7.0, end: 10.0) // set now has two intervals: [0,5] and [7,10]
subtract(start:end:)
Subtracts an interval from the set.
public func subtract(start: Double, end: Double)
- OCCT:
Intrv_Intervals::SubtractviaOCCTIntrvIntervalsSubtract.
intersect(start:end:)
Intersects the set with an interval, keeping only the overlap.
public func intersect(start: Double, end: Double)
- OCCT:
Intrv_Intervals::IntersectviaOCCTIntrvIntervalsIntersect.
xUnite(start:end:)
Applies exclusive union (symmetric difference) with an interval.
public func xUnite(start: Double, end: Double)
- OCCT:
Intrv_Intervals::XUniteviaOCCTIntrvIntervalsXUnite.
ShapeRayIntersection (BRepIntCurveSurface_Inter)
ShapeRayIntersection
Iterator over line/curve–shape intersection results, wrapping BRepIntCurveSurface_Inter.
public final class ShapeRayIntersection: @unchecked Sendable
ShapeRayIntersection.Hit
A single intersection hit between the line/curve and a face.
public struct Hit {
public let x: Double, y: Double, z: Double // 3D intersection point
public let u: Double, v: Double // UV parameters on face surface
public let w: Double // parameter on the curve/line
}
| Field | Meaning |
|---|---|
x, y, z | The 3D intersection point. |
u, v | UV parameters of that point on the intersected face’s surface. |
w | Parameter of that point along the intersecting line or curve. |
ShapeRayIntersection.init?(shape:originX:originY:originZ:dirX:dirY:dirZ:tolerance:)
Creates an intersection of a line with a shape.
public init?(shape: Shape, originX: Double, originY: Double, originZ: Double,
dirX: Double, dirY: Double, dirZ: Double, tolerance: Double = 1e-6)
- Parameters:
shape— target B-Rep shape;originX/Y/Z— ray origin;dirX/Y/Z— ray direction;tolerance— intersection tolerance. - Returns:
nilif initialisation fails. - OCCT:
BRepIntCurveSurface_Inter::Init(shape, gp_Lin)viaOCCTCurveSurfaceInterCreateLine. - Example:
if let inter = ShapeRayIntersection(shape: box, originX: 0, originY: 0, originZ: -10, dirX: 0, dirY: 0, dirZ: 1) { let hits = inter.allHits() }
ShapeRayIntersection.init?(shape:curve:tolerance:)
Creates an intersection of a Curve3D with a shape.
public init?(shape: Shape, curve: Curve3D, tolerance: Double = 1e-6)
- Parameters:
shape— target shape;curve— 3D curve;tolerance— intersection tolerance. - Returns:
nilif initialisation fails. - OCCT:
BRepIntCurveSurface_Inter::Init(shape, curve)viaOCCTCurveSurfaceInterCreateCurve.
hasMore
Whether more intersection results are available for iteration.
public var hasMore: Bool { get }
- OCCT:
BRepIntCurveSurface_Inter::MoreviaOCCTCurveSurfaceInterMore.
next()
Advances to the next intersection result.
public func next()
- OCCT:
BRepIntCurveSurface_Inter::NextviaOCCTCurveSurfaceInterNext.
currentHit
Returns the current intersection hit data.
public var currentHit: Hit { get }
- Returns:
Hitwith 3D point, UV face parameters, and curve parameterw. - OCCT:
BRepIntCurveSurface_Inter::Pnt,UParameter,VParameter,WParameterviaOCCTCurveSurfaceInterHit.
currentFace
Returns the face at the current intersection.
public var currentFace: Face? { get }
- Returns: The
Facethat was hit, ornilon failure. - OCCT:
BRepIntCurveSurface_Inter::FaceviaOCCTCurveSurfaceInterFace.
allHits()
Collects all intersection hits by draining the iterator.
public func allHits() -> [Hit]
- Returns: Array of all
Hitvalues (may be empty if no intersections). - Note: Calling this exhausts the iterator —
hasMorewill befalseafterward. - Example:
if let inter = ShapeRayIntersection(shape: shape, originX: 0, originY: 0, originZ: 50, dirX: 0, dirY: 0, dirZ: -1) { for hit in inter.allHits() { print("hit at z=\(hit.z), u=\(hit.u), v=\(hit.v)") } }
ShapeConstruct (Triangulation)
Shape.triangulationFromPoints(_:)
Creates a triangulated face from a flat list of 3D points.
public static func triangulationFromPoints(_ points: [(Double, Double, Double)]) -> Shape?
- Parameters:
points— ordered list of 3D coordinate triples. - Returns: A triangulated
Shape(face), ornilon failure. - OCCT:
ShapeConstruct_MakeTriangulationviaOCCTShapeConstructTriangulationFromPoints. - Example:
let pts = [(0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.5, 1.0, 0.0)] if let tri = Shape.triangulationFromPoints(pts) { // tri is a triangulated face }
Shape.triangulationFromWire(_:)
Creates a triangulated face from a planar wire.
public static func triangulationFromWire(_ wire: Wire) -> Shape?
- Parameters:
wire— a closed planar wire to triangulate. - Returns: A triangulated
Shape, ornilon failure. - OCCT:
ShapeConstruct_MakeTriangulationviaOCCTShapeConstructTriangulationFromWire. - Example:
if let rect = Wire.rectangle(width: 10, height: 5), let tri = Shape.triangulationFromWire(rect) { // tri is a mesh of the rectangle }
Surface Extensions (ShapeCustom_Surface periodic + gap)
Surface.convertToPeriodic()
Converts a surface to periodic form.
public func convertToPeriodic() -> Surface?
- Returns: The periodified surface, or
nilif the surface is already periodic or cannot be converted. - OCCT:
ShapeCustom_Surface::ConvertToPeriodicviaOCCTSurfaceConvertToPeriodic. - Example:
if let periodic = surface.convertToPeriodic() { print(periodic.isUPeriodic) // true for converted cylinder/cone }
conversionGap
The distance between the original and periodically converted surface (conversion error).
public var conversionGap: Double { get }
- Returns: Gap value in model units; 0.0 if no conversion has been applied.
- OCCT:
ShapeCustom_Surface::GapviaOCCTSurfaceConversionGap.
MeshCinert (Linear Mass Properties from Mesh)
MeshCinertResult
Result of linear mass property computation from polygon points.
centerOfMass is nil when mass is 0, which covers a polygon of fewer than two points and one whose points are all coincident. The three separate centerX/centerY/centerZ fields it replaced could not express “no centroid”, and reported (0,0,0) instead (#609).
public struct MeshCinertResult {
public let mass: Double
public let centerOfMass: SIMD3<Double>?
}
Edge.meshPolygonPoints()
Prepares polygon points from a meshed edge for use with meshCinertCompute(points:).
public func meshPolygonPoints() -> [(Double, Double, Double)]
- Returns: Array of 3D coordinate triples from the edge’s mesh polygon (up to 1000 points).
- OCCT:
BRepGProp_MeshCinert::PreparePolygonviaOCCTMeshCinertPreparePolygon. - Example:
let pts = someEdge.meshPolygonPoints() let props = meshCinertCompute(points: pts)
meshCinertCompute(points:)
Computes linear mass properties (mass and centre of mass) from polygon point coordinates.
public func meshCinertCompute(points: [(Double, Double, Double)]) -> MeshCinertResult
This is a free function (not a method). Feed it the output of Edge.meshPolygonPoints().
- Parameters:
points— array of 3D coordinate triples. - Returns:
MeshCinertResultwithmass(total arc length) and centre coordinates. - OCCT:
BRepGProp_MeshCinert::PerformviaOCCTMeshCinertCompute.
MeshProps (Surface/Volume Properties from Mesh)
MeshPropsType
Selects the type of mesh property to compute.
public enum MeshPropsType {
case volume
case surface
}
MeshPropsResult
Result of mesh property computation.
public struct MeshPropsResult {
public let mass: Double
public let centerOfMass: SIMD3<Double>?
}
mass is surface area when type == .surface, or enclosed volume when type == .volume.
centerOfMass is nil when mass is 0, which covers both an untriangulated face and a volume contribution that cancels. The mass itself stays non-optional because a zero contribution is a real answer for a caller summing over a shell (#609).
Face.meshProps(type:)
Computes mesh surface or volume properties for a triangulated face.
public func meshProps(type: MeshPropsType) -> MeshPropsResult
- Parameters:
type—.surfacefor area and centroid,.volumefor enclosed volume and centroid. - Returns:
MeshPropsResultwith mass and centre of mass. - OCCT:
BRepGProp_MeshProps(Sinert/Vinert path) viaOCCTMeshPropsCompute. - Example:
let result = triangulatedFace.meshProps(type: .surface) print("area =", result.mass)
MeshShapeTool (Static Mesh Utilities)
Face.maxMeshTolerance
Maximum tolerance of edges and vertices on this face.
public var maxMeshTolerance: Double { get }
- Returns: Maximum tolerance in model units.
- OCCT:
BRepMesh_ShapeTool::MaxFaceToleranceviaOCCTMeshShapeToolMaxFaceTolerance.
Face.uvPoints(edge:)
Gets the UV parameter points of an edge on this face.
public func uvPoints(edge: Edge) -> (u1: Double, v1: Double, u2: Double, v2: Double)?
- Parameters:
edge— an edge that lies on this face. - Returns: Tuple of UV parameters at each end of the edge, or
nilif the edge is not on this face. - OCCT:
BRepMesh_ShapeTool::UVPointsviaOCCTMeshShapeToolUVPoints. - Example:
if let uv = face.uvPoints(edge: edge) { print("start UV: (\(uv.u1), \(uv.v1))") }
Shape.meshMaxDimension
Maximum dimension of this shape’s bounding box (useful for mesh sizing heuristics).
public var meshMaxDimension: Double { get }
- Returns: The largest of the bounding box width, height, and depth.
- OCCT:
BRepMesh_ShapeTool::BoxMaxDimensionviaOCCTMeshShapeToolBoxMaxDimension.
ValidateEdge (BRepLib_ValidateEdge)
ValidateEdgeResult
Result of 3D curve vs curve-on-surface consistency check.
public struct ValidateEdgeResult {
public let isDone: Bool
public let isWithinTolerance: Bool
public let maxDistance: Double
public let tolerance: Double
}
| Field | Meaning |
|---|---|
isWithinTolerance | true if the maximum deviation between the 3D curve and the curve-on-surface is within tolerance. |
maxDistance | Maximum measured deviation between the 3D curve and the curve-on-surface. |
tolerance | The tolerance value the check was run against. |
ValidateEdgeResult.tolerance
Edge.validate(on:tolerance:)
Validates edge geometry against a face (3D curve vs curve-on-surface consistency).
public func validate(on face: Face, tolerance: Double = 1e-3) -> ValidateEdgeResult
- Parameters:
face— the face containing this edge’s pcurve;tolerance— acceptable maximum deviation. - Returns:
ValidateEdgeResultwithisDone,isWithinTolerance,maxDistance, and the testedtolerance. - OCCT:
BRepLib_ValidateEdgeviaOCCTValidateEdge. - Example:
let result = edge.validate(on: face) if !result.isWithinTolerance { print("max deviation:", result.maxDistance) }
BiTgte_Blend (Rolling-Ball Blend)
Shape.biTgteBlend(edgeIndices:radius:tolerance:nubs:)
Creates a rolling-ball blend on specified edges using BiTgte_Blend.
public func biTgteBlend(edgeIndices: [Int], radius: Double, tolerance: Double = 1e-3,
nubs: Bool = false) -> Shape?
BiTgte_Blend is an alternative blend algorithm that can handle configurations where BRepFilletAPI_MakeFillet fails.
- Parameters:
edgeIndices— zero-based indices intoedges(), the same enumerationedge(at:)andEdge.indexuse, so a geometrically selected edge feeds straight in.radius— blend radius.tolerance— geometric tolerance.nubs— iftrue, outputs NUBS (Non-Uniform B-Spline) surfaces; iffalse, outputs NURBS.
- Returns: Blended shape, or
nilif blending fails — including when any index names no edge, which refuses the whole request rather than blending the rest (#568). - OCCT:
BiTgte_Blend::PerformviaOCCTBiTgteBlend. - Changed in #613: the indices addressed a
TopExp_Explorerwalk, one entry per topology occurrence (24 on a 12-edge box), notedges(). Measured on an L-bracket, no index reached the concave edge at all. An index naming no edge was also silently dropped. - Example:
// Blend the edges you selected, by index, not by position in a walk let seams = part.edges { $0.length > 20 } if let blended = part.biTgteBlend(edgeIndices: seams.map(\.index), radius: 2.0) { // blended has rounded seams }
GeomConvert_ApproxCurve/Surface
ApproxContinuity was one of several copies of the same continuity-floor vocabulary, deprecated in #398 as a typealias of ParametricContinuity (.c0 … .c3, no raw value moved), and removed at v2.0.0 (#784). Use ParametricContinuity directly.
ApproxCurveResult
Result of curve approximation including the output curve, error, and status.
public struct ApproxCurveResult {
public let curve: Curve3D?
public let maxError: Double
public let isDone: Bool
public let hasResult: Bool
}
Curve3D.approxWithDetails(tolerance:continuity:maxSegments:maxDegree:)
Approximates a 3D curve as a BSpline with detailed result information.
public func approxWithDetails(tolerance: Double, continuity: ParametricContinuity = .c2,
maxSegments: Int = 100, maxDegree: Int = 8) -> ApproxCurveResult
- Parameters:
tolerance— maximum approximation deviation.continuity— desired continuity of the output BSpline.maxSegments— maximum number of BSpline segments.maxDegree— maximum polynomial degree.
- Returns:
ApproxCurveResultwith the outputCurve3D(ornil),maxError, and status flags. - OCCT:
GeomConvert_ApproxCurveviaOCCTGeomConvertApproxCurve. - Example:
let result = curve.approxWithDetails(tolerance: 0.01, continuity: .c2) if result.isDone, let bsp = result.curve { print("max error:", result.maxError) }
ApproxSurfaceResult
Result of surface approximation including the output surface, error, and status.
public struct ApproxSurfaceResult {
public let surface: Surface?
public let maxError: Double
public let isDone: Bool
public let hasResult: Bool
}
Surface.approxWithDetails(tolerance:uContinuity:vContinuity:maxDegree:maxSegments:)
Approximates a surface as a BSpline with detailed result information.
public func approxWithDetails(tolerance: Double, uContinuity: ParametricContinuity = .c2,
vContinuity: ParametricContinuity = .c2,
maxDegree: Int = 8, maxSegments: Int = 100) -> ApproxSurfaceResult
- Parameters:
tolerance— maximum approximation deviation.uContinuity— desired continuity in U direction.vContinuity— desired continuity in V direction.maxDegree— maximum polynomial degree.maxSegments— maximum number of BSpline segments.
- Returns:
ApproxSurfaceResultwith the outputSurface(ornil),maxError, and status flags. - OCCT:
GeomConvert_ApproxSurfaceviaOCCTGeomConvertApproxSurface. - Note: Prefer
Surface.approximated(tolerance:continuity:maxSegments:maxDegree:)for simpler use; use this variant when you need the error and status separately. Both continuity defaults are C2, matchingSurface.approximated; before #491 they were C1 here, so the two no-continuity-argument calls fitted to different smoothness and returned different surfaces. - Example:
let result = surface.approxWithDetails(tolerance: 0.001) if result.isDone, let bsp = result.surface { print("max error:", result.maxError) }
GCPnts_QuasiUniformAbscissa
Edge.quasiUniformParameters(count:)
Computes a quasi-uniform parameter distribution along an edge.
public func quasiUniformParameters(count: Int) -> [Double]
The returned parameters are distributed so that the chord lengths between consecutive curve points are approximately equal. The first is always the start of the edge and the last is always its end.
- Parameters:
count, the desired number of parameter values. Must be at least 2; below that the result is empty (#501). - Returns: Array of curve parameters of length ≤
count. - OCCT:
GCPnts_QuasiUniformAbscissaviaOCCTGCPntsQuasiUniform. It can compute one point beyond the request on a poorly-conditioned curve; the surplus is dropped and the edge’s end parameter kept. Before #501 the surplus was dropped along with the end parameter, so the distribution stopped short of the edge. - Curve3D equivalent:
Curve3D.quasiUniformParameters(count:), which goes throughOCCTCurve3DQuasiUniformAbscissa. A second Curve3D-based bridge function,OCCTGCPntsQuasiUniformCurve, duplicated it from v0.75 with no caller and was removed in #501. - Example:
let params = edge.quasiUniformParameters(count: 20) // params has ~20 evenly-spaced (by chord) parameter values
GCPnts_TangentialDeflection
TangentialDeflectionPoint
A sampled point from tangential deflection discretisation.
public struct TangentialDeflectionPoint {
public let parameter: Double
public let x: Double, y: Double, z: Double
}
Edge.tangentialDeflectionPoints(angularDeflection:curvatureDeflection:minPoints:)
Samples an edge using combined angular and chordal deflection criteria.
public func tangentialDeflectionPoints(angularDeflection: Double = 0.1,
curvatureDeflection: Double = 0.1,
minPoints: Int = 2) -> [TangentialDeflectionPoint]
This is the standard adaptive sampling algorithm used by OCCT’s meshing pipeline; it produces denser samples where curvature is high.
- Parameters:
angularDeflection— maximum angular deviation between consecutive tangents (radians).curvatureDeflection— maximum chordal deviation (model units).minPoints— minimum number of sample points (must be ≥ 2).
- Returns: Array of
TangentialDeflectionPointvalues (up to 10000). - OCCT:
GCPnts_TangentialDeflectionviaOCCTGCPntsTangentialDeflection. - Example:
let pts = edge.tangentialDeflectionPoints(angularDeflection: 0.05, curvatureDeflection: 0.1) for pt in pts { print("t=\(pt.parameter): (\(pt.x), \(pt.y), \(pt.z))") }
BRepGProp_Cinert (Curve Inertia per Edge)
CurveInertia
Curve linear inertia properties (arc length and centre of mass).
public struct CurveInertia {
public let length: Double
public let centerOfMass: SIMD3<Double>?
}
Edge.curveInertia
Computes linear inertia (arc length and centre of mass) for this edge.
public var curveInertia: CurveInertia { get }
- Returns:
CurveInertiawithlengthand an optionalcenterOfMass, which isnilwhen the length is 0 and there is no centroid to report (#609). - OCCT:
BRepGProp_CinertviaOCCTBRepGPropCinert. - Example:
let inertia = edge.curveInertia print("length:", inertia.length) print("center:", inertia.centerOfMass as Any)
BRepGProp_Sinert (Surface Inertia per Face)
FaceSurfaceInertia
Face surface inertia properties (area and centre of mass).
public struct FaceSurfaceInertia {
public let area: Double
public let centerOfMass: SIMD3<Double>?
public let epsilon: Double
}
epsilon is the integration error bound; it is 0 for the non-adaptive overload.
Face.surfaceInertia
Computes surface inertia (area and centre of mass) for this face.
public var surfaceInertia: FaceSurfaceInertia { get }
- Returns:
FaceSurfaceInertiawithareaand an optional centre of mass (epsilon= 0). The centre isnilwhen the area is 0 (#609). - OCCT:
BRepGProp_SinertviaOCCTBRepGPropSinert. - Example:
let inertia = face.surfaceInertia print("area:", inertia.area)
Face.surfaceInertia(epsilon:)
Computes surface inertia using adaptive numerical integration to the given error bound.
public func surfaceInertia(epsilon: Double) -> FaceSurfaceInertia
- Parameters:
epsilon— target integration error bound. - Returns:
FaceSurfaceInertiawitharea, an optional centre of mass, and the actualepsilonachieved. - OCCT:
BRepGProp_Sinertadaptive overload viaOCCTBRepGPropSinertAdaptive.
BRepGProp_Vinert (Volume Inertia per Face)
FaceVolumeInertia
Face volume inertia contribution.
volume stays non-optional because a zero contribution is a real, useful answer: this is the divergence-theorem decomposition, so a face whose plane contains the reference point contributes exactly nothing and a caller summing over a shell needs that 0. centerOfMass is nil there, because a zero contribution has no centroid and the (0,0,0) reported before #609 was the framework’s location seed.
public struct FaceVolumeInertia {
public let volume: Double
public let centerOfMass: SIMD3<Double>?
}
Face.volumeInertia
Computes the volume inertia contribution from this face (relative to the origin).
public var volumeInertia: FaceVolumeInertia { get }
- Returns:
FaceVolumeInertiawith signedvolumeand an optional centre of mass. - OCCT:
BRepGProp_VinertviaOCCTBRepGPropVinert. - Example:
let vi = face.volumeInertia print("volume contribution:", vi.volume)
Face.volumeInertia(planeNormal:planeDistance:)
Computes volume inertia with respect to a reference plane.
public func volumeInertia(planeNormal: SIMD3<Double>, planeDistance: Double = 0) -> FaceVolumeInertia
- Parameters:
planeNormal— normal of the reference plane.planeDistance— signed distance from origin to the plane alongplaneNormal.
- Returns:
FaceVolumeInertiameasured relative to the given plane. - OCCT:
BRepGProp_Vinert(face, gp_Pln)viaOCCTBRepGPropVinertPlane.
ShapeConstruct_ProjectCurveOnSurface
Curve3D.projectOnSurface(_:firstParam:lastParam:precision:)
Projects a 3D curve onto a surface, returning a 2D (UV) curve.
public func projectOnSurface(_ surface: Surface, firstParam: Double? = nil,
lastParam: Double? = nil, precision: Double = 1e-6) -> Curve2D?
- Parameters:
surface— target surface.firstParam— start of the curve parameter range (default:domain.lowerBound).lastParam— end of the curve parameter range (default:domain.upperBound).precision— projection tolerance.
- Returns: A
Curve2Din UV parameter space of the surface, ornilif projection fails. - OCCT:
ShapeConstruct_ProjectCurveOnSurface::PerformviaOCCTProjectCurveOnSurface. - Example:
if let pcurve = curve3D.projectOnSurface(surface, precision: 1e-6) { // pcurve is the 2D UV representation of curve3D on surface }
BRepPreviewAPI_MakeBox
Shape.previewBox(width:height:depth:)
Creates a preview box shape that handles degenerate dimensions gracefully.
public static func previewBox(width: Double, height: Double, depth: Double) -> Shape?
Unlike Shape.box(width:height:depth:), this factory accepts degenerate inputs and returns the appropriate lower-dimensional shape: a box for fully 3D dimensions, a face for one zero dimension, an edge for two zero dimensions, or a vertex for all-zero dimensions.
- Parameters:
width— X dimension;height— Y dimension;depth— Z dimension. - Returns: A
Shape(solid, face, edge, or vertex), ornilon failure. - OCCT:
BRepPreviewAPI_MakeBoxviaOCCTPreviewBox. - Example:
// Returns a Face (sheet) when depth is 0 if let sheet = Shape.previewBox(width: 10, height: 5, depth: 0) { print(sheet.shapeType) // .face }
GeomPoint3D (Geom_CartesianPoint)
GeomPoint3D
A Handle-managed 3D geometric point, wrapping Geom_CartesianPoint.
public final class GeomPoint3D: @unchecked Sendable
Useful when you need OCCT’s geometry-level point entity (rather than a raw SIMD3<Double>) for operations that take Handle(Geom_Point) arguments.
| Member | Kind | Meaning |
|---|---|---|
handle | public stored property | The opaque OCCTGeomPoint3DRef this wrapper owns; released in deinit. Public (unlike most wrapper handles) so other bridge-adjacent APIs can pass it through directly. |
GeomPoint3D.handle
GeomPoint3D.init(x:y:z:)
Creates a geometric point at the given coordinates.
public init(x: Double, y: Double, z: Double)
- OCCT:
Geom_CartesianPoint(x, y, z)viaOCCTGeomPoint3DCreate.
GeomPoint3D.init(simd:)
Creates a geometric point from a SIMD3<Double>.
public init(simd: SIMD3<Double>)
x, y, z
The Cartesian coordinates of this point.
public var x: Double { get }
public var y: Double { get }
public var z: Double { get }
- OCCT:
Geom_CartesianPoint::X,Y,Z.
GeomPoint3D.z
coordinates
The coordinates as a SIMD3<Double>.
public var coordinates: SIMD3<Double> { get }
setCoordinates(x:y:z:)
Sets the point coordinates.
public func setCoordinates(x: Double, y: Double, z: Double)
- OCCT:
Geom_CartesianPoint::SetCoordviaOCCTGeomPoint3DSetCoord.
distance(to:)
Returns the Euclidean distance to another geometric point.
public func distance(to other: GeomPoint3D) -> Double
- OCCT:
Geom_Point::DistanceviaOCCTGeomPoint3DDistance. - Example:
let a = GeomPoint3D(x: 0, y: 0, z: 0) let b = GeomPoint3D(x: 3, y: 4, z: 0) print(a.distance(to: b)) // 5.0
squareDistance(to:)
Returns the squared Euclidean distance to another geometric point.
public func squareDistance(to other: GeomPoint3D) -> Double
- OCCT:
Geom_Point::SquareDistanceviaOCCTGeomPoint3DSquareDistance.
translate(dx:dy:dz:)
Translates this point in place.
public func translate(dx: Double, dy: Double, dz: Double)
- OCCT:
Geom_CartesianPoint::Translate(gp_Vec)viaOCCTGeomPoint3DTranslate.
GeomDirection (Geom_Direction)
GeomDirection
A Handle-managed 3D unit vector (always normalised), wrapping Geom_Direction.
public final class GeomDirection: @unchecked Sendable
The input vector is automatically normalised on construction. Use this when downstream OCCT APIs require a Handle(Geom_Direction).
GeomDirection.init(x:y:z:)
Creates a unit direction from component values. The vector is normalised automatically.
public init(x: Double, y: Double, z: Double)
- OCCT:
Geom_Direction(x, y, z)viaOCCTGeomDirectionCreate. - Example:
let up = GeomDirection(x: 0, y: 0, z: 1)
GeomDirection.init(simd:)
Creates a unit direction from a SIMD3<Double>.
public init(simd: SIMD3<Double>)
coordinates
The unit vector as a SIMD3<Double>.
public var coordinates: SIMD3<Double> { get }
- OCCT:
Geom_Direction::X,Y,ZviaOCCTGeomDirectionCoords.
setCoordinates(x:y:z:)
Sets the direction; the new vector is automatically normalised.
public func setCoordinates(x: Double, y: Double, z: Double)
- OCCT:
Geom_Direction::SetCoordviaOCCTGeomDirectionSetCoord.
crossed(with:)
Returns the cross product with another direction.
public func crossed(with other: GeomDirection) -> GeomDirection?
- Returns: A new
GeomDirectionperpendicular to both, ornilif the vectors are parallel (cross product is zero). - OCCT:
Geom_Direction::CrossviaOCCTGeomDirectionCrossed. - Example:
let x = GeomDirection(x: 1, y: 0, z: 0) let y = GeomDirection(x: 0, y: 1, z: 0) if let z = x.crossed(with: y) { print(z.coordinates) // SIMD3(0, 0, 1) }
GeomVector3D (Geom_VectorWithMagnitude)
GeomVector3D
A Handle-managed 3D vector with arbitrary magnitude, wrapping Geom_VectorWithMagnitude. Unlike GeomDirection, the vector may have any non-negative length including zero.
public final class GeomVector3D: @unchecked Sendable
| Member | Kind | Meaning |
|---|---|---|
handle | public stored property | The opaque OCCTGeomVector3DRef this wrapper owns; released in deinit. |
GeomVector3D.handle
GeomVector3D.init(x:y:z:)
Creates a vector from component values.
public init(x: Double, y: Double, z: Double)
- OCCT:
Geom_VectorWithMagnitude(x, y, z)viaOCCTGeomVector3DCreate.
GeomVector3D.init(simd:)
Creates a vector from a SIMD3<Double>.
public init(simd: SIMD3<Double>)
GeomVector3D.init(from:to:)
Creates a vector from point p1 to point p2.
public init(from p1: SIMD3<Double>, to p2: SIMD3<Double>)
- OCCT:
Geom_VectorWithMagnitude(p1, p2)viaOCCTGeomVector3DFromPoints. - Example:
let v = GeomVector3D(from: SIMD3(0, 0, 0), to: SIMD3(3, 4, 0)) print(v.magnitude) // 5.0
coordinates
The vector components as a SIMD3<Double>.
public var coordinates: SIMD3<Double> { get }
- OCCT:
Geom_Vector::X,Y,ZviaOCCTGeomVector3DCoords.
magnitude
The Euclidean length of this vector.
public var magnitude: Double { get }
- OCCT:
Geom_Vector::MagnitudeviaOCCTGeomVector3DMagnitude.
dot(_:)
Dot product with another vector.
public func dot(_ other: GeomVector3D) -> Double
- OCCT:
Geom_Vector::DotviaOCCTGeomVector3DDot.
added(_:)
Returns the sum of this vector and another.
public func added(_ other: GeomVector3D) -> GeomVector3D
- OCCT:
Geom_Vector::AddedviaOCCTGeomVector3DAdded.
multiplied(by:)
Returns this vector scaled by a scalar.
public func multiplied(by scalar: Double) -> GeomVector3D
- OCCT:
Geom_VectorWithMagnitude::MultipliedviaOCCTGeomVector3DMultiplied.
normalized()
Returns a normalised copy of this vector.
public func normalized() -> GeomVector3D?
- Returns: Unit vector in the same direction, or
nilifmagnitudeis near zero. - OCCT:
Geom_VectorWithMagnitude::NormalizedviaOCCTGeomVector3DNormalized. - Example:
let v = GeomVector3D(x: 3, y: 4, z: 0) if let u = v.normalized() { print(u.magnitude) // ~1.0 }
crossed(_:)
Returns the cross product with another vector.
public func crossed(_ other: GeomVector3D) -> GeomVector3D
- Returns: A new
GeomVector3Dperpendicular to both inputs. - OCCT:
Geom_VectorWithMagnitude::CrossedviaOCCTGeomVector3DCrossed.
Axis1Placement (Geom_Axis1Placement)
Axis1Placement
A Handle-managed 3D axis (origin point + direction), wrapping Geom_Axis1Placement. Used as a placement entity for geometry operations that require an Axis1.
public final class Axis1Placement: @unchecked Sendable
Axis1Placement.init(origin:direction:)
Creates an axis placement from an origin point and a direction vector.
public init(origin: SIMD3<Double>, direction: SIMD3<Double>)
- Parameters:
origin— the axis origin point;direction— the axis direction (normalised internally). - OCCT:
Geom_Axis1Placement(gp_Pnt, gp_Dir)viaOCCTAxis1PlacementCreate. - Example:
let axis = Axis1Placement(origin: .zero, direction: SIMD3(0, 0, 1))
location
The origin point of the axis.
public var location: SIMD3<Double> { get }
- OCCT:
Geom_Axis1Placement::LocationviaOCCTAxis1PlacementLocation.
direction
The unit direction of the axis.
public var direction: SIMD3<Double> { get }
- OCCT:
Geom_Axis1Placement::DirectionviaOCCTAxis1PlacementDirection.
reverse()
Reverses the axis direction in place.
public func reverse()
- OCCT:
Geom_Axis1Placement::ReverseviaOCCTAxis1PlacementReverse.
reversed()
Returns a new axis with the direction reversed.
public func reversed() -> Axis1Placement
- Returns: A new
Axis1Placementwith the same origin and the direction negated. - OCCT:
Geom_Axis1Placement::ReversedviaOCCTAxis1PlacementReversed. - Example:
let axis = Axis1Placement(origin: .zero, direction: SIMD3(0, 0, 1)) let flipped = axis.reversed() print(flipped.direction) // SIMD3(0, 0, -1)
setDirection(_:)
Sets the axis direction.
public func setDirection(_ dir: SIMD3<Double>)
- OCCT:
Geom_Axis1Placement::SetDirectionviaOCCTAxis1PlacementSetDirection.
setLocation(_:)
Sets the axis origin point.
public func setLocation(_ loc: SIMD3<Double>)
- OCCT:
Geom_Axis1Placement::SetLocationviaOCCTAxis1PlacementSetLocation.