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:
parent
a6e15908e1
commit
209c36636b
4 changed files with 24 additions and 13 deletions
|
|
@ -34,9 +34,13 @@
|
||||||
* @param v
|
* @param v
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
AP.append = function(v) {
|
AP.append = function(v, flat) {
|
||||||
this.push(v);
|
if (flat) {
|
||||||
return this;
|
return this.appendAll(v);
|
||||||
|
} else {
|
||||||
|
this.push(v);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -520,17 +520,17 @@
|
||||||
|
|
||||||
// if specified, perform offset gap analysis
|
// if specified, perform offset gap analysis
|
||||||
if (opt.gaps && polys.length) {
|
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
|
fill: opt.fill, join: opt.join, type: opt.type, z: opt.z, minArea: mina
|
||||||
});
|
});
|
||||||
let suba = [];
|
let suba = [];
|
||||||
let diff = subtract(orig, negoff, suba, null, zed);
|
let diff = subtract(orig, oneg, suba, null, zed);
|
||||||
opt.gaps.push(suba);
|
opt.gaps.append(suba, opt.flat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if offset fails, consider last polygons as gap areas
|
// if offset fails, consider last polygons as gap areas
|
||||||
if (opt.gaps && !polys.length) {
|
if (opt.gaps && !polys.length) {
|
||||||
opt.gaps.push(orig);
|
opt.gaps.append(orig, opt.flat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if specified, perform up to *count* successive offsets
|
// if specified, perform up to *count* successive offsets
|
||||||
|
|
@ -538,7 +538,7 @@
|
||||||
// ensure opts has offset accumulator array
|
// ensure opts has offset accumulator array
|
||||||
opt.outs = opt.outs || [];
|
opt.outs = opt.outs || [];
|
||||||
// store polys in accumulator
|
// store polys in accumulator
|
||||||
opt.outs.push(polys);
|
opt.outs.append(polys, opt.flat);
|
||||||
if (opt.count > 1) {
|
if (opt.count > 1) {
|
||||||
// decrement count, increment depth
|
// decrement count, increment depth
|
||||||
opt.count--;
|
opt.count--;
|
||||||
|
|
|
||||||
|
|
@ -437,7 +437,7 @@
|
||||||
camTabsOn: false,
|
camTabsOn: false,
|
||||||
camRoughPocket: false, // camPocketOnlyRough
|
camRoughPocket: false, // camPocketOnlyRough
|
||||||
camOutlinePocket: false, // camPocketOnlyFinish
|
camOutlinePocket: false, // camPocketOnlyFinish
|
||||||
camDepthFirst: true,
|
camDepthFirst: false,
|
||||||
camWideCutout: false,
|
camWideCutout: false,
|
||||||
camEaseDown: false,
|
camEaseDown: false,
|
||||||
camOriginTop: true,
|
camOriginTop: true,
|
||||||
|
|
|
||||||
|
|
@ -693,10 +693,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// clone and flatten the shell with tops to offset array
|
// 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);
|
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) {
|
offset.forEach(function(trace) {
|
||||||
trace.setClosed();
|
trace.setClosed();
|
||||||
});
|
});
|
||||||
|
|
@ -705,7 +707,12 @@
|
||||||
offset = POLY.nest(offset);
|
offset = POLY.nest(offset);
|
||||||
|
|
||||||
// inset offset array by 1/2 diameter then by tool overlap %
|
// 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) {
|
if (!pocket) {
|
||||||
// re-flatten offset polys
|
// re-flatten offset polys
|
||||||
|
|
@ -718,7 +725,7 @@
|
||||||
// re-nest offset polys
|
// re-nest offset polys
|
||||||
// outer = POLY.nest(offset);
|
// outer = POLY.nest(offset);
|
||||||
outer = offset;
|
outer = offset;
|
||||||
// more outer
|
// add another wider pass to the cutout polygon(s)
|
||||||
if (widecut) {
|
if (widecut) {
|
||||||
POLY.expand(offset, diameter * overlap, slice.z, outer, 1);
|
POLY.expand(offset, diameter * overlap, slice.z, outer, 1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue