-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdicer.stanza
28 lines (26 loc) · 991 Bytes
/
dicer.stanza
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include("geom-lslib.lstanza")
#include("jitbot.stanza")
defn dice (mesh:Mesh, n:Int) :
val bb = bbox(mesh)
val lo = z(min(bb))
val dz = z(max(bb)) - lo
val sh = dz / to-float(n)
var res = none3()
println-all(["DZ " dz " LO " lo " SH " sh])
for i in 0 to n do :
val off = lo + ((0.5 + to-float(i)) * sh)
println-all(["I " i " OFF " off])
val sl = slice(num(off), mesh)
println-all(["SLICED " i])
save(str(string-join(["slice" i ".svg"])), sl)
val we = extrude(num(sh * 1.001), sl)
println-all(["EXTRUDED " i])
save(str(string-join(["slice" i ".stl"])), we)
res = res | zmov(num(off), we)
println-all(["UNION " i])
save(str(string-join(["slices" i ".stl"])), res)
res
save(str("slices.stl"), dice(sphere(num(16.0)), 13))
;; save(str("slices.stl"), dice(cube(num(5.0)), 13))
;; save(str("slices.stl"), dice(taper(num(10.0),num(5.0),num(1.0),circle(num(1.0))), 13))
;; save(str("slices.stl"), dice(load(str("fat-bear.stl")), 13))