improve retraction between shell areas

This commit is contained in:
Stewart Allen 2017-12-09 21:55:25 -05:00
commit 534992e34a
4 changed files with 37 additions and 24 deletions

View file

@ -547,7 +547,7 @@ var gs_base_polygons = exports;
if (clip.Execute(ctyp.ctIntersection, ctre, cfil.pftNonZero, cfil.pftEvenOdd)) { if (clip.Execute(ctyp.ctIntersection, ctre, cfil.pftNonZero, cfil.pftEvenOdd)) {
ctre.m_AllPolys.forEach(function(poly) { ctre.m_AllPolys.forEach(function(poly) {
// filter out polygons under min length (0.5mm) // filter out polygons under min length (0.5mm)
if (clib.JS.PerimeterOfPath(poly.m_polygon, false, 1) < minlen) return; // if (clib.JS.PerimeterOfPath(poly.m_polygon, false, 1) < minlen) return;
poly.m_polygon.forEach(function(point) { poly.m_polygon.forEach(function(point) {
rayint.push(newPoint(null,null,zpos,null,point)); rayint.push(newPoint(null,null,zpos,null,point));
}); });

View file

@ -241,7 +241,7 @@ var gs_kiri_fdm = exports;
if (!closest) break; if (!closest) break;
slices[minidx] = null; slices[minidx] = null;
// output seek to start point between mesh slices if previous data // output seek to start point between mesh slices if previous data
printPoint = print.slicePrintPath(closest.slice, printPoint.sub(closest.offset), closest.offset, layerout, true); printPoint = print.slicePrintPath(closest.slice, printPoint.sub(closest.offset), closest.offset, layerout, layer);
} }
if (layerout.length) output.append(layerout); if (layerout.length) output.append(layerout);
@ -448,7 +448,7 @@ var gs_kiri_fdm = exports;
// usually outer shell (finish speed) override // usually outer shell (finish speed) override
outMMM = out.speed * 60; outMMM = out.speed * 60;
} }
if (dist < shortDist) { if (layer > 0 && dist < shortDist) {
outMMM = shortMMM + ((outMMM - shortMMM) * (dist / shortDist)); outMMM = shortMMM + ((outMMM - shortMMM) * (dist / shortDist));
} else { } else {
// approximate compensation for acceleration & deceleration // approximate compensation for acceleration & deceleration
@ -464,7 +464,7 @@ var gs_kiri_fdm = exports;
if (out.speed) { if (out.speed) {
moveMMM = out.speed * 60; moveMMM = out.speed * 60;
} }
if (!retracted && (out.retract || dist >= retOver)) { if (!retracted && out.retract) {
retracted = retDist; retracted = retDist;
moveTo({e:-retracted}, retSpeed, "retract (ooze control)"); moveTo({e:-retracted}, retSpeed, "retract (ooze control)");
moveTo({x:x, y:y}, moveMMM); moveTo({x:x, y:y}, moveMMM);

View file

@ -365,10 +365,10 @@ var gs_kiri_print = exports;
* @param {Point} startPoint start as close as possible to startPoint * @param {Point} startPoint start as close as possible to startPoint
* @param {THREE.Vector3} offset * @param {THREE.Vector3} offset
* @param {Point[]} output points * @param {Point[]} output points
* @param {boolean} isFDM controls whether we emit wipe or not * @param {Number} layer from 0 to # of layers (slices) in model
* @return {Point} last output point * @return {Point} last output point
*/ */
PRO.slicePrintPath = function(slice, startPoint, offset, output, isFDM) { PRO.slicePrintPath = function(slice, startPoint, offset, output, layer) {
var i, var i,
preout = [], preout = [],
scope = this, scope = this,
@ -377,7 +377,7 @@ var gs_kiri_print = exports;
nozzle = settings.device.nozzleSize, nozzle = settings.device.nozzleSize,
minSeek = nozzle * 1.5, minSeek = nozzle * 1.5,
thinWall = nozzle * 1.75, thinWall = nozzle * 1.75,
fillSkip = nozzle * 5, fillSkip = nozzle * 3,
fillMult = process.outputFillMult, fillMult = process.outputFillMult,
shellMult = process.outputShellMult || (process.laserSliceHeight >= 0 ? 1 : 0), shellMult = process.outputShellMult || (process.laserSliceHeight >= 0 ? 1 : 0),
sparseMult = process.outputSparseMult, sparseMult = process.outputSparseMult,
@ -386,6 +386,10 @@ var gs_kiri_print = exports;
origin = startPoint.add(offset), origin = startPoint.add(offset),
z = slice.z; z = slice.z;
function retract() {
if (preout.length) preout.last().retract = true;
}
function outputWipe(poly) { function outputWipe(poly) {
if (!poly) return; if (!poly) return;
@ -407,21 +411,30 @@ var gs_kiri_print = exports;
distance -= last.distTo2D(point); distance -= last.distTo2D(point);
} }
last = point; last = point;
if (steps++ === 0) preout.last().retract = true; if (steps++ === 0) retract();
} }
}, true, closest.index); }, true, closest.index);
startPoint = preout[preout.length - 1].point; startPoint = preout[preout.length - 1].point;
} }
function outputTraces(poly, bounds) { function outputTraces(poly, bounds, last) {
if (!poly) return; if (!poly) return;
if (Array.isArray(poly)) { if (Array.isArray(poly)) {
var lastPoly = null;
outputOrderClosest(poly, function(next) { outputOrderClosest(poly, function(next) {
outputTraces(next, bounds); outputTraces(next, bounds, lastPoly);
lastPoly = next;
}); });
} else { } else {
startPoint = scope.polyPrintPath(poly, startPoint, preout, shellMult, function(point) { startPoint = scope.polyPrintPath(poly, startPoint, preout, shellMult, function(point) {
if (startPoint.distTo2D(point) > fillSkip) {
if (last) {
outputWipe(last)
} else {
retract();
}
}
checkBisect(startPoint, point, bounds); checkBisect(startPoint, point, bounds);
}); });
} }
@ -480,25 +493,24 @@ var gs_kiri_print = exports;
} }
function outputFills(lines, bounds) { function outputFills(lines, bounds) {
var mindist, p1, p2, dist, dsave, point, find, find2, len, lastout; var mindist, p1, p2, dist, point, find, find2, list, len, lastout, pass = 0;
while (lines) { while (lines) {
find = null; list = [];
find2 = null;
mindist = Infinity; mindist = Infinity;
// find next closes line // order all points by distance to last point
for (i=0; i<lines.length; i++) { for (i=0; i<lines.length; i++) {
point = lines[i]; point = lines[i];
if (point.del) continue; if (point.del) continue;
dist = startPoint.distTo2D(point); dist = startPoint.distTo2D(point);
if (dist < mindist) { list.push({i:i, p:point, d:dist});
find2 = find;
find = {i:i, p:point, d:dist};
mindist = dist;
} }
} if (list.length > 0) {
if (find) { list.sort(function(a,b) { return a.d - b.d });
find = list[0];
find2 = list[4] || list[3] || list [2] || list[1];
// do 2nd closest fill lines within bigger fill areas // do 2nd closest fill lines within bigger fill areas
// if (find2 && lastout === 2 && len > thinWall && find2.d < fillSkip) { // if (layer === 0 && pass > 0 && find2 && lastout === 2 && len > thinWall) {//} && find2.d <= fillSkip) {
// find = find2; // find = find2;
// } // }
@ -521,9 +533,9 @@ var gs_kiri_print = exports;
// and segment length is less than thinWall then // and segment length is less than thinWall then
// just extrude to midpoint of next segment. this is // just extrude to midpoint of next segment. this is
// to avoid shaking printer to death. // to avoid shaking printer to death.
if (mindist <= thinWall && len <= thinWall) { if (find.d <= thinWall && len <= thinWall) {
p2 = p1.midPointTo(p2); p2 = p1.midPointTo(p2);
addOutput(preout, p2, fillMult * (mindist / thinWall)); addOutput(preout, p2, fillMult * (find.d / thinWall));
lastout = 1; lastout = 1;
} else { } else {
// check for intersection with bounds and if found // check for intersection with bounds and if found
@ -541,6 +553,7 @@ var gs_kiri_print = exports;
} else { } else {
break; break;
} }
pass++;
} }
// clear delete marks so we can re-print later // clear delete marks so we can re-print later
if (lines) lines.forEach(function(p) { p.del = false }); if (lines) lines.forEach(function(p) { p.del = false });

View file

@ -2351,7 +2351,7 @@ self.kiri.license = exports.LICENSE;
outputBrimOffset: UC.newInput("skirt offset", {title:"millimeters", convert:UC.toFloat, modes:FDM}), outputBrimOffset: UC.newInput("skirt offset", {title:"millimeters", convert:UC.toFloat, modes:FDM}),
advanced: UC.newGroup("advanced", null, {modes:FDM}), advanced: UC.newGroup("advanced", null, {modes:FDM}),
outputRetractOver: UC.newInput("retract over", {title:"move threshold that\ntriggers retraction\n0 to disable", convert:UC.toFloat, modes:FDM}), // outputRetractOver: UC.newInput("retract over", {title:"move threshold that\ntriggers retraction\n0 to disable", convert:UC.toFloat, modes:FDM}),
outputRetractDist: UC.newInput("retract dist", {title:"amount to retract filament", convert:UC.toFloat, modes:FDM}), outputRetractDist: UC.newInput("retract dist", {title:"amount to retract filament", convert:UC.toFloat, modes:FDM}),
outputRetractSpeed: UC.newInput("retract rate", {title:"speed of filament\nretraction in mm/s", convert:UC.toInt, modes:FDM}), outputRetractSpeed: UC.newInput("retract rate", {title:"speed of filament\nretraction in mm/s", convert:UC.toInt, modes:FDM}),
outputWipeSpeed: UC.newInput("wipe speed", {title:"speed while wiping\nnozzle in mm/s", convert:UC.toInt, modes:FDM}), outputWipeSpeed: UC.newInput("wipe speed", {title:"speed while wiping\nnozzle in mm/s", convert:UC.toInt, modes:FDM}),