diff --git a/global_defs.scad b/global_defs.scad index 03a85bc..c9c73f1 100644 --- a/global_defs.scad +++ b/global_defs.scad @@ -41,13 +41,14 @@ pp1_colour = is_undef($pp1_colour) ? rr_green : $pp1_colour;// pri pp2_colour = is_undef($pp2_colour) ? crimson : $pp2_colour;// printed part colour 2 pp3_colour = is_undef($pp3_colour) ? "SteelBlue" : $pp3_colour;// printed part colour 3 pp4_colour = is_undef($pp4_colour) ? "darkorange" : $pp4_colour;// printed part colour 4 - +manifold = is_undef($manifold) ? false : $manifold; // Manifold library being used instead of cgal // Minimum wall is about two filaments wide but we extrude it closer to get better bonding squeezed_wall = $preview ? 2 * extrusion_width - layer_height * (1 - PI / 4) : extrusion_width - layer_height / 2 + nozzle / 2 + extrusion_width / 2; -inf = 1e10; // very big +inf = 1e10; // very big +big = manifold ? 1e3 : inf; // Not too big for manifold eps = 1/128; // small fudge factor to stop CSG barfing on coincident faces. fa = is_undef($vitamin_fa) ? 6 : $vitamin_fa; // Used for drawing vitamins, rather than printing. diff --git a/readme.md b/readme.md index 8320177..61c47d7 100644 --- a/readme.md +++ b/readme.md @@ -7539,7 +7539,7 @@ Original version by Doug Moen on the OpenSCAD forum | Module | Description | |:--- |:--- | | `box(xmin, ymin, zmin, xmax, ymax, zmax)` | Construct a box given its bounds | -| `clip(xmin = -inf, ymin = -inf, zmin = -inf, xmax = inf, ymax = inf, zmax = inf, convexity = 1)` | Clip child to specified boundaries | +| `clip(xmin = -big, ymin = -big, zmin = -big, xmax = big, ymax = big, zmax = big, convexity = 1)` | Clip child to specified boundaries | ![clip](tests/png/clip.png) @@ -7585,6 +7585,7 @@ See [global_defs.scad](../../global_defs.scad) for a list of global constants. | `extrude_if(h, center = true)` | Extrudes 2D object to 3D when `h` is nonzero, otherwise leaves it 2D | | `hflip(flip=true)` | Invert children by doing a 180° flip around the Y axis | | `render_if(render = true, convexity = 2)` | Renders an object if `render` is true, otherwise leaves it unrendered | +| `render_manifold()` | Render if manifold to work around convexity bug in manifold | | `right_triangle(width, height, h, center = true)` | A right angled triangle with the 90° corner at the origin. 3D when `h` is nonzero, otherwise 2D | | `semi_circle(r, d = undef)` | A semi circle in the positive Y domain | | `translate_z(z)` | Shortcut for Z only translations | diff --git a/scripts/openscad.py b/scripts/openscad.py index 1106aca..a39b882 100644 --- a/scripts/openscad.py +++ b/scripts/openscad.py @@ -26,6 +26,8 @@ import subprocess, sys def run_list(args, silent = False, verbose = False): cmd = ["openscad"] + args + ["--hardwarnings"] + if "-D$manifold=true" in args: + cmd += ["--enable"] + ["manifold"] if not silent: for arg in cmd: print(arg, end=" ") diff --git a/scripts/options.py b/scripts/options.py index cd11138..8d965a0 100644 --- a/scripts/options.py +++ b/scripts/options.py @@ -26,8 +26,9 @@ def check_options(dir = '.'): global options, options_mtime options = { "show_threads": str(os.getenv("NOPSCADLIB_SHOW_THREADS")), - "vitamin_fa": str(os.getenv("NOPSCADLIB_VITAMIN_FA")), - "vitamin_fs": str(os.getenv("NOPSCADLIB_VITAMIN_FS")) + "vitamin_fa" : str(os.getenv("NOPSCADLIB_VITAMIN_FA")), + "vitamin_fs" : str(os.getenv("NOPSCADLIB_VITAMIN_FS")), + "manifold" : str(os.getenv("NOPSCADLIB_MANIFOLD")) } options_fname = dir + '/options.json' try: diff --git a/tests/polyholes.scad b/tests/polyholes.scad index 8cf7528..35822fe 100644 --- a/tests/polyholes.scad +++ b/tests/polyholes.scad @@ -73,7 +73,7 @@ module polyholes() { // Alternating polyholes // translate([30, -40]) - alt_polyhole_stl(); + render_manifold() alt_polyhole_stl(); // // Poly rings // diff --git a/tests/screws.scad b/tests/screws.scad index 16decc0..638263d 100644 --- a/tests/screws.scad +++ b/tests/screws.scad @@ -57,7 +57,7 @@ module screws() { } } translate([20, 60, -15]) - polysink_stl(); + render_manifold() polysink_stl(); } if($preview) diff --git a/utils/core/clip.scad b/utils/core/clip.scad index 1d79ddb..cc1321d 100644 --- a/utils/core/clip.scad +++ b/utils/core/clip.scad @@ -41,7 +41,7 @@ module box(xmin, ymin, zmin, xmax, ymax, zmax) //! Construct a box given its bou [0,2,3,1]] // left ); -module clip(xmin = -inf, ymin = -inf, zmin = -inf, xmax = inf, ymax = inf, zmax = inf, convexity = 1) //! Clip child to specified boundaries +module clip(xmin = -big, ymin = -big, zmin = -big, xmax = big, ymax = big, zmax = big, convexity = 1) //! Clip child to specified boundaries render(convexity = convexity) intersection() { children(); diff --git a/utils/core/global.scad b/utils/core/global.scad index 36cebfa..7dbebb0 100644 --- a/utils/core/global.scad +++ b/utils/core/global.scad @@ -74,6 +74,10 @@ module render_if(render = true, convexity = 2) //! Renders an object if `re else children(); +module render_manifold() //! Render if manifold to work around convexity bug in manifold + render_if(manifold) + children(); + module extrude_if(h, center = true) //! Extrudes 2D object to 3D when `h` is nonzero, otherwise leaves it 2D if(h) linear_extrude(h, center = center, convexity = 5) // 3D diff --git a/utils/offset.scad b/utils/offset.scad index 8c13d3f..97374e3 100644 --- a/utils/offset.scad +++ b/utils/offset.scad @@ -47,11 +47,11 @@ module offset_3D(r, chamfer_base = false) { //! Offset 3D shape by specified rad else if(r < 0) render() difference() { - cube(inf / 2, center = true); + cube(big / 2, center = true); minkowski() { difference() { - cube(inf, center = true); + cube(big, center = true); children(); } diff --git a/utils/pcb_utils.scad b/utils/pcb_utils.scad index 3447696..207b960 100644 --- a/utils/pcb_utils.scad +++ b/utils/pcb_utils.scad @@ -52,6 +52,6 @@ module cylindrical_wrap(r, h = eps) { //! Wrap a 2D child extruded to height `h` translate([(sides / 2 - i) * -dx, 0]) children(); - square([dx, inf], center = true); + square([dx, big], center = true); } } diff --git a/vitamins/psu.scad b/vitamins/psu.scad index 3083667..017a7b8 100644 --- a/vitamins/psu.scad +++ b/vitamins/psu.scad @@ -161,7 +161,7 @@ module psu(type) { //! Draw a power supply fan_holes(fan.z, h = 0); difference() { - square(inf, true); + square(big, true); fan_guard(fan.z, thickness = 0, grill = true); }