use pre-computed clips in auto supports

This commit is contained in:
Stewart Allen 2021-06-25 22:29:33 -04:00
commit 6eaad0da93
2 changed files with 10 additions and 15 deletions

View file

@ -344,7 +344,7 @@
slice.height = height; slice.height = height;
slice.index = index; slice.index = index;
slice.thick = thick; slice.thick = thick;
slice.clips = clip; slice.clips = clip || slice.topSimples();
// debugging (non-threaded mode only) // debugging (non-threaded mode only)
let { debug, xray, view } = options; let { debug, xray, view } = options;
if (view && (debug || xray)) { if (view && (debug || xray)) {

View file

@ -98,7 +98,7 @@
danger: isDanger danger: isDanger
})); }));
} }
data.clip = POLY.offset(nutops.map(t => t.simple), clipOffset); data.clip = clipOffset ? POLY.offset(nutops.map(t => t.simple), clipOffset) : undefined;
data.tops = nutops; data.tops = nutops;
}; };
@ -680,7 +680,6 @@
} }
// add simple (low rez poly) where less accuracy is OK // add simple (low rez poly) where less accuracy is OK
// top.simple = top.poly.clean(true, undefined, CONF.clipper / 10);
top.simple = top.poly.simple(); top.simple = top.poly.simple();
let top_poly = [ top.poly ]; let top_poly = [ top.poly ];
@ -1164,11 +1163,10 @@
*/ */
async function doSupport(slice, proc, shadow, opt = {}) { async function doSupport(slice, proc, shadow, opt = {}) {
let maxBridge = proc.sliceSupportSpan || 5, let maxBridge = proc.sliceSupportSpan || 5,
minArea = proc.supportMinArea, minArea = proc.supportMinArea || 0.1,
pillarSize = proc.sliceSupportSize, pillarSize = proc.sliceSupportSize,
offset = proc.sliceSupportOffset, offset = proc.sliceSupportOffset,
gap = proc.sliceSupportGap, gap = proc.sliceSupportGap,
min = minArea || 0.01,
size = (pillarSize || 1), size = (pillarSize || 1),
tops = slice.topPolys(), tops = slice.topPolys(),
trimTo = tops; trimTo = tops;
@ -1245,6 +1243,7 @@
pillars.push(BASE.newPolygon().centerRectangle(point, size/2, size/2)); pillars.push(BASE.newPolygon().centerRectangle(point, size/2, size/2));
}); });
supports.appendAll(POLY.union(pillars, null, true));
// merge pillars and replace with convex hull of outer points (aka smoothing) // merge pillars and replace with convex hull of outer points (aka smoothing)
pillars = POLY.union(pillars, null, true).forEach(function(pillar) { pillars = POLY.union(pillars, null, true).forEach(function(pillar) {
supports.push(BASE.newPolygon().createConvexHull(pillar.points)); supports.push(BASE.newPolygon().createConvexHull(pillar.points));
@ -1271,15 +1270,13 @@
let trimmed = [], culled = []; let trimmed = [], culled = [];
// culled = supports;
// clip supports to shell offsets // clip supports to shell offsets
POLY.subtract(supports, down.topSimples(), trimmed, null, slice.z, min, { POLY.subtract(supports, down.topSimples(), trimmed, null, slice.z, minArea);
prof: opt.prof,
wasm: false
});
// set depth hint on support polys for infill density // set depth hint on support polys for infill density
trimmed.forEach(function(trim) { trimmed.forEach(function(trim) {
// if (trim.area() < 0.1) return; if (trim.area() < minArea) return;
culled.push(trim.setZ(down.z)); culled.push(trim.setZ(down.z));
}); });
@ -1306,12 +1303,10 @@
if (!supports) return; if (!supports) return;
// union supports // union supports
supports = POLY.union(supports, undefined, true); supports = POLY.setZ(POLY.union(supports, undefined, true), slice.z);
// trim to clip offsets // clip supports to slice clip offset (or shell if none)
if (slice.clips) {
POLY.subtract(supports, slice.clips, nsB, null, slice.z, min); POLY.subtract(supports, slice.clips, nsB, null, slice.z, min);
}
supports = nsB; supports = nsB;
// also trim to lower offsets, if they exist // also trim to lower offsets, if they exist