1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-01-16 13:08:15 +01:00

Mods to allow the manifold experimetal option to be used.

This commit is contained in:
Chris Palmer 2024-02-10 01:05:24 +00:00
parent 9666c018a0
commit 38196e9f78
11 changed files with 21 additions and 12 deletions

View File

@ -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.

View File

@ -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 |

View File

@ -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=" ")

View File

@ -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:

View File

@ -73,7 +73,7 @@ module polyholes() {
// Alternating polyholes
//
translate([30, -40])
alt_polyhole_stl();
render_manifold() alt_polyhole_stl();
//
// Poly rings
//

View File

@ -57,7 +57,7 @@ module screws() {
}
}
translate([20, 60, -15])
polysink_stl();
render_manifold() polysink_stl();
}
if($preview)

View File

@ -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();

View File

@ -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

View File

@ -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();
}

View File

@ -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);
}
}

View File

@ -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);
}