add min sizing for poly cleanup in more cases

This commit is contained in:
Stewart Allen 2020-05-09 20:33:25 -04:00
commit 579fdaccfa
5 changed files with 18 additions and 15 deletions

View file

@ -62,21 +62,24 @@ var gs_base_polygons = exports;
return poly; return poly;
}; };
function fromClipperTree(tnode, z, tops, parent) { function fromClipperTree(tnode, z, tops, parent, minarea) {
var polys = tops || [], var polys = tops || [],
poly; poly,
min = minarea || 0.1;
tnode.m_Childs.forEach(function(child) { tnode.m_Childs.forEach(function(child) {
poly = fromClipperNode(child, z); poly = fromClipperNode(child, z);
// throw out all tiny polygons // throw out all tiny polygons
if (poly.area() < 0.1) return; if (poly.area() < min) {
return;
}
if (parent) { if (parent) {
parent.addInner(poly); parent.addInner(poly);
} else { } else {
polys.push(poly); polys.push(poly);
} }
if (child.m_Childs) { if (child.m_Childs) {
fromClipperTree(child, z, polys, parent ? null : poly); fromClipperTree(child, z, polys, parent ? null : poly, minarea);
} }
}); });
@ -298,7 +301,7 @@ var gs_base_polygons = exports;
if (clip.Execute(ctyp.ctDifference, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) { if (clip.Execute(ctyp.ctDifference, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) {
cleanClipperTree(ctre); cleanClipperTree(ctre);
filter(fromClipperTree(ctre, z), outA); filter(fromClipperTree(ctre, z, null, null, min), outA);
} }
} }
@ -313,7 +316,7 @@ var gs_base_polygons = exports;
if (clip.Execute(ctyp.ctDifference, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) { if (clip.Execute(ctyp.ctDifference, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) {
cleanClipperTree(ctre); cleanClipperTree(ctre);
filter(fromClipperTree(ctre, z), outB); filter(fromClipperTree(ctre, z, null, null, min), outB);
} }
} }
@ -416,7 +419,7 @@ var gs_base_polygons = exports;
* @param {Function} [collector] receives output of each pass * @param {Function} [collector] receives output of each pass
* @returns {Polygon[]} last offset * @returns {Polygon[]} last offset
*/ */
function expand(polys, distance, z, out, count, distance2, collector) { function expand(polys, distance, z, out, count, distance2, collector, min) {
// prepare alignments for clipper lib // prepare alignments for clipper lib
alignWindings(polys); alignWindings(polys);
polys.forEach(function(poly) { polys.forEach(function(poly) {
@ -440,7 +443,7 @@ var gs_base_polygons = exports;
}); });
coff.Execute(ctre, distance * fact); coff.Execute(ctre, distance * fact);
polys = fromClipperTree(ctre, z); polys = fromClipperTree(ctre, z, null, null, min);
if (out) out.appendAll(polys); if (out) out.appendAll(polys);
if (collector) collector(polys, count); if (collector) collector(polys, count);

View file

@ -167,7 +167,7 @@ let gs_kiri_sla = exports;
}, "slice"); }, "slice");
forSlices(slices, 10, (slice) => { forSlices(slices, 10, (slice) => {
if (slice.synth) return; if (slice.synth) return;
slice.doDiff(0.00001, 0.005, !process.slaOpenBase); slice.doDiff(0.000001, 0.005, !process.slaOpenBase);
}, "delta"); }, "delta");
if (solidLayers) { if (solidLayers) {
forSlices(slices, 10, (slice) => { forSlices(slices, 10, (slice) => {

View file

@ -1484,10 +1484,10 @@ var gs_kiri_init = exports;
slaSupport: UC.newGroup(LANG.sa_supp_m, null, {modes:SLA, group:"sla-support"}), slaSupport: UC.newGroup(LANG.sa_supp_m, null, {modes:SLA, group:"sla-support"}),
slaSupportLayers: UC.newInput(LANG.sa_slyr_s, {title:LANG.sa_slyr_l, convert:UC.toInt, bound:UC.bound(5,100), modes:SLA}), slaSupportLayers: UC.newInput(LANG.sa_slyr_s, {title:LANG.sa_slyr_l, convert:UC.toInt, bound:UC.bound(5,100), modes:SLA}),
slaSupportGap: UC.newInput(LANG.sa_slgp_s, {title:LANG.sa_slgp_l, convert:UC.toInt, bound:UC.bound(3,30), modes:SLA, expert:true}),
slaSupportDensity: UC.newInput(LANG.sa_sldn_s, {title:LANG.sa_sldn_l, convert:UC.toFloat, bound:UC.bound(0.01,0.9), modes:SLA}), slaSupportDensity: UC.newInput(LANG.sa_sldn_s, {title:LANG.sa_sldn_l, convert:UC.toFloat, bound:UC.bound(0.01,0.9), modes:SLA}),
slaSupportSize: UC.newInput(LANG.sa_slsz_s, {title:LANG.sa_slsz_l, convert:UC.toFloat, bound:UC.bound(0.1,1), modes:SLA}), slaSupportSize: UC.newInput(LANG.sa_slsz_s, {title:LANG.sa_slsz_l, convert:UC.toFloat, bound:UC.bound(0.1,1), modes:SLA}),
slaSupportPoints: UC.newInput(LANG.sa_slpt_s, {title:LANG.sa_slpt_l, convert:UC.toInt, bound:UC.bound(3,10), modes:SLA, expert:true}), slaSupportPoints: UC.newInput(LANG.sa_slpt_s, {title:LANG.sa_slpt_l, convert:UC.toInt, bound:UC.bound(3,10), modes:SLA, expert:true}),
slaSupportGap: UC.newInput(LANG.sa_slgp_s, {title:LANG.sa_slgp_l, convert:UC.toInt, bound:UC.bound(3,30), modes:SLA, expert:true}),
slaSupportEnable: UC.newBoolean(LANG.enable, onBooleanClick, {title:LANG.sl_slen_l, modes:SLA}), slaSupportEnable: UC.newBoolean(LANG.enable, onBooleanClick, {title:LANG.sl_slen_l, modes:SLA}),
slaOutput: UC.newGroup(LANG.sa_outp_m, null, {modes:SLA, group:"sla-first"}), slaOutput: UC.newGroup(LANG.sa_outp_m, null, {modes:SLA, group:"sla-first"}),

View file

@ -881,8 +881,8 @@ let gs_kiri_slice = exports;
if (expand) { if (expand) {
top.bridges = []; top.bridges = [];
bottom.flats = []; bottom.flats = [];
POLY.expand(bridges, expand, top.z, top.bridges, 1); POLY.expand(bridges, expand, top.z, top.bridges, 1, null, null, 0.0001);
POLY.expand(flats, expand, top.z, bottom.flats, 1); POLY.expand(flats, expand, top.z, bottom.flats, 1, null, null, 0.0001);
} else { } else {
top.bridges = bridges; top.bridges = bridges;
bottom.flats = flats; bottom.flats = flats;

View file

@ -428,16 +428,16 @@ kiri.lang['en-us'] = {
sa_iflw_l: "hatch line width\nin millimeters", sa_iflw_l: "hatch line width\nin millimeters",
sa_supp_m: "support", sa_supp_m: "support",
sa_slyr_s: "layers", sa_slyr_s: "base layers",
sa_slyr_l: "base support layers\nvalue range 0-10", sa_slyr_l: "base support layers\nvalue range 0-10",
sa_slgp_s: "gap layers",
sa_slgp_l: "number of layers between\nraft and bottom of object",
sa_sldn_s: "density", sa_sldn_s: "density",
sa_sldn_l: "used to compute the\nnumber of support pillars\n0.0-1.0 (0 = disable)", sa_sldn_l: "used to compute the\nnumber of support pillars\n0.0-1.0 (0 = disable)",
sa_slsz_s: "size", sa_slsz_s: "size",
sa_slsz_l: "max size of a\nsupport pillar\nin millimeters", sa_slsz_l: "max size of a\nsupport pillar\nin millimeters",
sa_slpt_s: "points", sa_slpt_s: "points",
sa_slpt_l: "number of points in\neach support pillar\nin millimeters", sa_slpt_l: "number of points in\neach support pillar\nin millimeters",
sa_slgp_s: "gap layers",
sa_slgp_l: "number of layers between\nraft and bottom of object",
sl_slen_l: "enable supports", sl_slen_l: "enable supports",
sa_outp_m: "output", sa_outp_m: "output",