Swift CAD — Change the shape, keep the intent.
Make the reason behind a shape editable. swift-CAD is a native Swift foundation for parametric CAD, with dimensions, constraints and feature history as source data.
Design reasons come before triangles.
Changing a dimension should preserve the intended relationships between holes and parts. A display mesh cannot describe all of those relationships. CADDocument retains parameters, sketches, constraints and feature history so an edit can lead to reevaluation.
In parametric CAD, a dimension is a relationship, not merely a number. A CADKernelTests fixture resolves height=width/2 from width=40mm and obtains 0.02m internally. Retaining references and expressions lets the document describe how a width change should affect height, rather than storing unrelated edited values.
Geometry is evaluated; intent stays in the document.
README and DESIGN.md consistently treat triangles as derived data. B-rep describes a boundary through faces, edges, vertices and topology; a mesh is derived for display and other purposes. Separating the editable source from visible geometry preserves a place for design intent.
Editing triangles gives direct access to a visible surface. Repeated dimension- or constraint-based edits also need the reason that surface exists. swift-CAD separates authoritative document, B-rep evaluation and derived mesh. In exchange, the kernel takes responsibility for units, references, feature dependencies and topology consistency.
From a command to validated geometry.
CADPipeline.apply delegates commands to DocumentEditing; evaluate delegates documents to DocumentEvaluator. Evaluation uses ValidatedCADDocument before evaluating shape and deriving representations. Failures return through KernelError. Inspected parameter tests cover reference resolution and rejection of adding an angle to a length.
- ApplicationCADCommand
- Source of truthCADDocument
- CADKernelDocumentEvaluator
- Exact geometryB-rep
- Derived displayMesh
public func evaluate(_ document: CADDocument) throws -> EvaluatedDocument {
do {
return try evaluator.evaluate(document)
} catch {
throw KernelError.wrapping(
error, phase: .evaluation,
tolerance: evaluator.evaluationTolerance
)
}
}Do not make length and angle addable.
parameterResolverRejectsInvalidUnitAddition builds an expression adding 1m and 90 degrees and expects UnitError. Converting both to plain numbers could continue computation while destroying design meaning. Parameter resolution and ValidatedCADDocument put validity of the source—not merely the ability to draw a shape—at the evaluation boundary.
width=40mm; height=width/20.02m1m + 90°UnitError
Keep precision and scope explicit.
This is a pre-v1 development kernel, without an API or document-format compatibility promise. Supported modeling and exchange follow CAPABILITY_LEDGER.md. Using B-rep does not imply arbitrary CAD operations or universal format compatibility. Tessellation quality and resource limits are separate contracts.
A plausible-looking shape is not evidence of consistent dimensions, connections or history. Apps must distinguish failed evaluation from the last displayed shape; retaining that shape is a UI policy, not an automatic kernel guarantee. Fine tessellation quality and admitted compute resources are also different decisions, represented by TessellationOptions and TessellationLimits.
Read the evidence
Source reading date:
An explanation based on reading public design, implementation and test bodies. It is not a report of executing upstream tests or measuring device performance.