From cbeecb4130e8f150cb10242adc9d14b5860ee821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Franze=CC=81n?= Date: Sat, 19 Oct 2024 19:40:15 +0200 Subject: [PATCH] Remove absolute() and relative() for now --- .../Path Builder/BezierPath.Component.swift | 20 +++++++------------ .../Path Builder/ComponentFunctions.swift | 10 +--------- .../Values/Edge Profiles/Fillet.swift | 3 ++- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/Sources/SwiftSCAD/Values/Bezier/Path Builder/BezierPath.Component.swift b/Sources/SwiftSCAD/Values/Bezier/Path Builder/BezierPath.Component.swift index 1a193ff..5094968 100644 --- a/Sources/SwiftSCAD/Values/Bezier/Path Builder/BezierPath.Component.swift +++ b/Sources/SwiftSCAD/Values/Bezier/Path Builder/BezierPath.Component.swift @@ -2,7 +2,7 @@ extension BezierPath { public struct Component { private enum Contents { case points ([OptionalVector]) - case subcomponents ([Component], positioning: BezierPath.Positioning?) + case subcomponents ([Component]) } private let contents: Contents @@ -10,8 +10,8 @@ extension BezierPath { contents = .points(points) } - internal init(group: [Component], positioning: BezierPath.Positioning? = nil) { - contents = .subcomponents(group, positioning: positioning) + internal init(group: [Component]) { + contents = .subcomponents(group) } internal func bezierCurves(start: inout V, positioning: BezierPath.Positioning) -> [BezierCurve] { @@ -22,16 +22,10 @@ extension BezierPath { start = controlPoints.last! return [BezierCurve(controlPoints: controlPoints)] - case .subcomponents (let components, let override): - if let override { - return components.flatMap { - $0.bezierCurves(start: &start, positioning: override) - } - } else { - var localStart = start - return components.flatMap { - $0.bezierCurves(start: &localStart, positioning: positioning) - } + case .subcomponents (let components): + var localStart = start + return components.flatMap { + $0.bezierCurves(start: &localStart, positioning: positioning) } } } diff --git a/Sources/SwiftSCAD/Values/Bezier/Path Builder/ComponentFunctions.swift b/Sources/SwiftSCAD/Values/Bezier/Path Builder/ComponentFunctions.swift index 2eb88c6..c385d07 100644 --- a/Sources/SwiftSCAD/Values/Bezier/Path Builder/ComponentFunctions.swift +++ b/Sources/SwiftSCAD/Values/Bezier/Path Builder/ComponentFunctions.swift @@ -11,15 +11,7 @@ public func curve(_ controlPoints: [V]) -> BezierPath.Component { // MARK: - Groups public func group(@BezierPath.Builder builder: () -> [BezierPath.Component]) -> BezierPath.Component { - .init(group: builder(), positioning: nil) -} - -public func relative(@BezierPath.Builder builder: () -> [BezierPath.Component]) -> BezierPath.Component { - .init(group: builder(), positioning: .relative) -} - -public func absolute(@BezierPath.Builder builder: () -> [BezierPath.Component]) -> BezierPath.Component { - .init(group: builder(), positioning: .absolute) + .init(group: builder()) } diff --git a/Sources/SwiftSCAD/Values/Edge Profiles/Fillet.swift b/Sources/SwiftSCAD/Values/Edge Profiles/Fillet.swift index 1fb24d5..7863664 100644 --- a/Sources/SwiftSCAD/Values/Edge Profiles/Fillet.swift +++ b/Sources/SwiftSCAD/Values/Edge Profiles/Fillet.swift @@ -22,9 +22,10 @@ extension Fillet: EdgeProfileShape { EnvironmentReader3D { environment in let facetsPerRev = environment.facets.facetCount(circleRadius: max(width, height)) let facetCount = max(Int(ceil(Double(facetsPerRev) / 4.0)), 1) + let angleIncrement = 90° / Double(facetCount) return (0...facetCount).map { f in - let angle = (Double(f) / Double(facetCount)) * 90° + let angle = Double(f) * angleIncrement let inset = (cos(angle) - 1) * width let zOffset = sin(angle) * height return shape.offset(amount: inset, style: .round)