Overview
Add CadQuery-style workplane operations and face/edge selectors.
Parent issue: #25
Depends on: #26
Goals
Selector System
Face Selectors
| Selector |
Meaning |
Implementation |
">Z" |
Top face (normal +Z) |
Filter by normal.z > 0.9 |
"<Z" |
Bottom face (normal -Z) |
Filter by normal.z < -0.9 |
">X" |
Right face |
Filter by normal.x > 0.9 |
"<X" |
Left face |
Filter by normal.x < -0.9 |
">Y" |
Front face |
Filter by normal.y > 0.9 |
"<Y" |
Back face |
Filter by normal.y < -0.9 |
Edge Selectors
| Selector |
Meaning |
Implementation |
"|Z" |
Edges parallel to Z |
Filter by direction |
"|X" |
Edges parallel to X |
Filter by direction |
"#Z" |
Edges perpendicular to Z |
Filter by direction |
API Additions
// Select faces and work on them
shape.faces(">Z") // Select top face
.workplane() // Create workplane on face
.hole(diameter) // Drill hole
// Select edges for filleting
shape.edges("|Z") // Select vertical edges
.fillet(radius)
// 2D sketching
Workplane("XY")
.rect(width, height) // Draw rectangle
.circle(radius) // Draw circle
.polygon(points) // Draw polygon
.extrude(height) // Extrude to solid
Implementation
CadQuerySelectors.swift
struct Selector {
enum Direction { case x, y, z }
enum Comparison { case greater, less, parallel, perpendicular }
static func parse(_ str: String) -> Selector? {
// Parse ">Z", "<X", "|Z", "#Y" etc.
}
func filterFaces(_ faces: [Face]) -> [Face] {
// Apply selector logic
}
}
CadQueryWorkplane.swift
class CadQueryWorkplane: NSObject, CadQueryExports {
var origin: SIMD3<Double>
var normal: SIMD3<Double>
var xDirection: SIMD3<Double>
func rect(_ w: Double, _ h: Double) -> CadQueryWorkplane
func circle(_ r: Double) -> CadQueryWorkplane
func extrude(_ h: Double) -> CadQueryShape
}
Acceptance Criteria
Effort Estimate
~5 days
Overview
Add CadQuery-style workplane operations and face/edge selectors.
Parent issue: #25
Depends on: #26
Goals
Selector System
Face Selectors
">Z""<Z"">X""<X"">Y""<Y"Edge Selectors
"|Z""|X""#Z"API Additions
Implementation
CadQuerySelectors.swift
CadQueryWorkplane.swift
Acceptance Criteria
Effort Estimate
~5 days