Document — Shape Analysis, OSD & Geometry Builders
This page covers the shape analysis, file I/O helpers, analytic bounding, geometry property computation, transformation factories, and conic curve builders introduced across v0.99–v0.105 in Document.swift. For the core document lifecycle and STEP/IGES I/O see the main Document page.
Topics
- OSD_File · ShapeFix_Wireframe Extensions · RWStl / ShapeAnalysis_Curve / BRepExtrema_SelfIntersection / StepHeader / ShapeAnalysis_FreeBounds · Geom_TrimmedCurve · BRepLib_FindSurface · ShapeAnalysis_Surface · Resource_Manager · TopExp Adjacency · Poly_Connect Mesh Adjacency · BRepOffset_Analyse Edge Classification · BRepTools_WireExplorer Extensions · BndLib Analytic Bounding · OSD_Host / PerfMeter · GProp Cylinder/Cone · IntAna_IntQuadQuad · XCAFPrs_DocumentExplorer · gce Transform Factories · GProp Element Properties · Plate Constraint Extensions · Law_Interpolate · Bnd_Sphere · GC_MakeCircle · GC_MakeEllipse · GC_MakeHyperbola · GC_MakeCircle2d · GC_MakeEllipse2d · GC_MakeHyperbola2d
OSD_File
OSDFile wraps OCCT’s OSD_File for platform-independent sequential file I/O. Obtain an instance by path, URL, or with no arguments to create a temporary file.
OSDFile.init(path:)
Create a file object for the given file-system path.
public init(path: String)
- Parameters:
path— absolute or relative path to the file. - OCCT:
OSD_Fileconstructor viaOCCTFileCreate. - Example:
let f = OSDFile(path: "/tmp/output.txt")
OSDFile.init(url:)
Create a file object for a URL’s file path.
public init(url: URL)
- Parameters:
url— afile://URL;.pathis extracted and forwarded. - OCCT:
OSD_Fileconstructor viaOCCTFileCreate. - Example:
let f = OSDFile(url: URL(fileURLWithPath: "/tmp/output.txt"))
OSDFile.init()
Create a temporary file (path chosen by OCCT).
public init()
- OCCT:
OSD_Filedefault constructor viaOCCTFileCreateTemporary. - Example:
let tmp = OSDFile()
open()
Build (create/truncate) the file and open it for reading and writing.
@discardableResult
public func open() -> Bool
- Returns:
trueon success. - OCCT:
OSD_File::BuildviaOCCTFileOpen. - Example:
let f = OSDFile(path: "/tmp/out.txt") if f.open() { f.write("hello") }
openReadOnly()
Open an existing file for reading only.
@discardableResult
public func openReadOnly() -> Bool
- Returns:
trueon success. - OCCT:
OSD_File::Open(read-only mode) viaOCCTFileOpenReadOnly.
write(_:) (String)
Write a string to the file.
@discardableResult
public func write(_ string: String) -> Bool
- Parameters:
string— UTF-8 text to write. - Returns:
trueon success. - OCCT:
OSD_File::WriteviaOCCTFileWrite.
write(_:) (bytes)
Write raw bytes to the file.
@discardableResult
public func write(_ bytes: [UInt8]) -> Bool
- Parameters:
bytes— raw byte buffer to write. - Returns:
trueon success. - OCCT:
OSD_File::WriteviaOCCTFileWrite.
readLine(bufSize:)
Read one line from the file.
public func readLine(bufSize: Int = 4096) -> String?
- Parameters:
bufSize— maximum line length to read (default 4096). - Returns: The line string, or
nilat EOF or on error. - OCCT:
OSD_File::ReadLineviaOCCTFileReadLine.
readAll()
Read the entire remaining content of the file as a string.
public func readAll() -> String?
- Returns: The file content as a
String, ornilon error. - OCCT:
OSD_File::Read(full) viaOCCTFileReadAll. - Example:
let f = OSDFile(path: "/tmp/data.txt") if f.openReadOnly(), let content = f.readAll() { print(content) }
close()
Close the file.
public func close()
- OCCT:
OSD_File::CloseviaOCCTFileClose.
isOpen
Whether the file is currently open.
public var isOpen: Bool
- OCCT:
OSD_File::IsOpenviaOCCTFileIsOpen.
fileSize
File size in bytes, or nil on error.
public var fileSize: Int?
- Returns: Size in bytes, or
nilif the size could not be determined. - OCCT:
OSD_File::SizeviaOCCTFileSize.
rewind()
Rewind the file position to the beginning.
public func rewind()
- OCCT:
OSD_File::RewindviaOCCTFileRewind.
isAtEnd
Whether the file position is at the end.
public var isAtEnd: Bool
- OCCT:
OSD_File::IsAtEndviaOCCTFileIsAtEnd.
ShapeFix_Wireframe Extensions
Shape-healing extensions on Shape for wire gap and small-edge repair, backed by ShapeFix_Wireframe.
fixWireGaps(tolerance:)
Fix only wire gaps in the shape (no small-edge removal).
public func fixWireGaps(tolerance: Double = 1e-7) -> Shape?
- Parameters:
tolerance— precision for gap detection (default1e-7). - Returns: Fixed shape, or
nilon failure. - OCCT:
ShapeFix_Wireframe::FixWireGapsviaOCCTShapeFixWireGaps. - Example:
if let fixed = shape.fixWireGaps(tolerance: 1e-6) { // gaps repaired }
fixSmallEdges(tolerance:dropSmall:limitAngle:)
Fix only small edges in the shape (no gap repair).
public func fixSmallEdges(tolerance: Double = 1e-7,
dropSmall: Bool = false,
limitAngle: Double = -1) -> Shape?
- Parameters:
tolerance— precision for small-edge detection (default1e-7).dropSmall— iftrue, remove small edges; iffalse, merge them with neighbours.limitAngle— maximum tangent angle for merging in radians; pass-1for no limit.
- Returns: Fixed shape, or
nilon failure. - OCCT:
ShapeFix_Wireframe::FixSmallEdgesviaOCCTShapeFixSmallEdges.
RWStl / ShapeAnalysis_Curve / BRepExtrema_SelfIntersection / StepHeader / ShapeAnalysis_FreeBounds
writeSTLBinary(to:deflection:)
Write this shape’s triangulation to a binary STL file. The shape is meshed automatically.
public func writeSTLBinary(to filePath: String, deflection: Double = 0.1) -> Bool
- Parameters:
filePath— output file path.deflection— linear mesh deflection in mm for auto-triangulation (default0.1).
- Returns:
trueon success. - OCCT:
RWStl::WriteBinaryviaOCCTShapeWriteSTLBinary.
writeSTLAscii(to:deflection:)
Write this shape’s triangulation to an ASCII STL file. The shape is meshed automatically.
public func writeSTLAscii(to filePath: String, deflection: Double = 0.1) -> Bool
- Parameters:
filePath— output file path.deflection— linear mesh deflection in mm for auto-triangulation (default0.1).
- Returns:
trueon success. - OCCT:
RWStl::WriteAsciiviaOCCTShapeWriteSTLAscii.
Shape.readSTL(from:)
Read an STL file and return as a triangulated shape.
public static func readSTL(from filePath: String) -> Shape?
- Parameters:
filePath— input STL file path. - Returns: Shape with triangulation, or
nilon failure. - OCCT:
RWStl::ReadFileviaOCCTShapeReadSTL. - Example:
if let mesh = Shape.readSTL(from: "/tmp/model.stl") { print(mesh.isValid) }
isClosedWithPrecision(_:)
Check if this curve is closed within the given precision.
public func isClosedWithPrecision(_ precision: Double) -> Bool
- Parameters:
precision— tolerance for closure check. - Returns:
trueif the curve endpoints coincide withinprecision. - OCCT:
ShapeAnalysis_Curve::IsClosed(static) viaOCCTCurve3DIsClosedWithPreci.
isPeriodicSA
Check if this curve is periodic using ShapeAnalysis_Curve::IsPeriodic. More robust than the basic isPeriodic property.
public var isPeriodicSA: Bool
- OCCT:
ShapeAnalysis_Curve::IsPeriodic(static) viaOCCTCurve3DIsPeriodicSA.
OverlapPair
A pair of overlapping face indices detected by self-intersection analysis.
public struct OverlapPair: Sendable {
public let faceIndex1: Int
public let faceIndex2: Int
}
| Field | Meaning |
|---|---|
faceIndex1 | 0-based index of the first overlapping face. |
faceIndex2 | 0-based index of the second overlapping face. |
Shape.OverlapPair.faceIndex2
selfIntersectionPairs(tolerance:maxPairs:deflection:)
Detect self-intersecting face pairs in this shape. The shape is meshed automatically.
public func selfIntersectionPairs(tolerance: Double = 0.0,
maxPairs: Int = 100,
deflection: Double = 0.1) -> [OverlapPair]
- Parameters:
tolerance— overlap tolerance (default0.0).maxPairs— output capacity (default100), clamped into0...Sampling.maximumSampleCount(10,000,000); 0 or less returns empty (#622).deflection— linear mesh deflection in mm for detection triangulation (default0.1).
- Returns: Array of overlapping face index pairs; empty if none found.
- OCCT:
BRepExtrema_SelfIntersectionviaOCCTShapeSelfIntersectionPairs. - Example:
let pairs = shape.selfIntersectionPairs() for pair in pairs { print("faces \(pair.faceIndex1) and \(pair.faceIndex2) overlap") }
offsetBasisCurve
Get the basis curve of this offset curve.
public var offsetBasisCurve: Curve3D?
- Returns: The basis curve, or
nilif this is not an offset curve. - OCCT:
Geom_OffsetCurve::BasisCurveviaOCCTCurve3DOffsetBasis.
StepHeader
A STEP file header manager for reading and writing header fields (name, timestamp, author, organization, preprocessor version, originating system).
public final class StepHeader: @unchecked Sendable
StepHeader.init(filename:)
Create a STEP header with the given filename.
public init?(filename: String)
- Parameters:
filename— the STEP file name field value. - Returns:
nilif creation fails. - OCCT:
APIHeaderSection_MakeHeaderviaOCCTStepHeaderCreate.
StepHeader.isDone
Whether the header is fully defined.
public var isDone: Bool
- OCCT:
APIHeaderSection_MakeHeader::IsDoneviaOCCTStepHeaderIsDone.
StepHeader.name
The file name field.
public var name: String?
- OCCT:
APIHeaderSection_MakeHeaderget/set name fields viaOCCTStepHeaderGetName/OCCTStepHeaderSetName.
StepHeader.timeStamp
The timestamp field.
public var timeStamp: String?
- OCCT:
APIHeaderSection_MakeHeadertimestamp field viaOCCTStepHeaderGetTimeStamp/OCCTStepHeaderSetTimeStamp.
StepHeader.author
The first author field.
public var author: String?
- OCCT:
APIHeaderSection_MakeHeaderauthor field viaOCCTStepHeaderGetAuthor/OCCTStepHeaderSetAuthor.
StepHeader.organization
The first organization field.
public var organization: String?
- OCCT:
APIHeaderSection_MakeHeaderorganization field viaOCCTStepHeaderGetOrganization/OCCTStepHeaderSetOrganization.
StepHeader.preprocessorVersion
The preprocessor version field.
public var preprocessorVersion: String?
- OCCT:
APIHeaderSection_MakeHeaderpreprocessor version field viaOCCTStepHeaderGetPreprocessorVersion/OCCTStepHeaderSetPreprocessorVersion.
StepHeader.originatingSystem
The originating system field.
public var originatingSystem: String?
- OCCT:
APIHeaderSection_MakeHeaderoriginating system field viaOCCTStepHeaderGetOriginatingSystem/OCCTStepHeaderSetOriginatingSystem. - Example:
if let header = StepHeader(filename: "part.stp") { header.author = "Alice" header.organization = "ACME" print(header.isDone) }
freeBoundsClosedCount(tolerance:)
Count the number of closed free-boundary wires.
public func freeBoundsClosedCount(tolerance: Double = 1e-6) -> Int
- Note: Unaffected by OCCT 8.0.1’s
ConnectEdgesToWiresINTERNAL/EXTERNAL skip (OCCT#1408); seefreeBounds(sewingTolerance:)for why. See #655. - Parameters:
tolerance— sewing tolerance for boundary detection (default1e-6). - Returns: Number of closed free-boundary wires.
- OCCT:
ShapeAnalysis_FreeBoundsviaOCCTShapeFreeBoundsClosedCount.
freeBoundsClosedWires(tolerance:)
Get the compound of closed free-boundary wires.
public func freeBoundsClosedWires(tolerance: Double = 1e-6) -> Shape?
- Note: Unaffected by OCCT 8.0.1’s
ConnectEdgesToWiresINTERNAL/EXTERNAL skip (OCCT#1408); seefreeBounds(sewingTolerance:)for why. See #655. - Parameters:
tolerance— sewing tolerance for boundary detection (default1e-6). - Returns: Compound shape of closed wires, or
nilif none. - OCCT:
ShapeAnalysis_FreeBoundsviaOCCTShapeFreeBoundsClosed.
freeBoundsOpenWires(tolerance:)
Get the compound of open free-boundary wires.
public func freeBoundsOpenWires(tolerance: Double = 1e-6) -> Shape?
- Note: Unaffected by OCCT 8.0.1’s
ConnectEdgesToWiresINTERNAL/EXTERNAL skip (OCCT#1408); seefreeBounds(sewingTolerance:)for why. See #655. - Parameters:
tolerance— sewing tolerance for boundary detection (default1e-6). - Returns: Compound shape of open wires, or
nilif none. - OCCT:
ShapeAnalysis_FreeBoundsviaOCCTShapeFreeBoundsOpen.
Geom_TrimmedCurve
Extensions on Curve3D for trimming operations backed by Geom_TrimmedCurve.
trimmed(u1:u2:)
Create a trimmed curve from this curve between parameters u1 and u2.
public func trimmed(u1: Double, u2: Double) -> Curve3D?
- Parameters:
u1,u2— parametric start and end values. - Returns: Trimmed curve, or
nilon failure. - OCCT:
Geom_TrimmedCurveconstructor viaOCCTCurve3DTrimmed. - Example:
if let arc = curve.trimmed(u1: 0, u2: .pi / 2) { print(arc.length()) }
trimmedBasis
Get the basis curve of a trimmed curve (nil if not trimmed).
public var trimmedBasis: Curve3D?
- Returns: The underlying basis curve, or
nilif this curve is not a trimmed curve. - OCCT:
Geom_TrimmedCurve::BasisCurveviaOCCTCurve3DTrimmedBasis.
setTrim(u1:u2:)
Change the trim parameters on a trimmed curve.
@discardableResult
public func setTrim(u1: Double, u2: Double) -> Bool
- Parameters:
u1,u2— new parametric start and end values. - Returns:
trueon success. - OCCT:
Geom_TrimmedCurve::SetTrimviaOCCTCurve3DSetTrim.
BRepLib_FindSurface
Extensions on Shape to find a best-fit surface through a shape’s edges.
findSurface(tolerance:onlyPlane:)
Find a surface (typically a plane) through the edges of this shape.
public func findSurface(tolerance: Double = -1, onlyPlane: Bool = false) -> Surface?
- Parameters:
tolerance— search tolerance; pass-1to use the shape’s own tolerance.onlyPlane— iftrue, only a plane is accepted.
- Returns: Best-fit surface, or
nilif none found. - OCCT:
BRepLib_FindSurfaceviaOCCTFindSurface. - Example:
if let plane = wire.findSurface(onlyPlane: true) { // wire lies on `plane` }
findSurfaceTolerance(tolerance:onlyPlane:)
Return the tolerance achieved by the surface finder.
public func findSurfaceTolerance(tolerance: Double = -1, onlyPlane: Bool = false) -> Double?
- Returns: Achieved tolerance, or
nilon failure. - OCCT:
BRepLib_FindSurface::ToleranceReachedviaOCCTFindSurfaceTolerance.
findSurfaceExisted(tolerance:onlyPlane:)
Check if a surface already existed on the shape’s edges (rather than being computed).
public func findSurfaceExisted(tolerance: Double = -1, onlyPlane: Bool = false) -> Bool
- OCCT:
BRepLib_FindSurface::ExistedviaOCCTFindSurfaceExisted.
ShapeAnalysis_Surface
Extensions on Surface for robust projection and singularity analysis using ShapeAnalysis_Surface.
projectPointUV(_:precision:)
Project a 3D point onto this surface using ShapeAnalysis_Surface, returning UV parameters and gap.
public func projectPointUV(_ point: SIMD3<Double>, precision: Double = 1e-6) -> (u: Double, v: Double, gap: Double)
- Parameters:
point— 3D point to project.precision— projection precision (default1e-6).
- Returns: Tuple
(u, v, gap)wheregapis the distance frompointto the projected surface point. - OCCT:
ShapeAnalysis_Surface::ValueOfUVviaOCCTSurfaceProjectPointUV. - Example:
let (u, v, gap) = surface.projectPointUV(SIMD3(1, 0, 0))
hasSingularitiesSA(precision:)
Check if the surface has singularities using ShapeAnalysis_Surface.
public func hasSingularitiesSA(precision: Double = 1e-6) -> Bool
- Parameters:
precision— detection precision (default1e-6). - OCCT:
ShapeAnalysis_Surface::HasSingularitiesviaOCCTSurfaceHasSingularities.
singularityCountSA(precision:)
Number of singularities using ShapeAnalysis_Surface.
public func singularityCountSA(precision: Double = 1e-6) -> Int
- Parameters:
precision— detection precision (default1e-6). - Returns: Count of detected singularities.
- OCCT:
ShapeAnalysis_Surface::NbSingularitiesviaOCCTSurfaceNbSingularities.
isUClosedSA(precision:)
Check if the surface is spatially U-closed using ShapeAnalysis_Surface.
public func isUClosedSA(precision: Double = -1) -> Bool
- Parameters:
precision— closure precision; pass-1to use default. - OCCT:
ShapeAnalysis_Surface::IsUClosedviaOCCTSurfaceIsUClosedSA.
isVClosedSA(precision:)
Check if the surface is spatially V-closed using ShapeAnalysis_Surface.
public func isVClosedSA(precision: Double = -1) -> Bool
- Parameters:
precision— closure precision; pass-1to use default. - OCCT:
ShapeAnalysis_Surface::IsVClosedviaOCCTSurfaceIsVClosedSA.
Resource_Manager
ResourceManager is a lightweight key-value configuration store backed by OCCT’s Resource_Manager.
ResourceManager.init()
Create an in-memory resource manager.
public init()
- OCCT:
Resource_Managerconstructor viaOCCTResourceManagerCreate.
setString(_:value:)
Store a string value for the given key.
public func setString(_ key: String, value: String)
- OCCT:
Resource_Manager::SetResource(string) viaOCCTResourceManagerSetString.
setInt(_:value:)
Store an integer value for the given key.
public func setInt(_ key: String, value: Int)
- OCCT:
Resource_Manager::SetResource(integer) viaOCCTResourceManagerSetInt.
setReal(_:value:)
Store a floating-point value for the given key.
public func setReal(_ key: String, value: Double)
- OCCT:
Resource_Manager::SetResource(real) viaOCCTResourceManagerSetReal.
find(_:)
Check whether a key exists in the resource manager.
public func find(_ key: String) -> Bool
- Returns:
trueif the key is defined. - OCCT:
Resource_Manager::FindviaOCCTResourceManagerFind.
string(_:)
Retrieve a string value for the given key.
public func string(_ key: String) -> String?
- Returns: The stored string, or
nilif the key does not exist or is not a string. - OCCT:
Resource_Manager::Value(string) viaOCCTResourceManagerGetString.
integer(_:)
Retrieve an integer value for the given key.
public func integer(_ key: String) -> Int
- Returns: The stored integer, or
0if the key is not found. - OCCT:
Resource_Manager::IntegerValueviaOCCTResourceManagerGetInt.
real(_:)
Retrieve a floating-point value for the given key.
public func real(_ key: String) -> Double
- Returns: The stored real value, or
0.0if the key is not found. - OCCT:
Resource_Manager::RealValueviaOCCTResourceManagerGetReal. - Example:
let rm = ResourceManager() rm.setReal("tolerance", value: 1e-6) print(rm.real("tolerance")) // 1e-06
TopExp Adjacency
Shape extensions for vertex and edge adjacency queries backed by TopExp.
edgeFirstVertex()
Get the FORWARD vertex position of an edge shape.
public func edgeFirstVertex() -> SIMD3<Double>?
- Returns: Position of the first (FORWARD) vertex, or
nilif the shape is not an edge. - OCCT:
TopExp::FirstVertexviaOCCTEdgeFirstVertex.
edgeLastVertex()
Get the REVERSED vertex position of an edge shape.
public func edgeLastVertex() -> SIMD3<Double>?
- Returns: Position of the last (REVERSED) vertex, or
nilif the shape is not an edge. - OCCT:
TopExp::LastVertexviaOCCTEdgeLastVertex.
edgeVertices()
Get both vertex positions of an edge shape.
public func edgeVertices() -> (first: SIMD3<Double>, last: SIMD3<Double>)?
- Returns: Tuple of first and last vertex positions, or
nilif not an edge. - OCCT:
TopExp::VerticesviaOCCTEdgeVertices.
wireVertices()
Get first and last vertex positions of a wire shape. For closed wires both are the same.
public func wireVertices() -> (first: SIMD3<Double>, last: SIMD3<Double>)?
- Returns: Tuple of first and last wire vertices, or
nilif not a wire. - OCCT:
TopExp::Verticeson wire viaOCCTWireVertices.
commonVertex(with:)
Find common vertex between two edge shapes.
public func commonVertex(with other: Shape) -> SIMD3<Double>?
- Parameters:
other— the second edge shape to compare. - Returns: Shared vertex position, or
nilif no shared vertex. - OCCT:
TopExp::CommonVertexviaOCCTEdgeCommonVertex.
edgeFaceAdjacency()
Build edge-to-face adjacency. Returns an array where each element is the number of faces sharing that edge.
public func edgeFaceAdjacency() -> [Int]
- Returns: Array of face counts per edge (in edge iteration order); empty if no edges.
- OCCT:
TopExp_Explorer/ adjacency map viaOCCTEdgeFaceAdjacency.
vertexEdgeAdjacency()
Build vertex-to-edge adjacency. Returns an array where each element is the number of edges sharing that vertex.
public func vertexEdgeAdjacency() -> [Int]
- Returns: Array of edge counts per vertex (in vertex iteration order); empty if no vertices.
- OCCT:
TopExp_Explorer/ adjacency map viaOCCTVertexEdgeAdjacency.
adjacentFaces(forEdge:)
Get the 0-based indices of the faces adjacent to a specific edge within this shape.
public func adjacentFaces(forEdge edge: Shape) -> [Int]
- Parameters:
edge— the edge shape to query adjacency for. - Returns: Array of 0-based face indices (up to 64), addressable with
face(at:). - Example:
let box = Shape.box(width: 10, height: 10, depth: 10)! let edge = box.subShapes(ofType: .edge).first! for i in box.adjacentFaces(forEdge: edge) { print(box.face(at: i)!.area()) // the two faces meeting at that edge } - Note: These were 1-based until #541, which named the face before the intended one and could never name face 0. Drop any
- 1a caller was applying. - OCCT:
TopExpadjacency map viaOCCTEdgeAdjacentFaces.
adjacentEdges(forVertex:)
Get the 0-based indices of the edges meeting a specific vertex within this shape.
public func adjacentEdges(forVertex vertex: Shape) -> [Int]
- Parameters:
vertex— the vertex shape to query adjacency for. - Returns: Array of 0-based edge indices (up to 64), addressable with
subShape(type: .edge, index:). These were 1-based until #541. - OCCT:
TopExpadjacency map viaOCCTVertexAdjacentEdges. - Example:
let faceCounts = box.edgeFaceAdjacency() // faceCounts[i] == 2 for interior edges shared by two faces
Poly_Connect Mesh Adjacency
Shape extensions for mesh triangle adjacency queries via Poly_Connect.
meshTriangleAdjacency(faceIndex:triangleIndex:)
Get adjacent triangles for a triangle in a meshed face. Triangle indices are 1-based; 0 means no neighbour.
public func meshTriangleAdjacency(faceIndex: Int, triangleIndex: Int) -> (Int, Int, Int)?
- Parameters:
faceIndex— 0-based face index, asFace.indexandface(at:)use (#541).triangleIndex— 1-based triangle index within the face, asPoly_Triangulationnumbers them. The returned neighbour indices are 1-based for the same reason.
- Returns: Tuple
(adj1, adj2, adj3)of adjacent triangle indices, ornilif not found. - OCCT:
Poly_ConnectviaOCCTMeshTriangleAdjacency.
meshNodeTriangle(faceIndex:nodeIndex:)
Get a triangle index containing a given node.
public func meshNodeTriangle(faceIndex: Int, nodeIndex: Int) -> Int?
- Parameters:
faceIndex— 0-based face index (#541).nodeIndex— 1-based node index, asPoly_Triangulationnumbers them.
- Returns: 1-based triangle index, or
nilif not found. - OCCT:
Poly_ConnectviaOCCTMeshNodeTriangle.
meshNodeTriangleCount(faceIndex:nodeIndex:)
Count triangles sharing a node (triangle fan count).
public func meshNodeTriangleCount(faceIndex: Int, nodeIndex: Int) -> Int
- Parameters:
faceIndex— 0-based face index (#541).nodeIndex— 1-based node index, asPoly_Triangulationnumbers them.
- Returns: Number of triangles in the fan around this node.
- OCCT:
Poly_ConnectviaOCCTMeshNodeTriangleCount.
BRepOffset_Analyse Edge Classification
Shape extensions for concavity classification using BRepOffset_Analyse.
ConcavityType
Concavity classification for edges.
public enum ConcavityType: Int, Sendable {
case convex = 0
case concave = 1
case tangent = 2
case freeBound = 3
case other = 4
}
| Case | Meaning |
|---|---|
.convex | Edge is convex: the two adjacent faces bulge away from each other across it. |
.concave | Edge is concave: the two adjacent faces fold toward each other across it. |
.tangent | Adjacent faces meet tangentially (smooth, no sharp convex/concave transition) at this edge. |
.freeBound | Edge borders only one face (an open boundary), so convexity is not applicable. |
.other | Classification could not be determined as convex, concave, tangent, or a free bound. |
Shape.ConcavityType.other
analyseEdgeConcavity(angle:)
Analyze edge concavity for all edges in the shape.
public func analyseEdgeConcavity(angle: Double = .pi / 6.0) -> [ConcavityType]
- Parameters:
angle— tangency threshold in radians (defaultπ/6). - Returns: Array of
ConcavityTypeper edge in exploration order. - OCCT:
BRepOffset_AnalyseviaOCCTAnalyseEdgeConcavity. - Example:
let types = shape.analyseEdgeConcavity() let convexCount = types.filter { $0 == .convex }.count
analyseExplode(angle:type:)
Explode shape into groups of faces connected by edges of a given concavity type.
public func analyseExplode(angle: Double = .pi / 6.0, type: ConcavityType) -> Shape?
- Parameters:
angle— tangency threshold in radians.type— concavity type to group by.
- Returns: Compound shape of face groups, or
nilon failure. - OCCT:
BRepOffset_Analyse::ExplodeviaOCCTAnalyseExplode.
analyseEdgesOnFace(_:angle:type:)
Count edges of a given concavity type on a specific face.
public func analyseEdgesOnFace(_ face: Shape, angle: Double = .pi / 6.0, type: ConcavityType) -> Int
- Parameters:
face— the face shape to analyse.angle— tangency threshold in radians.type— concavity type to count.
- Returns: Edge count of the given type on this face.
- OCCT:
BRepOffset_AnalyseviaOCCTAnalyseEdgesOnFace.
analyseAncestorCount(edge:angle:)
Count ancestor faces for an edge in offset analysis.
public func analyseAncestorCount(edge: Shape, angle: Double = .pi / 6.0) -> Int
- Parameters:
edge— edge shape to query.angle— tangency threshold in radians.
- Returns: Number of ancestor faces.
- OCCT:
BRepOffset_Analyse::AncestorsviaOCCTAnalyseAncestorCount.
analyseTangentEdgeCount(edge:vertex:angle:)
Count tangent edges at a vertex along a given edge.
public func analyseTangentEdgeCount(edge: Shape, vertex: Shape, angle: Double = .pi / 6.0) -> Int
- Parameters:
edge— the edge to query tangency along.vertex— the vertex at which to count tangent edges.angle— tangency threshold in radians.
- Returns: Number of tangent edges at the vertex.
- OCCT:
BRepOffset_AnalyseviaOCCTAnalyseTangentEdgeCount.
BRepTools_WireExplorer Extensions
Shape extensions for ordered wire traversal via BRepTools_WireExplorer.
EdgeOrientation
Edge orientation within a wire.
public enum EdgeOrientation: Int, Sendable {
case forward = 0
case reversed = 1
case `internal` = 2
case external = 3
}
Case meanings, from TopAbs_Orientation: .forward and .reversed mark a “real” edge limiting the wire’s material side (reversed running opposite the wire’s parametric direction); .internal and .external mark an edge that is present in the wire but does not bound material on either side (traversed on both faces, or excluded from both).
EdgeOrientation.forward
The edge runs in the same direction as the wire’s parametric traversal and marks a real material boundary.
EdgeOrientation.external
The edge does not bound material on either side; it is excluded from the classification on both sides.
wireEdgeOrientations(face:)
Get edge orientations within a wire, optionally with face context.
public func wireEdgeOrientations(face: Shape? = nil) -> [EdgeOrientation]
- Parameters:
face— optional face context to resolve orientation ambiguity. - Returns: Array of
EdgeOrientationper edge in wire traversal order. - OCCT:
BRepTools_WireExplorerviaOCCTWireExplorerOrientations. - Example:
let orientations = wire.wireEdgeOrientations()
wireExplorerVertices(face:)
Get connecting vertex positions from wire explorer (vertex between consecutive edges).
public func wireExplorerVertices(face: Shape? = nil) -> [SIMD3<Double>]
- Parameters:
face— optional face context. - Returns: Array of 3D positions for the connecting vertices in traversal order.
- OCCT:
BRepTools_WireExplorer::CurrentVertexviaOCCTWireExplorerVertices.
BndLib Analytic Bounding
AnalyticBounds and BndLib provide exact bounding boxes for analytic geometry primitives without discretisation.
AnalyticBounds
Bounding box result from analytic geometry.
public struct AnalyticBounds: Sendable {
public let min: SIMD3<Double>
public let max: SIMD3<Double>
}
| Field | Meaning |
|---|---|
min | Minimum corner of the axis-aligned bounding box. |
max | Maximum corner of the axis-aligned bounding box. |
AnalyticBounds.max
BndLib.line(origin:direction:p1:p2:tolerance:)
Bounding box of a line segment.
public static func line(origin: SIMD3<Double>, direction: SIMD3<Double>,
p1: Double, p2: Double, tolerance: Double = 0) -> AnalyticBounds
- Parameters:
origin,direction— line definition;p1,p2— parametric extents;tolerance— inflation. - OCCT:
BndLib_Add3dCurve/BndLibline viaOCCTBndLibLine.
BndLib.circle(center:normal:radius:tolerance:)
Bounding box of a full circle.
public static func circle(center: SIMD3<Double>, normal: SIMD3<Double>,
radius: Double, tolerance: Double = 0) -> AnalyticBounds
- OCCT:
BndLibcircle viaOCCTBndLibCircle.
BndLib.sphere(center:radius:tolerance:)
Bounding box of a sphere.
public static func sphere(center: SIMD3<Double>, radius: Double, tolerance: Double = 0) -> AnalyticBounds
- OCCT:
BndLib_AddSurface/ sphere viaOCCTBndLibSphere.
BndLib.cylinder(center:axis:radius:vmin:vmax:tolerance:)
Bounding box of a cylinder patch.
public static func cylinder(center: SIMD3<Double>, axis: SIMD3<Double>,
radius: Double, vmin: Double, vmax: Double, tolerance: Double = 0) -> AnalyticBounds
- Parameters:
vmin,vmax— height extent alongaxis. - OCCT:
BndLibcylinder viaOCCTBndLibCylinder.
BndLib.torus(center:axis:majorRadius:minorRadius:tolerance:)
Bounding box of a torus.
public static func torus(center: SIMD3<Double>, axis: SIMD3<Double>,
majorRadius: Double, minorRadius: Double, tolerance: Double = 0) -> AnalyticBounds
- OCCT:
BndLibtorus viaOCCTBndLibTorus.
BndLib.edge(_:tolerance:)
Bounding box of a 3D edge curve.
public static func edge(_ edge: Shape, tolerance: Double = 0) -> AnalyticBounds
- Parameters:
edge— edge shape whose underlying curve is used. - OCCT:
BndLib_Add3dCurve::AddviaOCCTBndLibEdge.
BndLib.face(_:tolerance:)
Bounding box of a face surface.
public static func face(_ face: Shape, tolerance: Double = 0) -> AnalyticBounds
- Parameters:
face— face shape whose underlying surface is used. - OCCT:
BndLib_AddSurface::AddviaOCCTBndLibFace. - Example:
let bounds = BndLib.sphere(center: .zero, radius: 5) // bounds.min == SIMD3(-5, -5, -5), bounds.max == SIMD3(5, 5, 5)
OSD_Host / PerfMeter
System host information and performance measurement.
HostInfo.hostName
Get the hostname.
public static var hostName: String?
- OCCT:
OSD_Host::HostNameviaOCCTHostName.
HostInfo.systemVersion
Get the OS version string.
public static var systemVersion: String?
- OCCT:
OSD_Host::SystemVersionviaOCCTSystemVersion.
HostInfo.internetAddress
Get the internet address.
public static var internetAddress: String?
- OCCT:
OSD_Host::InternetAddressviaOCCTInternetAddress. - Example:
if let host = HostInfo.hostName { print("Running on \(host)") }
PerfMeter.init(name:)
Create a named performance measurement timer.
public init(name: String)
- Parameters:
name— identifier for the meter. - OCCT:
OSD_PerfMeterconstructor viaOCCTPerfMeterCreate.
PerfMeter.start()
Start the performance timer.
public func start()
- OCCT:
OSD_PerfMeter::StartviaOCCTPerfMeterStart.
PerfMeter.stop()
Stop the performance timer.
public func stop()
- OCCT:
OSD_PerfMeter::StopviaOCCTPerfMeterStop.
PerfMeter.elapsed
Elapsed time in seconds.
public var elapsed: Double
- OCCT:
OSD_PerfMeter::ElapsedviaOCCTPerfMeterElapsed. - Example:
let meter = PerfMeter(name: "myOp") meter.start() // ... work ... meter.stop() print(meter.elapsed)
GProp Cylinder/Cone
Extensions on GeometryProperties for analytical cylinder and cone property computation.
GeometryProperties.cylinderSurfaceArea(radius:height:)
Cylinder lateral surface area.
public static func cylinderSurfaceArea(radius: Double, height: Double) -> Double
- OCCT:
GProp_PGPropscylinder surface viaOCCTGPropCylinderSurface.
GeometryProperties.cylinderVolume(radius:height:)
Cylinder volume.
public static func cylinderVolume(radius: Double, height: Double) -> Double
- OCCT:
GProp_PGPropscylinder volume viaOCCTGPropCylinderVolume.
GeometryProperties.coneSurfaceArea(semiAngle:refRadius:height:)
Cone lateral surface area.
public static func coneSurfaceArea(semiAngle: Double, refRadius: Double, height: Double) -> Double
- Parameters:
semiAngle— cone half-angle in radians;refRadius— radius at reference plane;height— cone height. - OCCT:
GProp_PGPropscone surface viaOCCTGPropConeSurface.
GeometryProperties.coneVolume(semiAngle:refRadius:height:)
Cone volume.
public static func coneVolume(semiAngle: Double, refRadius: Double, height: Double) -> Double
- OCCT:
GProp_PGPropscone volume viaOCCTGPropConeVolume. - Example:
let area = GeometryProperties.cylinderSurfaceArea(radius: 5, height: 10) let vol = GeometryProperties.cylinderVolume(radius: 5, height: 10)
IntAna_IntQuadQuad
Analytic quadric-quadric intersection via IntAna_IntQuadQuad.
QuadricIntersection.cylinderSphere(cylinderRadius:sphereCenter:sphereRadius:tolerance:)
Intersect a cylinder (Z-axis, given radius) with a sphere. Returns intersection curve count, or nil on failure.
public static func cylinderSphere(cylinderRadius: Double,
sphereCenter: SIMD3<Double>, sphereRadius: Double,
tolerance: Double = 1e-6) -> Int?
- Parameters:
cylinderRadius— radius of the Z-axis cylinder.sphereCenter— center of the sphere.sphereRadius— radius of the sphere.tolerance— intersection tolerance (default1e-6).
- Returns: Number of intersection curves, or
nilon failure. - OCCT:
IntAna_IntQuadQuadviaOCCTIntAnaCylinderSphere.
QuadricIntersection.cylinderSphereIdentical(cylinderRadius:sphereCenter:sphereRadius:tolerance:)
Check if a cylinder and sphere surfaces are identical.
public static func cylinderSphereIdentical(cylinderRadius: Double,
sphereCenter: SIMD3<Double>, sphereRadius: Double,
tolerance: Double = 1e-6) -> Bool
- OCCT:
IntAna_IntQuadQuad::IdenticalElementsviaOCCTIntAnaCylinderSphereIdentical. - Example:
if let n = QuadricIntersection.cylinderSphere(cylinderRadius: 3, sphereCenter: .zero, sphereRadius: 5) { print("\(n) intersection curve(s)") }
XCAFPrs_DocumentExplorer
Extensions on Document for traversing the document’s shape tree using XCAFPrs_DocumentExplorer.
explorerNodeCount
Count leaf shape nodes in the document.
public var explorerNodeCount: Int
- OCCT:
XCAFPrs_DocumentExplorernode enumeration viaOCCTDocumentExplorerCount.
explorerShape(at:)
Get the shape at a 0-based index from the document explorer.
public func explorerShape(at index: Int) -> Shape?
- Parameters:
index— 0-based node index. - Returns: Shape at the given index, or
nilif out of range. - OCCT:
XCAFPrs_DocumentExplorerviaOCCTDocumentExplorerShape.
explorerPathId(at:)
Get the path ID string at a 0-based index from the document explorer.
public func explorerPathId(at index: Int) -> String?
- Parameters:
index— 0-based node index. - Returns: Path ID string, or
nilif out of range. - OCCT:
XCAFPrs_DocumentExplorerviaOCCTDocumentExplorerPathId.
explorerFindShape(pathId:)
Find a shape from a path ID string.
public func explorerFindShape(pathId: String) -> Shape?
- Parameters:
pathId— path ID string previously returned byexplorerPathId(at:). - Returns: Matching shape, or
nilif not found. - OCCT:
XCAFPrs_DocumentExplorerviaOCCTDocumentExplorerFindShape. - Example:
for i in 0..<doc.explorerNodeCount { if let shape = doc.explorerShape(at: i), let path = doc.explorerPathId(at: i) { print("\(path): valid=\(shape.isValid)") } }
gce Transform Factories
Transformation matrix types and factory namespaces backed by the gce_Make* family and gp_Trsf / gp_Trsf2d.
TransformMatrix3D
3D transformation matrix (row-major 3×4).
public struct TransformMatrix3D: Sendable {
public let values: [Double] // 12 elements: row-major 3x4
}
| Field | Meaning |
|---|---|
values | The 12 matrix entries, row-major (rows of a 3x4 affine transform: 3x3 rotation/scale block plus a translation column, one row of 4 values per output axis). |
(Per-field anchor below, for cross-reference; the table above has the actual meaning.)
values
TransformMatrix3D.apply(to:)
Apply this transform to a 3D point.
public func apply(to point: SIMD3<Double>) -> SIMD3<Double>
- Parameters:
point— input point. - Returns: Transformed point.
TransformMatrix2D
2D transformation matrix (row-major 2×3).
public struct TransformMatrix2D: Sendable {
public let values: [Double] // 6 elements: row-major 2x3
}
TransformMatrix2D.values
The 6 matrix coefficients, row-major: [a, b, c, d, e, f] such that apply(to: (x, y)) computes (a*x + b*y + c, d*x + e*y + f).
TransformMatrix2D.apply(to:)
Apply this transform to a 2D point.
public func apply(to point: SIMD2<Double>) -> SIMD2<Double>
- Parameters:
point— input 2D point. - Returns: Transformed 2D point.
TransformFactory3D.mirrorPoint(_:)
Mirror about a point (central symmetry).
public static func mirrorPoint(_ point: SIMD3<Double>) -> TransformMatrix3D
- OCCT:
gce_MakeMirror(point) viaOCCTMakeMirrorPoint.
TransformFactory3D.mirrorAxis(point:direction:)
Mirror about an axis (line).
public static func mirrorAxis(point: SIMD3<Double>, direction: SIMD3<Double>) -> TransformMatrix3D
- OCCT:
gce_MakeMirror(axis) viaOCCTMakeMirrorAxis.
TransformFactory3D.mirrorPlane(point:normal:)
Mirror about a plane.
public static func mirrorPlane(point: SIMD3<Double>, normal: SIMD3<Double>) -> TransformMatrix3D
- OCCT:
gce_MakeMirror(plane) viaOCCTMakeMirrorPlane.
TransformFactory3D.rotation(point:direction:angle:)
Rotation about an axis by angle in radians.
public static func rotation(point: SIMD3<Double>, direction: SIMD3<Double>, angle: Double) -> TransformMatrix3D
- OCCT:
gce_MakeRotationviaOCCTMakeRotation.
TransformFactory3D.scale(center:factor:)
Uniform scale about a point.
public static func scale(center: SIMD3<Double>, factor: Double) -> TransformMatrix3D
- OCCT:
gce_MakeScaleviaOCCTMakeScaleTransform.
TransformFactory3D.translation(_:)
Translation by a vector.
public static func translation(_ vector: SIMD3<Double>) -> TransformMatrix3D
- OCCT:
gce_MakeTranslation(vector) viaOCCTMakeTranslationVec.
TransformFactory3D.translation(from:to:)
Translation from one point to another.
public static func translation(from p1: SIMD3<Double>, to p2: SIMD3<Double>) -> TransformMatrix3D
- OCCT:
gce_MakeTranslation(two points) viaOCCTMakeTranslationPoints. - Example:
let m = TransformFactory3D.rotation(point: .zero, direction: SIMD3(0,0,1), angle: .pi / 4) let rotated = m.apply(to: SIMD3(1, 0, 0))
TransformFactory2D.mirrorPoint(_:)
Mirror about a 2D point.
public static func mirrorPoint(_ point: SIMD2<Double>) -> TransformMatrix2D
- OCCT:
gce_MakeMirror2d(point) viaOCCTMakeMirror2dPoint.
TransformFactory2D.mirrorAxis(point:direction:)
Mirror about a 2D axis.
public static func mirrorAxis(point: SIMD2<Double>, direction: SIMD2<Double>) -> TransformMatrix2D
- OCCT:
gce_MakeMirror2d(axis) viaOCCTMakeMirror2dAxis.
TransformFactory2D.rotation(center:angle:)
Rotation about a 2D point by angle in radians.
public static func rotation(center: SIMD2<Double>, angle: Double) -> TransformMatrix2D
- OCCT:
gce_MakeRotation2dviaOCCTMakeRotation2d.
TransformFactory2D.scale(center:factor:)
Uniform scale about a 2D point.
public static func scale(center: SIMD2<Double>, factor: Double) -> TransformMatrix2D
- OCCT:
gce_MakeScale2dviaOCCTMakeScale2d.
TransformFactory2D.translation(_:) (vector)
Translation by a 2D vector.
public static func translation(_ vector: SIMD2<Double>) -> TransformMatrix2D
- OCCT:
gce_MakeTranslation2d(vector) viaOCCTMakeTranslation2dVec.
TransformFactory2D.translation(from:to:)
Translation from one 2D point to another.
public static func translation(from p1: SIMD2<Double>, to p2: SIMD2<Double>) -> TransformMatrix2D
- OCCT:
gce_MakeTranslation2d(two points) viaOCCTMakeTranslation2dPoints.
TransformFactory2D.direction(x:y:)
Create a unit 2D direction from coordinates. Returns nil if the input is a zero vector.
public static func direction(x: Double, y: Double) -> SIMD2<Double>?
- OCCT:
gce_MakeDir2dviaOCCTMakeDir2d.
TransformFactory2D.direction(from:to:)
Create a unit 2D direction from two points. Returns nil if the points are coincident.
public static func direction(from p1: SIMD2<Double>, to p2: SIMD2<Double>) -> SIMD2<Double>?
- OCCT:
gce_MakeDir2d(two points) viaOCCTMakeDir2dFromPoints.
GProp Element Properties
GeometryProperties provides analytical mass/center computations for primitive geometry elements.
GeometryProperties.lineSegment(from:to:)
Line segment properties: returns (length, centerOfMass), or nil when OCCT rejects the input.
public static func lineSegment(from p1: SIMD3<Double>, to p2: SIMD3<Double>) -> (length: Double, center: SIMD3<Double>)?
- Returns:
nilfor two coincident endpoints, which give no direction to build a line from (gp_Dirthrows on the zero vector). That used to come back as a length of 0 with a centre of (0,0,0), a plausible answer for a segment that has none (#609). - OCCT:
GProp_CelGPropsline viaOCCTGPropLineSegment.
GeometryProperties.circularArc(center:normal:radius:u1:u2:)
Circular arc properties: returns (arcLength, centerOfMass), or nil when OCCT rejects the input.
public static func circularArc(center: SIMD3<Double>, normal: SIMD3<Double>,
radius: Double, u1: Double, u2: Double) -> (arcLength: Double, center: SIMD3<Double>)?
- Parameters:
u1,u2— parametric start and end angles in radians. - Returns:
nilfor a zero normal vector, which gives no plane to build a circle in. A valid arc withu1 == u2is not a rejection: it answers with an arc length of 0 and the correct centre, becauseGProp_CelGPropscomputes the centroid analytically rather than by accumulating mass (#609). - OCCT:
GProp_CelGPropscircular arc viaOCCTGPropCircularArc.
GeometryProperties.pointSetCentroid(_:)
Compute the centroid of a point set. Returns (pointCount, centroid).
public static func pointSetCentroid(_ points: [SIMD3<Double>]) -> (count: Double, centroid: SIMD3<Double>?)
- Parameters:
points— array of 3D points. - Returns: The point count (as
Double) and the centroid, which isnilfor an empty set. An empty set has no centroid, and the (0,0,0) reported before #609 was indistinguishable from the centroid of a set centred on the origin. - OCCT:
GProp_PGPropspoint set viaOCCTGPropPointSetCentroid.
GeometryProperties.sphereSurfaceArea(radius:)
Sphere surface area (analytical).
public static func sphereSurfaceArea(radius: Double) -> Double
- OCCT:
GProp_PGPropssphere surface viaOCCTGPropSphereSurface.
GeometryProperties.sphereVolume(radius:)
Sphere volume (analytical).
public static func sphereVolume(radius: Double) -> Double
- OCCT:
GProp_PGPropssphere volume viaOCCTGPropSphereVolume. - Example:
let seg = GeometryProperties.lineSegment(from: .zero, to: SIMD3(3, 4, 0)) // seg?.length == 5.0, seg?.center == SIMD3(1.5, 2.0, 0)
Plate Constraint Extensions
Extensions on PlateSolver for additional constraint types.
loadPlaneConstraint(u:v:planePoint:planeNormal:)
Load a plane constraint at a UV point.
@discardableResult
public func loadPlaneConstraint(u: Double, v: Double, planePoint: SIMD3<Double>, planeNormal: SIMD3<Double>) -> Bool
- Parameters:
u,v— parametric constraint location;planePoint,planeNormal— plane definition. - Returns:
trueon success. - OCCT:
Plate_PlaneConstraintviaOCCTPlateLoadPlaneConstraint.
loadLineConstraint(u:v:linePoint:lineDirection:)
Load a line constraint at a UV point.
@discardableResult
public func loadLineConstraint(u: Double, v: Double, linePoint: SIMD3<Double>, lineDirection: SIMD3<Double>) -> Bool
- Parameters:
u,v— parametric constraint location;linePoint,lineDirection— line definition. - Returns:
trueon success. - OCCT:
Plate_LineConstraintviaOCCTPlateLoadLineConstraint.
loadFreeG1Constraint(u:v:du:dv:)
Load a free G1 continuity constraint at a UV point.
@discardableResult
public func loadFreeG1Constraint(u: Double, v: Double, du: SIMD3<Double>, dv: SIMD3<Double>) -> Bool
- Parameters:
u,v— parametric constraint location;du,dv— partial derivatives defining the tangent frame. - Returns:
trueon success. - OCCT:
Plate_FreeGthenCConstraint(G1) viaOCCTPlateLoadFreeG1Constraint.
Law_Interpolate
Extension on LawFunction for creating interpolated law functions.
LawFunction.interpolated(values:parameters:periodic:)
Create an interpolated law function from values.
public static func interpolated(values: [Double], parameters: [Double]? = nil, periodic: Bool = false) -> LawFunction?
- Parameters:
values— array of function values to interpolate.parameters— optional parameter array; must matchvalues.countif provided. Ifnil, uniform spacing is used.periodic— iftrue, the interpolation is periodic.
- Returns: Interpolated
LawFunction, ornilon failure. - OCCT:
Law_InterpolateviaOCCTLawInterpolate. - Example:
if let law = LawFunction.interpolated(values: [1.0, 2.0, 1.0]) { print(law.value(at: 0.5)) }
Bnd_Sphere
BoundingSphere wraps OCCT’s Bnd_Sphere for fast spatial culling and proximity queries.
BoundingSphere.init(center:radius:)
Create a bounding sphere.
public init(center: SIMD3<Double>, radius: Double)
- OCCT:
Bnd_Sphereconstructor viaOCCTBndSphereCreate.
BoundingSphere.radius
The sphere radius.
public var radius: Double
- OCCT:
Bnd_Sphere::RadiusviaOCCTBndSphereRadius.
BoundingSphere.center
The sphere center.
public var center: SIMD3<Double>
- OCCT:
Bnd_Sphere::CenterviaOCCTBndSphereCenter.
BoundingSphere.distance(to:)
Distance from sphere center to a point.
public func distance(to point: SIMD3<Double>) -> Double
- OCCT:
Bnd_Sphere::DistanceviaOCCTBndSphereDistance.
BoundingSphere.isOutside(_:) (point)
Check if a point is outside the sphere.
public func isOutside(_ point: SIMD3<Double>) -> Bool
- OCCT:
Bnd_Sphere::IsOut(point) viaOCCTBndSphereIsOut.
BoundingSphere.isOutside(_:) (sphere)
Check if another sphere is disjoint from this sphere.
public func isOutside(_ other: BoundingSphere) -> Bool
- OCCT:
Bnd_Sphere::IsOut(sphere) viaOCCTBndSphereIsOutSphere.
BoundingSphere.add(_:)
Merge (expand to contain) another sphere.
public func add(_ other: BoundingSphere)
- OCCT:
Bnd_Sphere::AddviaOCCTBndSphereAdd. - Example:
let s = BoundingSphere(center: .zero, radius: 5) print(s.isOutside(SIMD3(10, 0, 0))) // true
GC_MakeCircle
Curve3D factory methods backed by GC_MakeCircle.
Curve3D.gcCircle(center:normal:radius:)
Create a 3D circle from axis (center + normal) and radius.
public static func gcCircle(center: SIMD3<Double>, normal: SIMD3<Double>, radius: Double) -> Curve3D?
- OCCT:
GC_MakeCircleviaOCCTGCMakeCircle.
Curve3D.gcCircle(p1:p2:p3:)
Create a 3D circle through 3 points.
public static func gcCircle(p1: SIMD3<Double>, p2: SIMD3<Double>, p3: SIMD3<Double>) -> Curve3D?
- OCCT:
GC_MakeCircle(3 points) viaOCCTGCMakeCircle3Points.
Curve3D.gcCircleCenterNormal(center:normal:radius:)
Create a 3D circle from center, normal, and radius (alias).
public static func gcCircleCenterNormal(center: SIMD3<Double>, normal: SIMD3<Double>, radius: Double) -> Curve3D?
- OCCT:
GC_MakeCircleviaOCCTGCMakeCircleCenterNormal.
Curve3D.gcCircleParallel(center:normal:radius:distance:)
Create a 3D circle parallel to an existing circle at a given distance.
public static func gcCircleParallel(center: SIMD3<Double>, normal: SIMD3<Double>,
radius: Double, distance: Double) -> Curve3D?
- Parameters:
distance— signed offset distance from the reference circle. - OCCT:
GC_MakeCircle(parallel) viaOCCTGCMakeCircleParallel. - Example:
if let c = Curve3D.gcCircle(center: .zero, normal: SIMD3(0,0,1), radius: 10) { print(c.length()) }
GC_MakeEllipse
Curve3D factory methods backed by GC_MakeEllipse.
Curve3D.gcEllipse(center:normal:majorRadius:minorRadius:)
Create a 3D ellipse from axis and major/minor radii.
public static func gcEllipse(center: SIMD3<Double>, normal: SIMD3<Double>,
majorRadius: Double, minorRadius: Double) -> Curve3D?
- OCCT:
GC_MakeEllipseviaOCCTGCMakeEllipse.
Curve3D.gcEllipse(s1:s2:center:)
Create a 3D ellipse from 3 points (S1, S2, center).
public static func gcEllipse(s1: SIMD3<Double>, s2: SIMD3<Double>, center: SIMD3<Double>) -> Curve3D?
- Parameters:
s1,s2— points on the ellipse;center— ellipse center. - OCCT:
GC_MakeEllipse(3 points) viaOCCTGCMakeEllipse3Points.
Curve3D.gcEllipse(center:normal:xDirection:majorRadius:minorRadius:)
Create a 3D ellipse from full Ax2 (center + normal + X direction) and radii.
public static func gcEllipse(center: SIMD3<Double>, normal: SIMD3<Double>, xDirection: SIMD3<Double>,
majorRadius: Double, minorRadius: Double) -> Curve3D?
- Parameters:
xDirection— explicit X-axis direction for the ellipse frame. - OCCT:
GC_MakeEllipse(Ax2) viaOCCTGCMakeEllipseFromElips.
GC_MakeHyperbola
Curve3D factory methods backed by GC_MakeHyperbola.
Curve3D.gcHyperbola(center:normal:majorRadius:minorRadius:)
Create a 3D hyperbola from axis and major/minor radii.
public static func gcHyperbola(center: SIMD3<Double>, normal: SIMD3<Double>,
majorRadius: Double, minorRadius: Double) -> Curve3D?
- OCCT:
GC_MakeHyperbolaviaOCCTGCMakeHyperbola.
Curve3D.gcHyperbola(s1:s2:center:)
Create a 3D hyperbola from 3 points (S1, S2, center).
public static func gcHyperbola(s1: SIMD3<Double>, s2: SIMD3<Double>, center: SIMD3<Double>) -> Curve3D?
- Parameters:
s1,s2— points on the hyperbola;center— hyperbola center. - OCCT:
GC_MakeHyperbola(3 points) viaOCCTGCMakeHyperbola3Points.
GC_MakeCircle2d
Curve2D factory methods backed by GC_MakeCircle2d.
Curve2D.gceCircle(center:radius:)
Create a 2D circle from center and radius.
public static func gceCircle(center: SIMD2<Double>, radius: Double) -> Curve2D?
- OCCT:
GC_MakeCircle2dviaOCCTCurve2DMakeCircleCenterRadius. - Note:
radiusmust be positive (#553).GC_MakeCircle2dreportsgce_NegativeRadiusfor a negative radius but succeeds for zero, returning a circle that behaves as its own centre. A non-positive radius returns nil.
Curve2D.gceCircle(p1:p2:p3:)
Create a 2D circle through 3 points.
public static func gceCircle(p1: SIMD2<Double>, p2: SIMD2<Double>, p3: SIMD2<Double>) -> Curve2D?
- OCCT:
GC_MakeCircle2d(3 points) viaOCCTCurve2DMakeCircle3Points.
Curve2D.gceCircle(center:pointOn:)
Create a 2D circle from center and a point on the circle.
public static func gceCircle(center: SIMD2<Double>, pointOn: SIMD2<Double>) -> Curve2D?
- OCCT:
GC_MakeCircle2d(center + point) viaOCCTCurve2DMakeCircleCenterPoint.
Curve2D.gceCircleParallel(center:direction:radius:distance:)
Create a 2D circle parallel to an existing circle at a given distance.
public static func gceCircleParallel(center: SIMD2<Double>, direction: SIMD2<Double>,
radius: Double, distance: Double) -> Curve2D?
- OCCT:
GC_MakeCircle2d(parallel) viaOCCTCurve2DMakeCircleParallel. - Note:
radiusmust be positive, and so mustradius + distance(#553).GC_MakeCircle2dtakes the absolute value rather than refusing an offset that reaches or passes the centre: measured, radius 5 offset by -5 gives radius 0 and by -6 gives radius 1, a circle inside the base rather than the one asked for. Either violation returns nil.
Curve2D.gceCircle(axisCenter:axisDirection:radius:)
Create a 2D circle from axis (center + direction) and radius.
public static func gceCircle(axisCenter: SIMD2<Double>, axisDirection: SIMD2<Double>,
radius: Double) -> Curve2D?
- OCCT:
GC_MakeCircle2d(axis) viaOCCTCurve2DMakeCircleAxis. - Note:
radiusmust be positive (#553); a non-positive radius returns nil. - Example:
if let c = Curve2D.gceCircle(center: SIMD2(0, 0), radius: 5) { print(c.length()) }
GC_MakeEllipse2d
Curve2D factory methods backed by GC_MakeEllipse2d.
Curve2D.gceEllipse(center:xDirection:majorRadius:minorRadius:)
Create a 2D ellipse from axis and radii.
public static func gceEllipse(center: SIMD2<Double>, xDirection: SIMD2<Double>,
majorRadius: Double, minorRadius: Double) -> Curve2D?
- OCCT:
GC_MakeEllipse2dviaOCCTCurve2DMakeEllipse.
Curve2D.gceEllipse(s1:s2:center:)
Create a 2D ellipse from 3 points (S1, S2, center).
public static func gceEllipse(s1: SIMD2<Double>, s2: SIMD2<Double>, center: SIMD2<Double>) -> Curve2D?
- OCCT:
GC_MakeEllipse2d(3 points) viaOCCTCurve2DMakeEllipse3Points.
Curve2D.gceEllipse(center:xDirection:yDirection:majorRadius:minorRadius:)
Create a 2D ellipse from full Ax22d and radii.
public static func gceEllipse(center: SIMD2<Double>, xDirection: SIMD2<Double>,
yDirection: SIMD2<Double>,
majorRadius: Double, minorRadius: Double) -> Curve2D?
- Parameters:
yDirection— explicit Y-axis direction for the ellipse frame. - OCCT:
GC_MakeEllipse2d(Ax22d) viaOCCTCurve2DMakeEllipseAxis22d.
GC_MakeHyperbola2d
Curve2D factory methods backed by GC_MakeHyperbola2d.
Curve2D.gceHyperbola(center:xDirection:majorRadius:minorRadius:)
Create a 2D hyperbola from axis and radii.
public static func gceHyperbola(center: SIMD2<Double>, xDirection: SIMD2<Double>,
majorRadius: Double, minorRadius: Double) -> Curve2D?
- OCCT:
GC_MakeHyperbola2dviaOCCTCurve2DMakeHyperbola.
Curve2D.gceHyperbola(s1:s2:center:)
Create a 2D hyperbola from 3 points (S1, S2, center).
public static func gceHyperbola(s1: SIMD2<Double>, s2: SIMD2<Double>, center: SIMD2<Double>) -> Curve2D?
- Parameters:
s1,s2— points on the hyperbola;center— hyperbola center. - OCCT:
GC_MakeHyperbola2d(3 points) viaOCCTCurve2DMakeHyperbola3Points. - Example:
if let h = Curve2D.gceHyperbola(center: .zero, xDirection: SIMD2(1, 0), majorRadius: 3, minorRadius: 2) { // h is a Geom2d_Hyperbola }