add dogbones support to traces ops
This commit is contained in:
parent
2353c33ef3
commit
956a694d86
5 changed files with 20 additions and 3 deletions
|
|
@ -292,18 +292,25 @@ CAM.addDogbones = function(poly, dist, reverse) {
|
|||
if (Array.isArray(poly)) {
|
||||
return poly.forEach(p => CAM.addDogbones(p, dist));
|
||||
}
|
||||
if (poly.open) return;
|
||||
// if (poly.open) return;
|
||||
let open = poly.open;
|
||||
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();
|
||||
let newpts = [ ];
|
||||
for (let i=0; i<oldpts.length + 1; i++) {
|
||||
for (let i=0; i<oldpts.length + (open ? 0 : 1); i++) {
|
||||
let nextpt = oldpts[i % oldpts.length];
|
||||
let nextsl = lastpt.slopeTo(nextpt).toUnit();
|
||||
let adiff = lastsl.angleDiff(nextsl, true);
|
||||
let bdiff = ((adiff < 0 ? (180 - adiff) : (180 + adiff)) / 2) + 180;
|
||||
if (open && i === 0) {
|
||||
lastsl = nextsl;
|
||||
lastpt = nextpt;
|
||||
newpts.push(nextpt);
|
||||
continue;
|
||||
}
|
||||
if (isCW && adiff > 45) {
|
||||
let newa = base.newSlopeFromAngle(lastsl.angle + bdiff);
|
||||
newpts.push(lastpt.projectOnSlope(newa, dist));
|
||||
|
|
|
|||
Loading…
Reference in a new issue