Skip to content

Commit

Permalink
Add a new initializer for Polyhedron
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasf committed Feb 18, 2024
1 parent d0e6723 commit 3cefaaa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/SwiftSCAD/Shapes/3D/Polyhedron.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ public struct Polyhedron: CoreGeometry3D {
self.init(points: table, faces: faces, convexity: convexity)
}

public init<Vertex: Hashable>(faces: [OrderedSet<Vertex>], 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",
Expand Down

0 comments on commit 3cefaaa

Please sign in to comment.