### Install Xcode Command Line Tools Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/building-occt.md If you encounter a "No CMAKE_CXX_COMPILER could be found" error, install the Xcode Command Line Tools using this command. ```bash xcode-select --install ``` -------------------------------- ### Quick Start Build OCCT Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/building-occt.md Executes a script to download, build, and package OCCT for iOS and macOS. ```bash cd /path/to/OCCTSwift ./Scripts/build-occt.sh ``` -------------------------------- ### Typical OCCTSwift Wrapping Workflow Steps Source: https://github.com/gsdali/occtswift/blob/main/CLAUDE.md A step-by-step guide for the typical wrapping workflow in the OCCTSwift project, from initial audit to final release. ```bash 1. /audit-occt → pick ~20-25 operations for the next release 2. /ground-truth v51 Class1 Class2 ... → verify OCCT APIs work 3. Invoke occt-header-analyzer agent on the class list → get API analysis 4. Invoke bridge-generator agent with the analysis → get code artifacts 5. Insert generated code, swift build, swift test, iterate on failures 6. Update README.md, commit, tag, release ``` -------------------------------- ### Create a Circle Wire in C++ Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/adding-features.md Provides a C++ example of creating a circle geometry, converting it to an edge, and then forming a wire. ```cpp #include #include #include #include #include #include // Create a circle wire gp_Pnt center(0, 0, 0); gp_Dir normal(0, 0, 1); gp_Ax2 axis(center, normal); Handle(Geom_Circle) circle = GC_MakeCircle(axis, radius).Value(); TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(circle).Edge(); TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edge).Wire(); ``` -------------------------------- ### Basic OCCTSwift Usage Examples Source: https://github.com/gsdali/occtswift/blob/main/README.md Demonstrates creating primitive shapes, performing boolean operations, applying modifications, and exporting to STEP and STL formats using OCCTSwift. ```swift import OCCTSwift // Primitives let box = Shape.box(width: 10, height: 5, depth: 3) let cylinder = Shape.cylinder(radius: 2, height: 10) // Boolean operations let result = box - cylinder // subtract let combined = box + cylinder // union let common = box & cylinder // intersect // Modifications let filleted = result.filleted(radius: 0.5) let shelled = filleted.shelled(thickness: -0.3) // Export try Exporter.writeSTEP(shape: shelled, to: stepURL) try Exporter.writeSTL(shape: shelled, to: stlURL, deflection: 0.05) ``` -------------------------------- ### Example: Chamfer Specific Edges in Documentation Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/adding-features.md Illustrates how to chamfer a selected set of edges on a shape using the `chamfered` method. ```swift let box = Shape.box(width: 10, height: 10, depth: 10) // Chamfer only the top edges let topEdges = box.edges.filter { /* selection logic */ } if let chamfered = box.chamfered(edges: topEdges, distance: 1.0) { // Use chamfered shape } ``` -------------------------------- ### Set and Get Colors and Materials Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/xcaf-assemblies.md Applies a specific color and a PBR material to a document node. Demonstrates retrieving the currently set color and material properties. ```swift guard let node = doc.node(at: boxId) else { return } node.setColor(Color(red: 0.30, green: 0.52, blue: 0.90)) // also Color(red255:…), .fromHex("#4C84E6") if let c = node.color { print(c.red, c.green, c.blue) } // PBR material (baseColor + metallic/roughness/emissive/transparency) node.setMaterial(Material(baseColor: Color(red: 0.8, green: 0.2, blue: 0.1), metallic: 0.9, roughness: 0.3)) if let m = node.material { print(m.metallic, m.roughness) } ``` -------------------------------- ### Regenerate Cookbook Figures Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/images/README.md Navigate to the CookbookRender example directory and run the CookbookRender tool to regenerate figures. This process requires the path to the OCCTSwift documentation images directory. ```bash cd OCCTSwiftViewport/Examples/CookbookRender swift run CookbookRender /docs/guides/cookbook/images ``` -------------------------------- ### Build Gordon Surface from Network Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/gordon-surfaces.md Constructs a Gordon surface from a network of profiles and guides. Ensure the grid closes and shared corners coincide within the specified tolerance. The interior bows of profiles and guides do not need to match. ```swift guard let p1 = Curve3D.interpolate(points: [SIMD3(0, 0, 0), SIMD3(5, 0, 3), SIMD3(10, 0, 0)]), let p2 = Curve3D.interpolate(points: [SIMD3(0, 10, 0), SIMD3(5, 10, 3), SIMD3(10, 10, 0)]), // guides (V): the x = 0 and x = 10 edges, bowed up to z = 2 mid-span let g1 = Curve3D.interpolate(points: [SIMD3(0, 0, 0), SIMD3(0, 5, 2), SIMD3(0, 10, 0)]), let g2 = Curve3D.interpolate(points: [SIMD3(10, 0, 0), SIMD3(10, 5, 2), SIMD3(10, 10, 0)]) else { return } guard let surface = Surface.gordon(profiles: [p1, p2], guides: [g1, g2], tolerance: 1e-3) else { return } ``` -------------------------------- ### GeomFill_GuideTrihedronPlan Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Operations for creating and evaluating planar guide frames. ```APIDOC ## GeomFill_GuideTrihedronPlan ### Description Creates and evaluates planar guide frames along a curve. ### Methods - **create+setCurve**: Creates a planar guide frame and sets the base curve. - **evaluate**: Evaluates the planar guide frame at a given parameter along the curve. ``` -------------------------------- ### Build OCCT for iOS Device Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/building-occt.md Configures and builds OCCT for iOS devices using CMake, specifying installation paths and disabling optional modules. ```bash mkdir -p occt-build-ios && cd occt-build-ios cmake ../occt-src \ -DCMAKE_TOOLCHAIN_FILE=../ios.toolchain.cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=../occt-install-ios \ -DBUILD_SHARED_LIBS=OFF \ -DBUILD_MODULE_Draw=OFF \ -DBUILD_MODULE_Visualization=OFF \ -DUSE_FREETYPE=OFF \ -DUSE_FREEIMAGE=OFF \ -DUSE_RAPIDJSON=OFF \ -DUSE_TBB=OFF \ -DUSE_VTK=OFF \ -DUSE_OPENGL=OFF cmake --build . --config Release --parallel $(sysctl -n hw.ncpu) cmake --install . ``` -------------------------------- ### Create Coiled Spring Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/helices.md Constructs a coiled spring by sweeping a circular profile along a helix. Ensure the profile's normal aligns with the helix tangent at the start point for correct orientation. ```swift let r = 10.0, pitch = 4.0, turns = 5.0, wireRadius = 1.5 guard let spine = Wire.helix(radius: r, pitch: pitch, turns: turns) else { return } // helix tangent at the start point (r, 0, 0): d/dt(r·cos t, r·sin t, pitch·t/2π) at t = 0 let tangent = simd_normalize(SIMD3(0, r, pitch / (2 * .pi))) guard let profile = Wire.circle(origin: SIMD3(r, 0, 0), normal: tangent, radius: wireRadius), let spring = Shape.pipeShell(spine: spine, profile: profile, mode: .correctedFrenet, solid: true) else { return } // spring.isValid == true; spring.volume ≈ π·wireRadius²·(coil length) ``` -------------------------------- ### Run Visual Workflow Demos Source: https://github.com/gsdali/occtswift/blob/main/docs/integration-tests.md Execute visual workflow demonstrations in the OCCTSwiftViewport project. This requires navigating to the directory and running the OCCTSwiftMetalDemo executable with the --test-all-demos flag. ```bash # Visual workflow demos (in OCCTSwiftViewport) cd ../OCCTSwiftViewport swift run OCCTSwiftMetalDemo --test-all-demos ``` -------------------------------- ### Get optimal bounding box for threaded shaft Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/threads.md The default `bounds` property may overestimate the extent of a smooth thread due to control-pole hull calculations. Use `boundingBoxOptimal()` to get the precise extent of the thread's crest. ```swift threaded.bounds.max.x // ~6.8 — pole hull, misleading threaded.boundingBoxOptimal()?.max.x // ~6.0 — the real crest radius (= nominal/2) ``` -------------------------------- ### GeomFill_GuideTrihedronAC Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Operations for creating and evaluating guide frames with arc-length correction. ```APIDOC ## GeomFill_GuideTrihedronAC ### Description Creates and evaluates guide frames along a curve, with arc-length correction. ### Methods - **create+setCurve**: Creates a guide frame and sets the base curve. - **evaluate**: Evaluates the guide frame at a given parameter along the curve. ``` -------------------------------- ### Build OCCTSwift Package Source: https://github.com/gsdali/occtswift/blob/main/CLAUDE.md Builds the entire OCCTSwift package. Use this for a full build of the project. ```bash swift build ``` -------------------------------- ### Check Architectures of OCCT Library Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/building-occt.md Use the 'lipo' command to inspect the architectures supported by the OCCT static library. ```bash # Check architectures lipo -info OCCT.xcframework/ios-arm64/libOCCT.a ``` -------------------------------- ### Build OCCT from Source Source: https://github.com/gsdali/occtswift/blob/main/README.md Execute this script to rebuild the OCCT framework from its source code. Refer to the building OCCT documentation for detailed instructions. ```bash ./Scripts/build-occt.sh ``` -------------------------------- ### OCCT Bottle Workflow Source: https://github.com/gsdali/occtswift/blob/main/docs/integration-tests.md Adapts the canonical OCCT tutorial to Swift, testing fundamental operations like wire construction, mirroring, revolving, shelling, lofting, and STEP I/O. ```text profile wire → mirror → face → revolve → fillet(all) → shell → thread(helix+loft) → STEP round-trip ``` -------------------------------- ### Create Multi-Start and Left-Handed Threads Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/threads.md Use `starts` for multi-start threads and `leftHanded` for left-handed threads. These are created using the boolean cut path. ```swift let leadScrew = ThreadSpec(form: .iso68, nominalDiameter: 16, pitch: 2, leftHanded: true) let shaft = rod.threadedShaft(axisOrigin: .zero, axisDirection: SIMD3(0, 0, 1), spec: leadScrew, length: 40, starts: 2) ``` -------------------------------- ### TDataStd_ExtStringArray Operations Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Manages extended string arrays, providing methods to set, retrieve values, get the length, and check for the presence of an extended string array. ```APIDOC ## TDataStd_ExtStringArray Operations ### Description Manages extended string arrays, providing methods to set, retrieve values, get the length, and check for the presence of an extended string array. ### Methods - `setExtStringArray(array: [String])` - `extStringArrayValue(index: Int)` - `extStringArrayLength()` - `hasExtStringArray()` ``` -------------------------------- ### Build Assembly Tree with Components Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/xcaf-assemblies.md Constructs an assembly by creating an empty label and adding shapes as components with specified translations. Demonstrates adding components using translation. ```swift let asmId = doc.newShapeLabel() // an empty assembly label let c1 = doc.addComponent(assemblyLabelId: asmId, shapeLabelId: boxId, translation: (0, 0, 0)) let c2 = doc.addComponent(assemblyLabelId: asmId, shapeLabelId: sphereId, translation: (50, 0, 0)) doc.componentCount(assemblyLabelId: asmId) // 2 ``` -------------------------------- ### Import BREP and Robust STL Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/meshing-and-export.md Loads BREP files directly and robustly loads STL files, including automatic sewing and healing of seams. ```swift let brep = try Shape.loadBREP(from: brepURL) // exact + triangulation if exported with it let stl = try Shape.loadSTLRobust(from: stlURL, sewingTolerance: 1e-6) // auto sew + heal ``` -------------------------------- ### Analyze Defects with Tolerance Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/healing-and-validity.md Get a detailed report of defects like small edges, gaps, self-intersections, and free edges by analyzing the shape with a specified tolerance. ```swift if let report = box.analyze(tolerance: 1e-3) { print(report.smallEdgeCount, report.gapCount, report.selfIntersectionCount, report.freeEdgeCount, report.hasInvalidTopology) } ``` -------------------------------- ### Import STEP and IGES Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/meshing-and-export.md Loads STEP and IGES files into shapes. `loadIGESRobust` offers improved handling of potential sewing and healing issues. ```swift let step = try Shape.load(from: stepURL) // STEP (also Shape.loadSTEP) let iges = try Shape.loadIGES(from: igesURL) // loadIGESRobust sews/heals tolerance issues ``` -------------------------------- ### Download OCCT Source Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/building-occt.md Clones the OCCT source code from GitHub. Use the recommended method for RC releases. ```bash cd /path/to/OCCTSwift/Libraries # Clone from GitHub (recommended for RC releases) git clone --depth 1 --branch V8_0_0_rc4 \ https://github.com/Open-Cascade-SAS/OCCT.git occt-src # Or for stable releases, use the official repo: # git clone --depth 1 --branch V8_0_0 \ # https://git.dev.opencascade.org/repos/occt.git occt-src ``` -------------------------------- ### Get Raw Metal Buffer Data from Mesh Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/working-with-meshes.md Extract raw vertex positions, normals, and indices from a Mesh object as Data, suitable for direct use with Metal buffers for GPU rendering. ```swift // raw Metal buffers (positions / normals / indices as Data) let (positions, normals, indices) = mesh.metalBufferData() ``` -------------------------------- ### Verify Library Architecture Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/building-occt.md Check if a library is built for the correct architecture (e.g., arm64) using the 'lipo -info' command to resolve 'Undefined symbols for architecture arm64' errors. ```bash lipo -info libTKernel.a # Should show: arm64 ``` -------------------------------- ### Run Integration Tests Source: https://github.com/gsdali/occtswift/blob/main/docs/integration-tests.md Execute integration tests within the OCCTSwift project using the Swift Package Manager. ```bash # Integration tests (in OCCTSwift) swift test --filter "IntegrationTests" ``` -------------------------------- ### Revolve a Profile Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/lofting-and-sweeps.md Create a revolved shape by spinning a wire profile around an axis. This example shows revolving a rectangle to form a cylindrical drum. The `angle` parameter controls the extent of the revolution. ```swift guard let meridian = Wire.polygon([ SIMD2(5, 0), SIMD2(7, 0), SIMD2(7, 10), SIMD2(5, 10), ], closed: true), let drum = Shape.revolve(profile: meridian, axisOrigin: .zero, axisDirection: SIMD3(0, 1, 0), angle: 2 * .pi) else { return } ``` -------------------------------- ### Sweep a Circle Along a Quarter-Circle Path Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/lofting-and-sweeps.md Creates a pipe elbow by sweeping a circular profile along a quarter-circle path. Ensure the section is placed at the path's start point with its plane square to the path tangent. ```swift guard let section = Wire.circle(origin: SIMD3(16, 0, 0), normal: SIMD3(0, 1, 0), radius: 5), let path = Wire.arc(center: .zero, radius: 16, startAngle: 0, endAngle: .pi / 2), let elbow = Shape.sweep(profile: section, along: path) else { return } // elbow.isValid == true ``` -------------------------------- ### Create XCFramework for OCCT Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/building-occt.md Combines static libraries for iOS, iOS Simulator, and macOS into a single XCFramework using `libtool` and `xcodebuild`. ```bash # Combine all static libraries into single fat library per platform # (OCCT produces many .a files, we need to combine them) # For each platform, create combined library: libtool -static -o libOCCT-ios.a \ occt-install-ios/lib/*.a libtool -static -o libOCCT-sim.a \ occt-install-sim/lib/*.a libtool -static -o libOCCT-macos.a \ occt-install-macos/lib/*.a # Create XCFramework xcodebuild -create-xcframework \ -library libOCCT-ios.a -headers occt-install-ios/include \ -library libOCCT-sim.a -headers occt-install-sim/include \ -library libOCCT-macos.a -headers occt-install-macos/include \ -output OCCT.xcframework ``` -------------------------------- ### Load, Inspect, and Export Assemblies Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/xcaf-assemblies.md Loads a STEP assembly, inspects its root nodes for names and colors, and exports it back to STEP or GLTF formats. Preserves structure, names, and colors during round-trip. ```swift // load a STEP assembly — structure, names, colors preserved let doc = try Document.load(from: stepURL) for root in doc.rootNodes { print(root.name ?? "—", root.color as Any) } // write it back out, structure intact try Exporter.writeSTEPAssembly(doc, to: outURL) // product-structured STEP try doc.write(to: outURL) // same (STEP) doc.writeGLTF(to: glbURL, binary: true) // GLB for the web (returns Bool) ``` -------------------------------- ### C Interface for Edge and Chamfer Operations Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/adding-features.md Defines the C interface for interacting with OCCT shapes and edges, including functions to get edge count, retrieve specific edges, release edge handles, and perform chamfer operations on selected edges. ```c // Edge handle type (if not already defined) typedef struct OCCTEdge* OCCTEdgeRef; // Get edges from a shape int32_t OCCTShapeGetEdgeCount(OCCTShapeRef shape); OCCTEdgeRef OCCTShapeGetEdge(OCCTShapeRef shape, int32_t index); void OCCTEdgeRelease(OCCTEdgeRef edge); // Chamfer specific edges OCCTShapeRef OCCTShapeChamferEdges( OCCTShapeRef shape, const OCCTEdgeRef* edges, int32_t edgeCount, double distance ); ``` -------------------------------- ### Verify Simulator SDK Path Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/building-occt.md Ensure you are using the correct SDK for simulator builds by checking the path with 'xcrun --sdk iphonesimulator --show-sdk-path'. This helps resolve simulator build failures. ```bash xcrun --sdk iphonesimulator --show-sdk-path ``` -------------------------------- ### List Symbols in OCCT Library Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/building-occt.md Use the 'nm' command to list symbols within the OCCT static library, filtering for BRepPrimAPI to verify specific components. ```bash # List symbols nm -g OCCT.xcframework/ios-arm64/libOCCT.a | grep BRepPrimAPI ``` -------------------------------- ### Import Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Loads various CAD file formats into a Shape object. ```APIDOC ## Shape Load ### Description Loads a shape from a file. ### Methods `Shape.load(from:)` - Loads from STEP format using `STEPControl_Reader`. `Shape.loadRobust(from:)` - Loads from STEP format robustly using `STEPControl_Reader` and `ShapeFix_*`. `Shape.loadIGES(from:)` - Loads from IGES format using `IGESControl_Reader`. `Shape.loadIGESRobust(from:)` - Loads from IGES format robustly using `IGESControl_Reader` and `ShapeFix_*`. `Shape.loadBREP(from:)` - Loads from BRep format using `BRepTools::Read`. `Shape.loadSTL(from:)` - Loads from STL format using `StlAPI_Reader`. `Shape.loadSTLRobust(from:)` - Loads from STL format robustly using `StlAPI_Reader`, `BRepBuilderAPI_Sewing`, and `ShapeFix_Shape`. `Shape.loadOBJ(from:)` - Loads from OBJ format using `RWObj_CafReader`. ``` -------------------------------- ### BRep_Tool Extras Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Utilities for working with BRep tools. ```APIDOC ## BRep_Tool Extras ### Description Utilities for working with BRep tools. ### Methods - `edgeSameParameter` - `edgeSameRange` - `faceNaturalRestriction` - `edgeIsGeometric` - `faceIsGeometric` ``` -------------------------------- ### TopExp Extras Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Utilities for topological exploration. ```APIDOC ## TopExp Extras ### Description Utilities for topological exploration. ### Methods - `commonVertex` ``` -------------------------------- ### Rebuild OCCT Library Source: https://github.com/gsdali/occtswift/blob/main/docs/occt-upgrades.md Navigate to the libraries directory, remove existing OCCT source and build artifacts, and then execute the build script. This process can take 30-60 minutes. ```bash cd Libraries rm -rf occt-src occt-build-* occt-install-* cd ../Scripts && ./build-occt.sh ``` -------------------------------- ### Basic Loft: Square to Circle Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/lofting-and-sweeps.md Creates a solid by skinning a surface between a square base and a circular top. Ensure profiles are defined in separate planes. ```swift guard let base = Wire.polygon3D([ SIMD3(-5, -5, 0), SIMD3(5, -5, 0), SIMD3(5, 5, 0), SIMD3(-5, 5, 0), ], closed: true), let top = Wire.circle(origin: SIMD3(0, 0, 12), radius: 4), let transition = Shape.loft(profiles: [base, top], solid: true) else { return } // a square-to-round transition duct ``` -------------------------------- ### Run OCCTSwift Test Executable Source: https://github.com/gsdali/occtswift/blob/main/CLAUDE.md Executes the main test executable for the OCCTSwift project. ```bash swift run OCCTTest ``` -------------------------------- ### OCCT Iterator Pattern Source: https://github.com/gsdali/occtswift/blob/main/docs/naming-conventions.md Demonstrates the traditional C++ OCCT iterator pattern using Init/More/Next. ```cpp TopExp_Explorer ex(shape, TopAbs_FACE); for (; ex.More(); ex.Next()) { TopoDS_Face f = TopoDS::Face(ex.Current()); } ``` -------------------------------- ### Test OCCT Integration in Xcode Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/building-occt.md Include the OCCT header and instantiate a BRepPrimAPI_MakeBox to ensure the library is correctly linked and functional within an Objective-C++ file. ```objc // In a .mm file #include void testOCCT() { BRepPrimAPI_MakeBox box(10, 20, 30); TopoDS_Shape shape = box.Shape(); // If this compiles and runs, OCCT is working } ``` -------------------------------- ### Iterate All Faces using TopExp_Explorer Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/adding-features.md Shows how to iterate through all faces of a shape using TopExp_Explorer in C++. ```cpp // Iterate all faces TopExp_Explorer faceExplorer(shape->shape, TopAbs_FACE); while (faceExplorer.More()) { TopoDS_Face face = TopoDS::Face(faceExplorer.Current()); // Process face faceExplorer.Next(); } ``` -------------------------------- ### Wedge & Half-Space Primitives Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Constructs wedge and half-space geometric primitives. ```APIDOC ## Wedge Construction ### Description Constructs a wedge primitive. ### Methods `Shape.wedge(dx:dy:dz:ltx:)` `Shape.wedge(dx:dy:dz:xmin:zmin:xmax:zmax:)` ### OCCT Class `BRepPrimAPI_MakeWedge` ``` ```APIDOC ## Half-Space Construction ### Description Constructs a half-space primitive. ### Method `Shape.halfSpace(face:referencePoint:)` ### OCCT Class `BRepPrimAPI_MakeHalfSpace` ``` -------------------------------- ### Build TopologyGraph Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/topology-graph.md Initialize a TopologyGraph from a Shape. The graph provides durable identities for topological nodes. ```swift let box = Shape.box(width: 10, height: 10, depth: 10)! guard let graph = TopologyGraph(shape: box) else { return } // parallel: false by default ``` -------------------------------- ### Make Build Script Executable Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/building-occt.md Grant execute permissions to the OCCT build script using the 'chmod' command. ```bash chmod +x Scripts/build-occt.sh ``` -------------------------------- ### Build OCCT for macOS Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/building-occt.md Configures and builds OCCT for macOS, specifying the target deployment version and architecture. ```bash mkdir -p occt-build-macos && cd occt-build-macos cmake ../occt-src \ -DCMAKE_OSX_ARCHITECTURES=arm64 \ -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=../occt-install-macos \ -DBUILD_SHARED_LIBS=OFF \ -DBUILD_MODULE_Draw=OFF \ -DBUILD_MODULE_Visualization=OFF \ -DUSE_FREETYPE=OFF \ -DUSE_FREEIMAGE=OFF \ -DUSE_RAPIDJSON=OFF \ -DUSE_TBB=OFF \ -DUSE_VTK=OFF \ -DUSE_OPENGL=OFF cmake --build . --config Release --parallel $(sysctl -n hw.ncpu) cmake --install . ``` -------------------------------- ### Named Parameters: Cone Creation Source: https://github.com/gsdali/occtswift/blob/main/docs/naming-conventions.md OCCT uses positional arguments for cone creation, while OCCTSwift uses Swift's labeled arguments for clarity. ```cpp BRepPrimAPI_MakeCone(5.0, 2.0, 10.0); ``` ```swift Shape.cone(bottomRadius: 5, topRadius: 2, height: 10) ``` -------------------------------- ### Sweep Profile Along Path in Swift Source: https://github.com/gsdali/occtswift/blob/main/README.md Demonstrates sweeping a rectangular profile along a circular arc path to create a 3D shape. ```swift let profile = Wire.rectangle(width: 5, height: 3) let path = Wire.arc(center: .zero, radius: 50, startAngle: 0, endAngle: .pi / 2) let swept = Shape.sweep(profile: profile, along: path) ``` -------------------------------- ### Diagnose Gordon Surface Build with gordonReport Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/gordon-surfaces.md Builds a Gordon surface and returns a report including the surface, its status, and an approximation flag. This is useful for diagnosing build failures and understanding if the result is an exact interpolation or a fallback approximation. ```swift let report = Surface.gordonReport(profiles: [p1, p2], guides: [g1, g2], tolerance: 1e-3) switch report.status { case .done: print("exact:", report.surface != nil, "approx:", report.isApproximate) case .invalidInput, .intersectionFailed, .compatibilityFailed: print("network problem:", report.status) default: print("build failed:", report.status) } ``` -------------------------------- ### Shape Creation (Primitives) Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Create basic geometric shapes using primitive constructors. ```APIDOC ## Shape Creation (Primitives) ### Description Create basic geometric shapes using primitive constructors. ### Swift API - `Shape.box()` - `Shape.cylinder()` - `Shape.sphere()` - `Shape.cone()` - `Shape.torus()` ### OCCT Class - `BRepPrimAPI_MakeBox` - `BRepPrimAPI_MakeCylinder` - `BRepPrimAPI_MakeSphere` - `BRepPrimAPI_MakeCone` - `BRepPrimAPI_MakeTorus` ``` -------------------------------- ### Load XDE Document and Process Nodes in Swift Source: https://github.com/gsdali/occtswift/blob/main/README.md Loads an XDE document from a STEP file and iterates through its root nodes, printing part names, colors, and processing shapes into meshes. ```swift let doc = try Document.load(from: stepURL) for node in doc.rootNodes { print("Part: \(node.name ?? \"unnamed\")") if let color = node.color { print(" Color: \(color.red), \(color.green), \(color.blue)") } if let shape = node.shape { let mesh = shape.mesh(linearDeflection: 0.1) // render with Metal, SceneKit, RealityKit... } } ``` -------------------------------- ### OCCTSwift Project File Structure Source: https://github.com/gsdali/occtswift/blob/main/docs/architecture/overview.md Details the directory layout of the OCCTSwift project, outlining the purpose of each major directory and key files. ```text OCCTSwift/ ├── Package.swift # SPM configuration ├── README.md # Quick start guide ├── Sources/ │ ├── OCCTSwift/ # Swift public API │ │ ├── Shape.swift # 3D shapes, booleans, modifications │ │ ├── Wire.swift # 2D/3D wire profiles and paths │ │ ├── Face.swift # Face surface analysis │ │ ├── Edge.swift # Edge curve analysis │ │ ├── Curve2D.swift # 2D parametric curves (Geom2d) │ │ ├── Curve3D.swift # 3D parametric curves (Geom) │ │ ├── Surface.swift # Parametric surfaces (Geom) │ │ ├── Document.swift # XDE assembly + OCAF │ │ ├── Mesh.swift # Triangulated mesh data │ │ └── Exporter.swift # Multi-format export │ └── OCCTBridge/ │ ├── include/ │ │ └── OCCTBridge.h # C function declarations │ └── src/ │ └── OCCTBridge.mm # OCCT C++ implementations ├── Libraries/ │ └── OCCT.xcframework/ # Pre-built OCCT 8.0.0-rc5 ├── Scripts/ │ └── build-occt.sh # Build OCCT from source ├── Tests/ │ └── OCCTTests/ # Per-domain Swift Testing targets (Analysis, Modeling, Surface, …) └── docs/ # Documentation ``` -------------------------------- ### Shell and Vertex Creation Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md APIs for creating shells from shapes and vertices at specific locations. ```APIDOC ## Shell & Vertex Creation ### Description Provides methods to create a shell from a given shape and to create a vertex at a specified 3D point. ### Swift API - `Shape.shell(from:) - `Shape.vertex(at:) ### OCCT Class - `BRepBuilderAPI_MakeShell` - `BRepBuilderAPI_MakeVertex` ``` -------------------------------- ### Build Gordon Surface with Lower-Level Network Builder Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/gordon-surfaces.md Uses the lower-level `GeomFill_NetworkSurface` builder, which is stricter than `gordon` and requires aligned knot structures. It returns the surface and its status, which can indicate failures like `.knotAlignmentFailed`. ```swift let (surface, status) = Surface.networkSurface(profiles: [p1, p2], guides: [g1, g2], tolerance: 1e-3) if status != .done { print("network builder declined:", status) } // e.g. .knotAlignmentFailed ``` -------------------------------- ### OSD_Process Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Provides information about the current process. ```APIDOC ## OSD_Process ### Description Provides information about the current process, including its ID, user name, and executable path. ### Methods - `processId() -> Int` - `userName() -> String` - `executablePath() -> String` - `executableFolder() -> String` ``` -------------------------------- ### Run All OCCTSwift Tests Source: https://github.com/gsdali/occtswift/blob/main/CLAUDE.md Executes all tests within the OCCTSwift package. This command runs approximately 3900 tests across various per-domain targets. ```bash swift test ``` -------------------------------- ### Using SIMD3 for 3D Vector Operations Source: https://github.com/gsdali/occtswift/blob/main/docs/architecture/overview.md Illustrates the use of Swift's SIMD3 for representing 3D points and vectors, leveraging hardware acceleration and clear semantics for operations like translation. ```swift let offset = SIMD3(10, 0, 0) let moved = shape.translated(by: offset) ``` -------------------------------- ### OSD_Host Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Provides information about the host system. ```APIDOC ## OSD_Host ### Description Provides information about the host system, including its name, version, and internet address. ### Methods - `hostName() -> String` - `systemVersion() -> String` - `internetAddress() -> String` ``` -------------------------------- ### Math Solvers Part 2 Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Advanced mathematical solvers for root finding, least squares, and integration. ```APIDOC ## Math Solvers Part 2 ### Description Advanced mathematical solvers for root finding, least squares, and integration. ### Methods - `bracketedRoot` - `bracketMinimum` - `frpr` - `functionAllRoots` - `gaussLeastSquare` - `newtonFunctionRoot` - `uzawa` - `eigenvalues` - `eigenvaluesAndVectors` - `kronrodIntegrate` - `kronrodIntegrateAdaptive` - `gaussMultipleIntegration` - `gaussSetIntegration` ``` -------------------------------- ### Thickness Analysis via Ray Casting Source: https://github.com/gsdali/occtswift/blob/main/docs/integration-tests.md Computes a wall thickness map by casting rays from each face to find the opposite wall. Checks minimum thickness against the shell parameter and identifies thin-wall regions. ```text shelled box → for each face: cast ray along normal → find opposite wall → compute thickness ``` -------------------------------- ### Build OCCT for iOS Simulator Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/building-occt.md Configures and builds OCCT for iOS simulators, adjusting CMake settings for the simulator SDK. ```bash mkdir -p occt-build-sim && cd occt-build-sim # Modify toolchain for simulator cmake ../occt-src \ -DCMAKE_SYSTEM_NAME=iOS \ -DCMAKE_OSX_ARCHITECTURES=arm64 \ -DCMAKE_OSX_SYSROOT=$(xcrun --sdk iphonesimulator --show-sdk-path) \ -DCMAKE_OSX_DEPLOYMENT_TARGET=15.0 \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=../occt-install-sim \ -DBUILD_SHARED_LIBS=OFF \ -DBUILD_MODULE_Draw=OFF \ -DBUILD_MODULE_Visualization=OFF \ -DUSE_FREETYPE=OFF \ -DUSE_FREEIMAGE=OFF \ -DUSE_RAPIDJSON=OFF \ -DUSE_TBB=OFF \ -DUSE_VTK=OFF \ -DUSE_OPENGL=OFF cmake --build . --config Release --parallel $(sysctl -n hw.ncpu) cmake --install . ``` -------------------------------- ### ElCLib Operations Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Library for calculations on lines and circles. ```APIDOC ## ElCLib ### Description Provides library functions for calculations on lines and circles, including value retrieval and parameter calculations. ### Operations - valueOnLine - valueOnCircle - valueOnEllipse - d1OnLine - d1OnCircle - parameterOnLine - parameterOnCircle - inPeriod ``` -------------------------------- ### Configure OCCT Build Version Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/building-occt.md Set the OCCT version and release candidate number by editing variables at the top of the build script. Leave OCCT_RC empty for stable releases. ```bash OCCT_VERSION="8.0.0" OCCT_RC="rc4" # Clear this for stable releases ``` -------------------------------- ### BRepBndLib Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Functions for calculating bounding boxes of shapes. ```APIDOC ## BRepBndLib ### Description Functions for calculating bounding boxes of shapes. ### Methods - `boundingBox` - `boundingBoxOptimal` - `orientedBoundingBoxDetailed` ``` -------------------------------- ### OCCT C++ Box Constructor Source: https://github.com/gsdali/occtswift/blob/main/docs/naming-conventions.md Demonstrates the typical OCCT C++ pattern for creating shapes using a builder class and an IsDone() check. ```cpp BRepPrimAPI_MakeBox builder(10, 20, 30); if (builder.IsDone()) { TopoDS_Shape s = builder.Shape(); } ``` -------------------------------- ### Final Cleanup Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md A collection of miscellaneous utility methods for curves and surfaces. ```APIDOC ## Final Cleanup ### Description A collection of miscellaneous utility methods for curves and surfaces. ### Methods - `IsCN` (curve3D/curve2D/surfaceU/V) - `ReversedParameter` (curve3D/2D) - `ParametricTransformation` - `continuityOrder` (curve3D/2D) - `surface UReversed/VReversed/UReversedParam/VReversedParam` - `RemoveVKnot` - `vecCrossMagnitude/CrossSquareMagnitude` - `dirIsOpposite/IsNormal` - `BezierResolution` (curve3D/surface) - `MaxDegree` (bezierCurve3D/2D/surface, bsplineSurface/curve2D) ``` -------------------------------- ### Import and Cleanup Pipeline Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/healing-and-validity.md A typical workflow for importing CAD data, including loading, checking validity, repairing defects, and ensuring correct orientation. ```swift let raw = try Shape.load(from: stepURL) // imported geometry guard raw.isValid else { let fixed = raw.fixed(tolerance: 1e-3)? // repair .orientedForward() // ensure outward solid // re-check, then proceed… return } ``` -------------------------------- ### Involute Gear Workflow Source: https://github.com/gsdali/occtswift/blob/main/docs/integration-tests.md Exercises curve construction, extrusion, circular patterns, and boolean operations for creating an involute gear. Verifies rotational symmetry and volume consistency. ```text involute curve → tooth wire → extrude → circularPattern(x20) → union(hub) → drill(bore) ``` -------------------------------- ### Bezier Surface Fill Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md APIs for filling surfaces using Bezier curves with different parameterizations. ```APIDOC ## Bezier Surface Fill ### Description Fills a surface using Bezier curves, with options for different parameterizations and styles. ### Swift API - `Surface.bezierFill(_:_:_:_:style:) - `Surface.bezierFill(_:_:style:) ### OCCT Class - `GeomFill_BezierCurves` ``` -------------------------------- ### APIHeaderSection_MakeHeader Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Creates and manages STEP file headers. ```APIDOC ## APIHeaderSection_MakeHeader ### Description Manages STEP file headers, including creation, release, and setting various header attributes like name, timestamp, author, organization, and system information. ### Methods - `create() -> APIHeaderSection_MakeHeader` - `release()` - `isDone() -> Bool` - `getName() -> String` - `setName(name: String)` - `getTimeStamp() -> DateTime` - `setTimeStamp(timeStamp: DateTime)` - `getAuthor() -> [String]` - `setAuthor(authors: [String])` - `getOrganization() -> [String]` - `setOrganization(organizations: [String])` - `getPreprocessorVersion() -> String` - `setPreprocessorVersion(version: String)` - `getOriginatingSystem() -> String` - `setOriginatingSystem(system: String)` ``` -------------------------------- ### BRepGProp_VinertGK Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Operation for volume integration on a face using Gauss-Kronrod method. ```APIDOC ## BRepGProp_VinertGK ### Description Performs volume integration on a face using the Gauss-Kronrod quadrature method. ### Methods - **vinertGK**: Computes volume properties using Gauss-Kronrod integration on a face. ``` -------------------------------- ### Export Exact B-Rep Formats Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/meshing-and-export.md Exports a shape in exact B-Rep formats such as STEP, IGES, and BREP, preserving the full analytic geometry. ```swift // exact B-Rep try Exporter.writeSTEP(shape: box, to: stepURL) try Exporter.writeIGES(shape: box, to: igesURL, unit: "MM") try Exporter.writeBREP(shape: box, to: brepURL) // native OCCT, full precision ``` -------------------------------- ### Creating a Box Shape in OCCTSwift Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/occt-concepts.md This snippet demonstrates how to create a basic box shape using the OCCTSwift library. The Shape object internally manages the full B-Rep structure, including topology, without exposing it directly. ```swift let box = Shape.box(width: 10, height: 5, depth: 3) ``` -------------------------------- ### ElSLib Operations Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Library for calculations on surfaces. ```APIDOC ## ElSLib ### Description Provides library functions for calculations on surfaces like planes, cylinders, cones, spheres, and tori. ### Operations - valueOnPlane - valueOnCylinder - valueOnCone - valueOnSphere - valueOnTorus - parametersOnSphere - d1OnSphere ``` -------------------------------- ### BRepTools_WireExplorer Extensions Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Provides extensions for exploring wires. ```APIDOC ## BRepTools_WireExplorer Extensions ### Description Provides methods to get edge orientations and vertices from a wire explorer. ### Methods - `wireEdgeOrientations(wireExplorer: BRepTools_WireExplorer) -> [(TopoDS_Edge, Orientation)]` - `wireExplorerVertices(wireExplorer: BRepTools_WireExplorer) -> [TopoDS_Vertex]` ``` -------------------------------- ### Mounting Bracket Workflow Source: https://github.com/gsdali/occtswift/blob/main/docs/integration-tests.md Validates a parametric design workflow involving multiple modeling operations. Checks include validity, monotonic volume changes, face counts, and STEP round-trip fidelity. ```text box → union(wall) → fillet(corner) → drill(x4) → chamfer(holes) → shell → validate ``` -------------------------------- ### Verify OCCT Symbols Source: https://github.com/gsdali/occtswift/blob/main/CLAUDE.md Lists the symbols within the OCCT library, filtering for 'ClassName' and displaying the first 5 results. This helps in verifying the presence and naming of OCCT classes. ```bash nm -C Libraries/OCCT.xcframework/macos-arm64/libOCCT-macos.a 2>/dev/null | grep "ClassName" | head -5 ``` -------------------------------- ### Create Tapered and Variable-Pitch Coils Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/cookbook/helices.md Generates conical springs with linearly varying radii or springs with a profile that scales along the spine using a specified law function. ```swift // Conical spring — radius varies linearly along the axis. let cone = Wire.helixTapered(startRadius: 12, endRadius: 4, pitch: 3, turns: 6) // Variable section — scale the profile with a law along the spine // (BRepOffsetAPI_MakePipeShell::SetLaw): e.g. a coil whose wire tapers to half thickness. guard let law = LawFunction.linear(from: 1.0, to: 0.5) else { return } let varying = Shape.pipeShellWithLaw(spine: spine, profile: profile, law: law) ``` -------------------------------- ### Polynomial Solver Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md APIs for solving quadratic, cubic, and quartic polynomial equations. ```APIDOC ## Polynomial Solver ### Description Provides methods for finding the roots of polynomial equations of degree 2, 3, and 4. ### Swift API - `PolynomialSolver.quadratic(a:b:c:) - `PolynomialSolver.cubic(a:b:c:d:) - `PolynomialSolver.quartic(a:b:c:d:e:) ### OCCT Class - `math_DirectPolynomialRoots` ``` -------------------------------- ### BinTools Operations Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Provides utilities for binary data manipulation, including conversion to and from binary data, and writing and loading binary files. ```APIDOC ## BinTools Operations ### Description Provides utilities for binary data manipulation, including conversion to and from binary data, and writing and loading binary files. ### Methods - `toBinaryData(data: Any)` - `fromBinaryData(binaryData: [Byte])` - `writeBinary(filePath: String, data: Any)` - `loadBinary(filePath: String)` ``` -------------------------------- ### OCCTSwift Swift Transformation Methods Source: https://github.com/gsdali/occtswift/blob/main/docs/naming-conventions.md Illustrates how OCCTSwift uses Swift API Design Guidelines for transformation methods, employing -ed/-ing suffixes for methods returning new values. ```swift shape.filleted(radius:) ``` ```swift shape.chamfered(distance:) ``` ```swift shape.translated(by:) ``` ```swift shape.rotated(axis:angle:) ``` ```swift shape.scaled(by:) ``` ```swift shape.mirrored(planeNormal:) ``` ```swift shape.healed() ``` ```swift shape.deepCopy() ``` -------------------------------- ### OCCT API for Chamfering Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/adding-features.md Illustrates the basic usage of OCCT classes for performing a chamfer operation on a shape, specifically adding a chamfer to a particular edge. ```cpp #include #include #include // Basic usage: BRepFilletAPI_MakeChamfer chamfer(shape); chamfer.Add(distance, edge); // Add specific edge TopoDS_Shape result = chamfer.Shape(); ``` -------------------------------- ### OCCT C++ Exception Handling Source: https://github.com/gsdali/occtswift/blob/main/docs/naming-conventions.md Illustrates error handling in OCCT using C++ try-catch blocks for exceptions. ```cpp try { BRepPrimAPI_MakeBox builder(0, 0, 0); // degenerate TopoDS_Shape s = builder.Shape(); } catch (StdFail_NotDone&) { ... } ``` -------------------------------- ### Handle OCCT Exceptions in Objective-C Source: https://github.com/gsdali/occtswift/blob/main/docs/guides/adding-features.md Demonstrates how to catch Standard_Failure exceptions from OCCT operations in Objective-C, with conditional logging in debug builds. ```objc try { // OCCT operations } catch (const Standard_Failure& e) { // Log error if debugging #ifdef DEBUG NSLog(@"OCCT error: %s", e.GetMessageString()); #endif return nullptr; } ``` -------------------------------- ### OSD_Environment Source: https://github.com/gsdali/occtswift/blob/main/docs/API_REFERENCE.md Manages environment variables. ```APIDOC ## OSD_Environment ### Description Provides methods to get, set, and remove environment variables. ### Methods - `get(key: String) -> String?` - `set(key: String, value: String)` - `remove(key: String)` ``` -------------------------------- ### Run Stress Tests Source: https://github.com/gsdali/occtswift/blob/main/docs/integration-tests.md Execute stress tests located in the OCCTSwiftScripts directory. This involves changing the directory and running the StressTests executable. ```bash # Stress tests (in OCCTSwiftScripts) cd ../OCCTSwiftScripts swift run StressTests ```