From 3cefaaaf01ed42b2ae645ce836cffa0983b23b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Franze=CC=81n?= Date: Sun, 18 Feb 2024 15:40:11 +0100 Subject: [PATCH] Add a new initializer for Polyhedron --- Sources/SwiftSCAD/Shapes/3D/Polyhedron.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/SwiftSCAD/Shapes/3D/Polyhedron.swift b/Sources/SwiftSCAD/Shapes/3D/Polyhedron.swift index c15e9d0..f6767a9 100644 --- a/Sources/SwiftSCAD/Shapes/3D/Polyhedron.swift +++ b/Sources/SwiftSCAD/Shapes/3D/Polyhedron.swift @@ -89,6 +89,13 @@ public struct Polyhedron: CoreGeometry3D { self.init(points: table, faces: faces, convexity: convexity) } + public init(faces: [OrderedSet], convexity: Int = 2, resolver: (Vertex) -> Vector3D) { + let table: [Vertex: Vector3D] = faces.joined().reduce(into: [:]) { table, vertex in + table[vertex] = resolver(vertex) + } + self.init(points: table, faces: faces, convexity: convexity) + } + func call(in environment: Environment) -> SCADCall { SCADCall( name: "polyhedron",