From 93b641a68ff2e5df53b66cc2f61e83b1af63af23 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sun, 26 Apr 2020 21:13:43 -0400 Subject: [PATCH] fix new clipper union function --- js/geo-polygons.js | 12 ++++++++---- js/kiri-driver-sla.js | 8 ++++---- web/kiri/lang/en.js | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/js/geo-polygons.js b/js/geo-polygons.js index cfea45e0..0a7bc223 100644 --- a/js/geo-polygons.js +++ b/js/geo-polygons.js @@ -83,17 +83,21 @@ var gs_base_polygons = exports; return polys; }; - function fromClipperTreeUnion(tnode, z, minarea) { - let polys = [], poly; + function fromClipperTreeUnion(tnode, z, minarea, tops, parent) { + let polys = tops || [], poly; tnode.m_Childs.forEach(function(child) { poly = fromClipperNode(child, z); if (minarea && poly.area() < minarea) { return; } - polys.push(poly); + if (parent) { + parent.addInner(poly); + } else { + polys.push(poly); + } if (child.m_Childs) { - fromClipperTreeUnion(child, z, minarea); + fromClipperTreeUnion(child, z, minarea, polys, parent ? null : poly); } }); diff --git a/js/kiri-driver-sla.js b/js/kiri-driver-sla.js index e6980186..561608f3 100644 --- a/js/kiri-driver-sla.js +++ b/js/kiri-driver-sla.js @@ -101,7 +101,7 @@ let gs_kiri_sla = exports; polys.appendAll(slice.tops.map(t => t.poly.clone())); }); // 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 lastraft; for (let s=0; s p.clone(true).setZ(slice.z)); } 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; } diff --git a/web/kiri/lang/en.js b/web/kiri/lang/en.js index dc56caf9..6765ff9a 100644 --- a/web/kiri/lang/en.js +++ b/web/kiri/lang/en.js @@ -399,7 +399,7 @@ kiri.lang['en-us'] = { sa_otop_s: "open top", sa_otop_l: "if shell is enabled\nresults in an open top", 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_lton_s: "light on time",