add min sizing for poly cleanup in more cases
This commit is contained in:
parent
b59cf7e909
commit
579fdaccfa
5 changed files with 18 additions and 15 deletions
|
|
@ -62,21 +62,24 @@ var gs_base_polygons = exports;
|
|||
return poly;
|
||||
};
|
||||
|
||||
function fromClipperTree(tnode, z, tops, parent) {
|
||||
function fromClipperTree(tnode, z, tops, parent, minarea) {
|
||||
var polys = tops || [],
|
||||
poly;
|
||||
poly,
|
||||
min = minarea || 0.1;
|
||||
|
||||
tnode.m_Childs.forEach(function(child) {
|
||||
poly = fromClipperNode(child, z);
|
||||
// throw out all tiny polygons
|
||||
if (poly.area() < 0.1) return;
|
||||
if (poly.area() < min) {
|
||||
return;
|
||||
}
|
||||
if (parent) {
|
||||
parent.addInner(poly);
|
||||
} else {
|
||||
polys.push(poly);
|
||||
}
|
||||
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)) {
|
||||
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)) {
|
||||
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
|
||||
* @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
|
||||
alignWindings(polys);
|
||||
polys.forEach(function(poly) {
|
||||
|
|
@ -440,7 +443,7 @@ var gs_base_polygons = exports;
|
|||
});
|
||||
|
||||
coff.Execute(ctre, distance * fact);
|
||||
polys = fromClipperTree(ctre, z);
|
||||
polys = fromClipperTree(ctre, z, null, null, min);
|
||||
|
||||
if (out) out.appendAll(polys);
|
||||
if (collector) collector(polys, count);
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ let gs_kiri_sla = exports;
|
|||
}, "slice");
|
||||
forSlices(slices, 10, (slice) => {
|
||||
if (slice.synth) return;
|
||||
slice.doDiff(0.00001, 0.005, !process.slaOpenBase);
|
||||
slice.doDiff(0.000001, 0.005, !process.slaOpenBase);
|
||||
}, "delta");
|
||||
if (solidLayers) {
|
||||
forSlices(slices, 10, (slice) => {
|
||||
|
|
|
|||
|
|
@ -1484,10 +1484,10 @@ var gs_kiri_init = exports;
|
|||
|
||||
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}),
|
||||
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}),
|
||||
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}),
|
||||
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}),
|
||||
|
||||
slaOutput: UC.newGroup(LANG.sa_outp_m, null, {modes:SLA, group:"sla-first"}),
|
||||
|
|
|
|||
|
|
@ -881,8 +881,8 @@ let gs_kiri_slice = exports;
|
|||
if (expand) {
|
||||
top.bridges = [];
|
||||
bottom.flats = [];
|
||||
POLY.expand(bridges, expand, top.z, top.bridges, 1);
|
||||
POLY.expand(flats, expand, top.z, bottom.flats, 1);
|
||||
POLY.expand(bridges, expand, top.z, top.bridges, 1, null, null, 0.0001);
|
||||
POLY.expand(flats, expand, top.z, bottom.flats, 1, null, null, 0.0001);
|
||||
} else {
|
||||
top.bridges = bridges;
|
||||
bottom.flats = flats;
|
||||
|
|
|
|||
|
|
@ -428,16 +428,16 @@ kiri.lang['en-us'] = {
|
|||
sa_iflw_l: "hatch line width\nin millimeters",
|
||||
|
||||
sa_supp_m: "support",
|
||||
sa_slyr_s: "layers",
|
||||
sa_slyr_s: "base layers",
|
||||
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_l: "used to compute the\nnumber of support pillars\n0.0-1.0 (0 = disable)",
|
||||
sa_slsz_s: "size",
|
||||
sa_slsz_l: "max size of a\nsupport pillar\nin millimeters",
|
||||
sa_slpt_s: "points",
|
||||
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",
|
||||
|
||||
sa_outp_m: "output",
|
||||
|
|
|
|||
Loading…
Reference in a new issue