fix new clipper union function

This commit is contained in:
Stewart Allen 2020-04-26 21:13:43 -04:00
commit 93b641a68f
3 changed files with 13 additions and 9 deletions

View file

@ -83,17 +83,21 @@ var gs_base_polygons = exports;
return polys; return polys;
}; };
function fromClipperTreeUnion(tnode, z, minarea) { function fromClipperTreeUnion(tnode, z, minarea, tops, parent) {
let polys = [], poly; let polys = tops || [], poly;
tnode.m_Childs.forEach(function(child) { tnode.m_Childs.forEach(function(child) {
poly = fromClipperNode(child, z); poly = fromClipperNode(child, z);
if (minarea && poly.area() < minarea) { if (minarea && poly.area() < minarea) {
return; return;
} }
polys.push(poly); if (parent) {
parent.addInner(poly);
} else {
polys.push(poly);
}
if (child.m_Childs) { if (child.m_Childs) {
fromClipperTreeUnion(child, z, minarea); fromClipperTreeUnion(child, z, minarea, polys, parent ? null : poly);
} }
}); });

View file

@ -101,7 +101,7 @@ let gs_kiri_sla = exports;
polys.appendAll(slice.tops.map(t => t.poly.clone())); polys.appendAll(slice.tops.map(t => t.poly.clone()));
}); });
// p.clone prevents inner voids from forming // p.clone prevents inner voids from forming
let union = POLY.union(polys,0).map(p => p.clone()); let union = POLY.union(polys).map(p => p.clone());
let expand = POLY.expand(union, off, zoff, [], 1); let expand = POLY.expand(union, off, zoff, [], 1);
let lastraft; let lastraft;
for (let s=0; s<layers + gap; s++) { for (let s=0; s<layers + gap; s++) {
@ -178,7 +178,7 @@ let gs_kiri_sla = exports;
let traces = POLY.nest(POLY.flatten(slice.gatherTraces([]))); let traces = POLY.nest(POLY.flatten(slice.gatherTraces([])));
let trims = slice.solids.trimmed || []; let trims = slice.solids.trimmed || [];
traces.appendAll(trims); traces.appendAll(trims);
let union = POLY.union(traces,0); let union = POLY.union(traces);
slice.solids.unioned = union; slice.solids.unioned = union;
}, "solid"); }, "solid");
} else { } else {
@ -563,14 +563,14 @@ let gs_kiri_sla = exports;
} }
if (!cached) { if (!cached) {
fill = POLY.union(fill,0); fill = POLY.union(fill);
fill_cache[seq_c] = fill; fill_cache[seq_c] = fill;
} else { } else {
fill = cached.slice().map(p => p.clone(true).setZ(slice.z)); fill = cached.slice().map(p => p.clone(true).setZ(slice.z));
} }
fill = POLY.trimTo(fill, slice.tops.map(t => t.poly)); fill = POLY.trimTo(fill, slice.tops.map(t => t.poly));
fill = POLY.union(slice.solids.unioned.appendAll(fill),0); fill = POLY.union(slice.solids.unioned.appendAll(fill));
slice.solids.unioned = fill; slice.solids.unioned = fill;
} }

View file

@ -399,7 +399,7 @@ kiri.lang['en-us'] = {
sa_otop_s: "open top", sa_otop_s: "open top",
sa_otop_l: "if shell is enabled\nresults in an open top", sa_otop_l: "if shell is enabled\nresults in an open top",
sa_obas_s: "open base", sa_obas_s: "open base",
sa_obas_l: "if shell is enabled\nresults in an open base", sa_obas_l: "if shell is enabled\nresults in an open base\ndisabled with supports",
sa_layr_m: "layers", sa_layr_m: "layers",
sa_lton_s: "light on time", sa_lton_s: "light on time",