add flatten option to Array.append(). swap in new offset() method for expand() in rough offsetting. default disable depth first

This commit is contained in:
Stewart Allen 2020-11-02 10:32:53 -05:00
commit 209c36636b
4 changed files with 24 additions and 13 deletions

View file

@ -34,9 +34,13 @@
* @param v
* @returns {Array}
*/
AP.append = function(v) {
this.push(v);
return this;
AP.append = function(v, flat) {
if (flat) {
return this.appendAll(v);
} else {
this.push(v);
return this;
}
};
/**

View file

@ -520,17 +520,17 @@
// if specified, perform offset gap analysis
if (opt.gaps && polys.length) {
let negoff = offset(polys, -offs, {
let oneg = offset(polys, -offs, {
fill: opt.fill, join: opt.join, type: opt.type, z: opt.z, minArea: mina
});
let suba = [];
let diff = subtract(orig, negoff, suba, null, zed);
opt.gaps.push(suba);
let diff = subtract(orig, oneg, suba, null, zed);
opt.gaps.append(suba, opt.flat);
}
// if offset fails, consider last polygons as gap areas
if (opt.gaps && !polys.length) {
opt.gaps.push(orig);
opt.gaps.append(orig, opt.flat);
}
// if specified, perform up to *count* successive offsets
@ -538,7 +538,7 @@
// ensure opts has offset accumulator array
opt.outs = opt.outs || [];
// store polys in accumulator
opt.outs.push(polys);
opt.outs.append(polys, opt.flat);
if (opt.count > 1) {
// decrement count, increment depth
opt.count--;

View file

@ -437,7 +437,7 @@
camTabsOn: false,
camRoughPocket: false, // camPocketOnlyRough
camOutlinePocket: false, // camPocketOnlyFinish
camDepthFirst: true,
camDepthFirst: false,
camWideCutout: false,
camEaseDown: false,
camOriginTop: true,

View file

@ -693,10 +693,12 @@
}
// clone and flatten the shell with tops to offset array
shell.clone(true).forEach(function(poly) { poly.setZ(slice.z).flattenTo(offset) });
shell.clone(true).forEach(function(poly) {
poly.setZ(slice.z).flattenTo(offset);
});
POLY.flatten(tops, offset, true);
// only tab cut polys should be open
// only tab cut polys should be open (happens later)
offset.forEach(function(trace) {
trace.setClosed();
});
@ -705,7 +707,12 @@
offset = POLY.nest(offset);
// inset offset array by 1/2 diameter then by tool overlap %
POLY.expand(offset, - (diameter / 2 + stock), slice.z, outer, 0, -diameter * overlap);
POLY.offset(offset, [-(diameter / 2 + stock), -diameter * overlap], {
z: slice.z,
count: 999,
flat: true,
outs: outer
});
if (!pocket) {
// re-flatten offset polys
@ -718,7 +725,7 @@
// re-nest offset polys
// outer = POLY.nest(offset);
outer = offset;
// more outer
// add another wider pass to the cutout polygon(s)
if (widecut) {
POLY.expand(offset, diameter * overlap, slice.z, outer, 1);
}