de-rez complex slices for support interference detection where it's less important

This commit is contained in:
Stewart Allen 2021-06-23 15:25:01 -04:00
commit a73faf8d05
2 changed files with 22 additions and 13 deletions

View file

@ -288,15 +288,7 @@
* @returns {Polygon[]} out
*/
function subtract(setA, setB, outA, outB, z, minArea) {
let clib = self.ClipperLib,
ctyp = clib.ClipType,
ptyp = clib.PolyType,
cfil = clib.PolyFillType,
clip = new clib.Clipper(),
ctre = new clib.PolyTree(),
sp1 = toClipper(setA),
sp2 = toClipper(setB),
min = minArea || 0.1,
let min = minArea || 0.1,
out = [];
function filter(from, to = []) {
@ -309,10 +301,17 @@
return to;
}
const JS = true;
if (true) {
let clib = self.ClipperLib,
ctyp = clib.ClipType,
ptyp = clib.PolyType,
cfil = clib.PolyFillType,
clip = new clib.Clipper(),
ctre = new clib.PolyTree(),
sp1 = toClipper(setA),
sp2 = toClipper(setB);
if (JS) {
// expensive but worth it?
// more expensive? worth it?
clip.StrictlySimple = true;
if (outA) {
clip.AddPaths(sp1, ptyp.ptSubject, true);

View file

@ -451,6 +451,7 @@
projectFlats(slice, solidLayers);
projectBridges(slice, solidLayers);
}, "layer deltas");
// console.log('start'); await BASE.util.ptimer(1000);
let promises = doConcurrent ? [] : undefined;
forSlices(0.35, promises ? 0.4 : 0.5, slice => {
let params = slice.params || spro;
@ -466,6 +467,7 @@
trackupdate(i / t, 0.4, 0.5);
});
}
// console.log('stop'); await BASE.util.ptimer(1000);
}
// sparse layers only present when non-vase mose and sparse % > 0
@ -1164,7 +1166,6 @@
gap = proc.sliceSupportGap,
min = minArea || 0.01,
size = (pillarSize || 1),
mergeDist = size * 3, // pillar merge dist
tops = slice.topPolys(),
trimTo = tops;
@ -1181,6 +1182,15 @@
down_tops = down ? down.topPolys() : null,
down_traces = down ? POLY.flatten(down.topShells().clone(true)) : null;
if (down_tops) {
// de-rez complex polys because it's not that important for supports
let points = down_tops.map(p => p.deepLength).reduce((a,v)=>a+v);
if (points > 200) {
down_tops = down_tops.map(p => p.clean(true, undefined, CONF.clipper / 10));
down_traces = down_traces.map(p => p.clean(true, undefined, CONF.clipper / 10));
}
}
// check if point is supported by layer below
function checkPointSupport(point) {
// skip points close to other support points