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:)``