Merge pull request #362 from bakedPotatoLord/outline-order
Outline order
This commit is contained in:
commit
058f983249
1 changed files with 33 additions and 12 deletions
|
|
@ -628,12 +628,20 @@ class OpOutline extends CamOp {
|
||||||
} else {
|
} else {
|
||||||
if (op.wide) {
|
if (op.wide) {
|
||||||
let stepover = toolDiam * op.step;
|
let stepover = toolDiam * op.step;
|
||||||
for (let c = (op.steps || 1); c > 0; c--)
|
let wideCuts = [] //accumulator for wide cuts
|
||||||
offset.slice().forEach(op => {
|
for (let c = (op.steps || 1); c > 0; c--){
|
||||||
// clone removes inners but the real solution is
|
offset.slice().forEach(op => {
|
||||||
// to limit expanded shells to through holes
|
// clone removes inners but the real solution is
|
||||||
POLY.expand([op.clone(true)], stepover, slice.z, offset, 1);
|
// to limit expanded shells to through holes
|
||||||
});
|
let wideCut = POLY.expand([op.clone(true)], stepover*c, slice.z, [], 1);
|
||||||
|
wideCut.forEach(cut =>{ //set order of cuts when wide
|
||||||
|
cut.order = c
|
||||||
|
if(cut.inner) cut.inner.forEach(inn =>{ inn.order = c })
|
||||||
|
});
|
||||||
|
wideCuts.push(...wideCut)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
offset.appendAll(wideCuts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -697,7 +705,10 @@ class OpOutline extends CamOp {
|
||||||
|
|
||||||
for (let slice of sliceOut) {
|
for (let slice of sliceOut) {
|
||||||
let polys = [], t = [], c = [];
|
let polys = [], t = [], c = [];
|
||||||
POLY.flatten(slice.camLines).forEach(function (poly) {
|
let lines =POLY.flatten(slice.camLines)
|
||||||
|
// console.log(lines);
|
||||||
|
lines.forEach((poly)=> {
|
||||||
|
poly.order = poly.order ?? 0;
|
||||||
let child = poly.parent;
|
let child = poly.parent;
|
||||||
if (depthFirst) { poly = poly.clone(); poly.parent = child ? 1 : 0 }
|
if (depthFirst) { poly = poly.clone(); poly.parent = child ? 1 : 0 }
|
||||||
if (child) c.push(poly); else t.push(poly);
|
if (child) c.push(poly); else t.push(poly);
|
||||||
|
|
@ -713,11 +724,21 @@ class OpOutline extends CamOp {
|
||||||
if (depthFirst) {
|
if (depthFirst) {
|
||||||
depthData.push(polys);
|
depthData.push(polys);
|
||||||
} else {
|
} else {
|
||||||
printPoint = poly2polyEmit(polys, printPoint, function(poly, index, count) {
|
let orderSplit = {}
|
||||||
poly.forEachPoint(function(point, pidx, points, offset) {
|
polys.forEach(poly => {
|
||||||
camOut(point.clone(), offset !== 0);
|
if(poly.order in orderSplit) orderSplit[poly.order].push(poly);
|
||||||
}, poly.isClosed(), index);
|
else orderSplit[poly.order] = [poly];
|
||||||
}, { swapdir: false });
|
})
|
||||||
|
Object.entries(orderSplit) //split the polys by order
|
||||||
|
.sort((a,b) => -(a[0] - b[0] )) //sort by order (highest first)
|
||||||
|
.forEach(([order, orderPolys]) => { // emit based on closest for each order
|
||||||
|
// console.log({order, orderPolys});
|
||||||
|
printPoint = poly2polyEmit(orderPolys, printPoint, function(poly, index, count) {
|
||||||
|
poly.forEachPoint(function(point, pidx, points, offset) {
|
||||||
|
camOut(point.clone(), offset !== 0);
|
||||||
|
}, poly.isClosed(), index);
|
||||||
|
}, { swapdir: false });
|
||||||
|
})
|
||||||
newLayer();
|
newLayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue