Last active
January 29, 2021 13:56
-
-
Save ochafik/ede7e8eecd228e754cb4f2e96ae7164d to your computer and use it in GitHub Desktop.
OpenSCAD file with an irregular pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Context: ochafik@'s attempts to speed up OpenSCAD | |
// fast-union feature: https://github.com/openscad/openscad/pull/3636 | |
// lazier union features: https://github.com/openscad/openscad/pull/3637 | |
// | |
// (and parallelization attempts, not sent as PRs yet) | |
// | |
// fast-union, lazy-union, push-transforms-down-unions, lazy-module and flatten-children all help here! | |
// openscad --enable=fast-union cube-with-half-spheres-dents.scad -o cube-with-half-spheres-dents.stl | |
top_transform = true; | |
top_union = true; | |
N = 5; | |
size = 2; | |
$fn=12; | |
module grid(N) | |
{ | |
for (i=[0:N-1], j=[0:N-1]) translate([i * size, j * size, 0]) | |
{ | |
sphere(d=1, $fn=16); | |
difference() { | |
h = 1 + (i + N * j) / pow(N, 2); | |
// Explicit union here as difference isn't optimized by fast-union yet. | |
// (to be done soon) | |
union() { | |
hull() { | |
cube(h, center=true); | |
cylinder(h / 2 - 0.01, d=h * 1.3); | |
} | |
cylinder(h, r=0.45); | |
translate([0, 0.5, 0]) | |
cylinder(h, r=0.2); | |
} | |
} | |
} | |
} | |
if (top_union) | |
union() { | |
if (top_transform) | |
translate([0, 0, 1]) | |
grid(N); | |
else | |
grid(N); | |
} | |
else if (top_transform) | |
translate([0, 0, 1]) | |
grid(N); | |
else | |
grid(N); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment