Skip to content

Repository files navigation

OCCTSwiftAIS

Superseded by OCCTSwiftInteraction

New code should depend on OCCTSwiftInteraction, which vends OCCTSwiftAIS as one of its three targets, alongside the other two packages this one used to sit beside. The module name is unchanged, so import OCCTSwiftAIS still works: what changes is the package you depend on.

-.package(url: "https://github.com/SecondMouseAU/OCCTSwiftAIS.git", from: "..."),
+.package(url: "https://github.com/SecondMouseAU/OCCTSwiftInteraction.git", from: "..."),

-.product(name: "OCCTSwiftAIS", package: "OCCTSwiftAIS"),
+.product(name: "OCCTSwiftAIS", package: "OCCTSwiftInteraction"),

You cannot depend on both. They vend targets with the same names, and SwiftPM rejects that at build-graph assembly rather than at resolution, so swift package resolve succeeds and swift build then fails on a duplicate target name. Migrate the whole graph at once, and see docs/MIGRATION.md.

This repository is not being deleted, and is status: maintenance: it still builds and still takes dependency repins, so nothing breaks by staying. It takes no new features or fixes, which all go to OCCTSwiftInteraction. Why the three were merged, and what it bought, is in ecosystem#42.

Swift Platforms License

High-level Application Interactive Services for the OCCTSwift / OCCTSwiftViewport stack — selection-from-topology, manipulator widgets, dimension annotations, and standard scene objects, all in pure Swift.

Part of the OCCTSwift ecosystem — see the ecosystem map for how this package fits with the kernel, viewport, and sibling layers.

Current: v1.3.1. SemVer-stable from v1.0.0, re-pinned to OCCTSwiftTools v1.6.0 / OCCTSwift v1.15.0+ (still the OCCT 8.0.0p1 GA cohort). See SPEC.md for the design brief and docs/CHANGELOG.md for per-release notes.

What's in the box

  • Selection-from-topology — pick a body / face / edge / vertex; round-trip the GPU pick to a TopoDS_Face / Edge / Vertex handle on the source Shape. Body and face highlights composite via the renderer's per-triangle style buffer (no overlay-mesh flicker).
  • Manipulator widgets — translate and rotate gizmos with snapTranslate / snapRotateDeg, on the renderer's overlay layer (always-on-top), with native widget pick filtering. SwiftUI integration via .attachManipulator(_:).
  • DimensionsLinearDimension, AngularDimension, RadialDimension. Topology-aware anchors (vertex / edge midpoint / face bbox center / circular-edge center) feed into OCCTSwiftViewport's existing MeasurementOverlay for leader lines + billboarded label.
  • Standard scene objectsTrihedron, WorkPlane, Axis, PointCloudPresentation.
  • Durable selection identitySubShape carries a SubShapeRef (the resolved Shape plus a BRepGraph.GraphUID when a graph was in hand at pick time), not just a render-path ordinal. InteractiveContext.update(_:to:absorbing:operationName:) absorbs a modelling operation's history into the object's living BRepGraph, and remap(_:using:rebindingTo:) resolves a pre-mutation Selection forward through it — a face split by the operation expands to all its successors; a deleted one is reported via isDeleted(_:in:), never silently pointed at a coincidentally-adjacent neighbour.
  • Topology-aware selection filtersSurfaceTypeFilter, CurveTypeFilter, ShapeTypeFilter, composed with AllOfFilter / AnyOfFilter / NotFilter / PredicateFilter, installed via InteractiveContext.addFilter(_:) to restrict what's pickable/hoverable beyond selectionMode.
  • Rectangle and lasso area selectionInteractiveContext.selectRectangle(from:to:) / selectPolygon(_:), honouring selectionMode and installed filters; .attachAreaSelection(_:) wires up the drag gesture, a live rubber-band/lasso overlay, and camera-orbit passthrough when not actively marqueeing.

→ Getting started walks through wiring all of this into a SwiftUI app.

Installation

.package(url: "https://github.com/SecondMouseAU/OCCTSwiftAIS.git", from: "1.3.0"),

OCCTSwiftAIS transitively pulls OCCTSwiftTools, OCCTSwiftViewport, and OCCTSwift.

30-second example

import SwiftUI
import OCCTSwift
import OCCTSwiftViewport
import OCCTSwiftAIS

@MainActor
struct CADView: View {
    @StateObject private var ais = InteractiveContext(viewport: ViewportController())

    var body: some View {
        MetalViewportView(controller: ais.viewport, bodies: $ais.bodies)
            .onAppear {
                if let part = Shape.box(width: 10, height: 5, depth: 3) {
                    ais.display(part)
                }
                ais.selectionMode = [.face]
            }
            .onChange(of: ais.selection) { _, sel in
                for face in sel.faces {
                    print("selected face area:", face.area())
                }
            }
    }
}

Architecture

Application
   ↑
OCCTSwiftAIS         ← this repo (selection / manipulator / dimensions)
   ↑
OCCTSwiftTools       ← bridge: Shape ↔ ViewportBody
   ↑      ↑
OCCTSwift  OCCTSwiftViewport
(B-Rep)    (Metal)

OCCTSwiftAIS adds scene-management semantics an OCCT-style API expects (selection-on-topology, manipulators, dimensions) as a thin Swift layer on top of OCCTSwiftViewport's native Metal renderer. It is not a port of OCCT's TKV3d / TKService / TKOpenGl toolkits — see OCCTSwift/docs/visualization-research.md for why.

Supported platforms

Platform Status
macOS 15+ arm64 Supported
iOS 18+ device + simulator arm64 Supported
visionOS 1+ device + simulator arm64 Supported
tvOS 18+ device + simulator arm64 Supported

Same floor as OCCTSwiftViewport.

Documentation

  • Getting started — selection, manipulators, dimensions, standard objects in one walkthrough.
  • SPEC.md — design rationale and the v0.x → v1.0 trajectory.
  • docs/CHANGELOG.md — what shipped in each release.

Sibling repos: OCCTSwift (B-Rep kernel), OCCTSwiftViewport (Metal renderer), OCCTSwiftTools (Shape ↔ ViewportBody bridge).

License

LGPL 2.1 (matching OCCT). See LICENSE.

About

High-level Application Interactive Services for the OCCTSwift / OCCTSwiftViewport stack — selection-from-topology, manipulator widgets, dimension annotations, standard scene objects.

Resources

Code of conduct

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages