fix infill offsetting. implement point reduction. fix move to start on layer up
This commit is contained in:
parent
813ae0d9e6
commit
cc2615db71
2 changed files with 22 additions and 9 deletions
|
|
@ -170,6 +170,9 @@ function thin_type_3(params) {
|
||||||
let noodleWidth = offsetN * count;
|
let noodleWidth = offsetN * count;
|
||||||
let { noodle, remain } = top.poly.noodle(noodleWidth);
|
let { noodle, remain } = top.poly.noodle(noodleWidth);
|
||||||
|
|
||||||
|
// re-expand inner offset so fill offsets align properly with expectation
|
||||||
|
remain = POLY.offset(remain, offsetN / 2);
|
||||||
|
|
||||||
// render inset "noodle"
|
// render inset "noodle"
|
||||||
// shells.appendAll(noodle);
|
// shells.appendAll(noodle);
|
||||||
|
|
||||||
|
|
@ -188,7 +191,7 @@ function thin_type_3(params) {
|
||||||
let polys = [];
|
let polys = [];
|
||||||
|
|
||||||
for (let i=0; i<count; i++) {
|
for (let i=0; i<count; i++) {
|
||||||
let remain = [];
|
let next = [];
|
||||||
|
|
||||||
// process each top level noodle separately
|
// process each top level noodle separately
|
||||||
for (let n of noodle)
|
for (let n of noodle)
|
||||||
|
|
@ -202,16 +205,16 @@ function thin_type_3(params) {
|
||||||
shell: i + 1,
|
shell: i + 1,
|
||||||
lines,
|
lines,
|
||||||
polys,
|
polys,
|
||||||
remain,
|
remain: next,
|
||||||
traces,
|
traces,
|
||||||
brute: false,
|
brute: false,
|
||||||
showChainIntersect: false
|
showChainIntersect: false
|
||||||
});
|
});
|
||||||
|
|
||||||
// show remaining noodle after single trace
|
// show remaining noodle after single trace
|
||||||
if (debugRemain) polys.push(...POLY.setZ(POLY.flatten(remain), z));
|
if (debugRemain) polys.push(...POLY.setZ(POLY.flatten(next), z));
|
||||||
|
|
||||||
noodle = remain;
|
noodle = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log({ lines, polys, trace });
|
// console.log({ lines, polys, trace });
|
||||||
|
|
@ -471,25 +474,34 @@ function trace_noodle(noodle, noodleWidth, minR, midR, maxR, opt = {}) {
|
||||||
nupoly.push(new Point(min.x, min.y));
|
nupoly.push(new Point(min.x, min.y));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let npo;
|
||||||
if (pop.length === 1) {
|
if (pop.length === 1) {
|
||||||
// let rad_step = ((pop[0] * sstep) | 0) / sstep;
|
// let rad_step = ((pop[0] * sstep) | 0) / sstep;
|
||||||
// for single wall place it exactly on medial axis
|
// for single wall place it exactly on medial axis
|
||||||
nupoly.push(new Point(min.x, min.y));
|
nupoly.push(new Point(min.x, min.y));
|
||||||
trace.push({ x: min.x, y: min.y, r: mr })
|
npo = { x: min.x, y: min.y, r: mr, s: p1.segment };
|
||||||
} else {
|
} else {
|
||||||
// radius rounded to nearest step
|
// radius rounded to nearest step
|
||||||
let rad_step = ((pop[0] * sstep) | 0) / sstep;
|
let rad_step = ((pop[0] * sstep) | 0) / sstep;
|
||||||
// otherwise use first division
|
// otherwise use first division
|
||||||
// compensate for minimal inset
|
// compensate for minimal inset
|
||||||
let off = -dstep + rad_step;
|
let off = -dstep + rad_step;
|
||||||
trace.push({
|
npo = {
|
||||||
x: np1.x + dy * off,
|
x: np1.x + dy * off,
|
||||||
y: np1.y - dx * off,
|
y: np1.y - dx * off,
|
||||||
r: rad_step
|
r: rad_step,
|
||||||
})
|
s: p1.segment
|
||||||
|
};
|
||||||
// trace inset by full diameter
|
// trace inset by full diameter
|
||||||
nupoly.push(new Point(np1.x + dy * off * 2, np1.y - dx * off * 2));
|
nupoly.push(new Point(np1.x + dy * off * 2, np1.y - dx * off * 2));
|
||||||
}
|
}
|
||||||
|
let lpo = trace.peek();
|
||||||
|
// when outputting the same segment at the same radius
|
||||||
|
// it's safe to drop the last point since path output will connect them
|
||||||
|
if (trace.length > 1 && lpo.s === npo.s && lpo.r === npo.r) {
|
||||||
|
trace.pop();
|
||||||
|
}
|
||||||
|
trace.push(npo);
|
||||||
if (odd && !mp1.claimed) {
|
if (odd && !mp1.claimed) {
|
||||||
mp1.claimed = p1.segment;
|
mp1.claimed = p1.segment;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1101,7 +1101,7 @@ function slicePrintPath(print, slice, startPoint, offset, output, opt = {}) {
|
||||||
thin.forEach((a,i) => a.shell = sort[i] * shellOrder);
|
thin.forEach((a,i) => a.shell = sort[i] * shellOrder);
|
||||||
thin.forEach(t => t.shell = t.shell < 0 ? Math.abs(t.shell) + 0.5 : t.shell);
|
thin.forEach(t => t.shell = t.shell < 0 ? Math.abs(t.shell) + 0.5 : t.shell);
|
||||||
thin.sort((a,b) => a.shell - b.shell);
|
thin.sort((a,b) => a.shell - b.shell);
|
||||||
let np;
|
let np = print.lastPoint;
|
||||||
// perform nearest poly to poly algorithm on shells
|
// perform nearest poly to poly algorithm on shells
|
||||||
for (;;) {
|
for (;;) {
|
||||||
let min = { dist: Infinity };
|
let min = { dist: Infinity };
|
||||||
|
|
@ -1114,6 +1114,7 @@ function slicePrintPath(print, slice, startPoint, offset, output, opt = {}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!min.trace) {
|
if (!min.trace) {
|
||||||
|
startPoint = np;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let { trace } = min;
|
let { trace } = min;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue