diff --git a/src/main/scad/puzzlecad/puzzlecad-burr.scad b/src/main/scad/puzzlecad/puzzlecad-burr.scad index 992b8b5..a8b92ad 100644 --- a/src/main/scad/puzzlecad/puzzlecad-burr.scad +++ b/src/main/scad/puzzlecad/puzzlecad-burr.scad @@ -48,9 +48,11 @@ module burr_piece(burr_spec) { * The other arguments should be left as defaults (they're used for recursive calls to burr_plate). */ -module burr_plate(burr_specs, num_copies = 1) { +module burr_plate(burr_specs, num_copies = 1, dup = []) { - burr_infos = [ for (burr_spec = burr_specs) to_burr_info(burr_spec) ]; + burr_dups = dups(dup, burr_specs); + + burr_infos = [ for (burr_spec = burr_dups) to_burr_info(burr_spec) ]; layout_burr_infos = $auto_layout ? auto_layout_plate(burr_infos) : burr_infos; diff --git a/src/main/scad/puzzlecad/puzzlecad-parser.scad b/src/main/scad/puzzlecad/puzzlecad-parser.scad index 2fd05e5..4ac4283 100644 --- a/src/main/scad/puzzlecad/puzzlecad-parser.scad +++ b/src/main/scad/puzzlecad/puzzlecad-parser.scad @@ -209,3 +209,7 @@ function bit_of(n, exponent) = floor(n / pow(2, exponent)) % 2; function copies(n, burr) = n == 0 ? [] : concat(copies(n-1, burr), [burr]); +function dups(v, r, i = 0) = + i < len(v) + ? dups(v, concat(r, [for (x = [0:1:v[i][1] - 1]) r[v[i][0]]]), i + 1) + : r;