correct dogbone angles. handle inner polys
This commit is contained in:
parent
83de534a52
commit
79b09ee73c
2 changed files with 14 additions and 9 deletions
|
|
@ -1594,7 +1594,7 @@
|
|||
camOutlineDown: UC.newInput(LANG.cc_sdwn_s, {title:LANG.cc_sdwn_l, convert:UC.toFloat, modes:CAM, units:true}),
|
||||
camOutlineSpeed: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, modes:CAM, units:true}),
|
||||
camOutlinePlunge: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toInt, modes:CAM, units:true}),
|
||||
camOutlineDogbone: UC.newBoolean(LANG.co_dogb_s, onBooleanClick, {title:LANG.co_dogb_l, modes:CAM}),
|
||||
camOutlineDogbone: UC.newBoolean(LANG.co_dogb_s, onBooleanClick, {title:LANG.co_dogb_l, modes:CAM, show:() => { return !UI.camOutlineWide.checked }}),
|
||||
camOutlineIn: UC.newBoolean(LANG.co_olin_s, onBooleanClick, {title:LANG.co_olin_l, modes:CAM, show:() => { return !UI.camOutlineOut.checked }}),
|
||||
camOutlineOut: UC.newBoolean(LANG.co_olot_s, onBooleanClick, {title:LANG.co_olot_l, modes:CAM, show:() => { return !UI.camOutlineIn.checked }}),
|
||||
camOutlineWide: UC.newBoolean(LANG.co_wide_s, onBooleanClick, {title:LANG.co_wide_l, modes:CAM, show:() => { return !UI.camOutlineIn.checked }}),
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@
|
|||
offset = cutTabs(tabs, offset, slice.z);
|
||||
}
|
||||
|
||||
if (proc.camOutlineDogbone) {
|
||||
if (proc.camOutlineDogbone && !procOutlineWide) {
|
||||
CAM.addDogbones(offset, outlineToolDiam / 4);
|
||||
}
|
||||
|
||||
|
|
@ -571,11 +571,12 @@
|
|||
ondone();
|
||||
};
|
||||
|
||||
CAM.addDogbones = function(poly, dist) {
|
||||
CAM.addDogbones = function(poly, dist, reverse) {
|
||||
if (Array.isArray(poly)) {
|
||||
return poly.forEach(p => CAM.addDogbones(p, dist));
|
||||
}
|
||||
let isCW = poly.isClockwise();
|
||||
if (reverse || poly.parent) isCW = !isCW;
|
||||
let oldpts = poly.points.slice();
|
||||
let lastpt = oldpts[oldpts.length - 1];
|
||||
let lastsl = lastpt.slopeTo(oldpts[0]).toUnit();
|
||||
|
|
@ -584,14 +585,15 @@
|
|||
let nextpt = oldpts[i % oldpts.length];
|
||||
let nextsl = lastpt.slopeTo(nextpt).toUnit();
|
||||
let adiff = lastsl.angleDiff(nextsl, true);
|
||||
if (isCW && adiff > 0) {
|
||||
let newa = BASE.newSlopeFromAngle(lastsl.angle - adiff / 2);
|
||||
let bdiff = ((adiff < 0 ? (180 - adiff) : (180 + adiff)) / 2) + 180;
|
||||
if (isCW && adiff > 45) {
|
||||
let newa = BASE.newSlopeFromAngle(lastsl.angle + bdiff);
|
||||
newpts.push(lastpt.projectOnSlope(newa, dist));
|
||||
newpts.push(lastpt.clone());
|
||||
console.log('CW dogbone at', lastpt);
|
||||
} else if (!isCW && adiff < 0) {
|
||||
console.log('CCW dogbone at', lastpt);
|
||||
let newa = BASE.newSlopeFromAngle(lastsl.angle - adiff / 2);
|
||||
console.log('CW dogbone', lastsl.angle.round(2), adiff.round(2));
|
||||
} else if (!isCW && adiff < -45) {
|
||||
console.log('CCW dogbone', lastsl.angle.round(2), ':', nextsl.angle.round(2), '=', adiff.round(2));
|
||||
let newa = BASE.newSlopeFromAngle(lastsl.angle - bdiff);
|
||||
newpts.push(lastpt.projectOnSlope(newa, dist));
|
||||
newpts.push(lastpt.clone());
|
||||
}
|
||||
|
|
@ -603,6 +605,9 @@
|
|||
}
|
||||
poly.points = newpts;
|
||||
poly.length = newpts.length;
|
||||
if (poly.inner) {
|
||||
CAM.addDogbones(poly.inner, dist, true);
|
||||
}
|
||||
};
|
||||
|
||||
CAM.traces = function(settings, widget) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue