From 244734ae991bb2e7ac6522350a610df1f5506614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Franze=CC=81n?= Date: Thu, 1 Aug 2024 21:15:52 +0200 Subject: [PATCH] Fix extrude with profiles --- .../Extrude/ExtrudeWithEdgeProfiles.swift | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Sources/SwiftSCAD/Operations/Extrude/ExtrudeWithEdgeProfiles.swift b/Sources/SwiftSCAD/Operations/Extrude/ExtrudeWithEdgeProfiles.swift index dffa868..2985ec6 100644 --- a/Sources/SwiftSCAD/Operations/Extrude/ExtrudeWithEdgeProfiles.swift +++ b/Sources/SwiftSCAD/Operations/Extrude/ExtrudeWithEdgeProfiles.swift @@ -17,19 +17,18 @@ public extension Geometry2D { /// - Returns: The extruded 3D geometry. func extruded(height: Double, topEdge: EdgeProfile?, bottomEdge: EdgeProfile?, method: EdgeProfile.Method) -> any Geometry3D { - extruded(height: height) - .intersection { - if let topEdge { - topEdge.mask(shape: self, extrusionHeight: height, method: method) - } - } - .intersection { - if let bottomEdge { - bottomEdge.mask(shape: self, extrusionHeight: height, method: method) - .flipped(along: .z) - .translated(z: height) - } + var shape = extruded(height: height) + if let topEdge { + shape = shape.intersection(topEdge.mask(shape: self, extrusionHeight: height, method: method)) + } + if let bottomEdge { + shape = shape.intersection { + bottomEdge.mask(shape: self, extrusionHeight: height, method: method) + .flipped(along: .z) + .translated(z: height) } + } + return shape } /// See ``extruded(height:topEdge:bottomEdge:method:)``