add poly bisect detect and route. remove wipe

This commit is contained in:
Stewart Allen 2017-10-29 22:35:28 -04:00
commit 8d8e9fdefb
4 changed files with 21 additions and 35 deletions

View file

@ -300,7 +300,7 @@ var gs_kiri_fdm = exports;
emitPerMM = print.extrudePerMM(device.nozzleSize, device.filamentSize, process.sliceHeight),
emitPerMMLayer1 = print.extrudePerMM(device.nozzleSize, device.filamentSize, process.sliceHeight * process.firstLayerHeight),
constReplace = print.constReplace,
pidx, path, out, lastp, dist, printMMM, shortMMM,
pidx, path, out, lastp, laste, dist, printMMM, shortMMM,
appendAll = function(arr) {
arr.forEach(function(line) { append(line) });
},
@ -437,15 +437,17 @@ var gs_kiri_fdm = exports;
moveTo({x:x, y:y, e:emitMM}, outMMM);
emitted += emitMM;
} else {
if (retOver > 0.0 && dist > retOver) moveTo({e:-retDist}, retSpeed, "ooze retract");
var retract = laste && retOver > 0.0 && dist > retOver;
if (retract) moveTo({e:-retDist}, retSpeed, "ooze retract");
moveTo({x:x, y:y}, seekMMM);
if (retOver > 0.0 && dist > retOver) moveTo({e:retDist}, retSpeed, "re-engage");
if (retract) moveTo({e:retDist}, retSpeed, "re-engage");
time += (dist / seekMMM) * 60; // seek distance
time += (retDist / retSpeed) * 60 * 2; // retraction time
// approximate compensation for acceleration & deceleration
time += (shortDist * 2) / seekMMM / 10 * 60;
}
lastp = out.point;
laste = out.emit;
// emit tracked progress
if (trackProgress && progress != lastProgress) {
append(constReplace(trackProgress, {progress:progress}));

View file

@ -298,11 +298,10 @@ var gs_kiri_print = exports;
* @param {Point} startPoint
* @param {Array} output
* @param {number} [extrude] multiplier
* @param {number} [extrude] wipe distance
* @param {Function} [onfirst] optional fn to call on first point
* @return {Point} last output point
*/
PRO.polyPrintPath = function(poly, startPoint, output, extrude, wipe) {
// poly.setClosed();
PRO.polyPrintPath = function(poly, startPoint, output, extrude, onfirst) {
poly.setClockwise();
var mindist = Infinity,
@ -314,6 +313,7 @@ var gs_kiri_print = exports;
poly.forEachPoint(function(point) {
if (first) {
if (onfirst) onfirst(point);
// move from startPoint to point
output.push(newOut(point, 0));
first = false;
@ -322,22 +322,6 @@ var gs_kiri_print = exports;
}
}, true, closest.index);
if (wipe) {
wipe = Math.min(wipe, poly.perimeter());
poly.forEachSegment(function(point, next) {
// exit loop when no more wipe
if (!(wipe && wipe > 0.1)) return true;
dist = point.distTo2D(next);
if (dist <= wipe) {
output.push(newOut(next, 0));
wipe -= dist;
} else {
output.push(newOut(point.followTo(next, wipe), 0));
return true;
}
}, false, closest.index);
}
return output[output.length - 1].point;
};
@ -365,14 +349,16 @@ var gs_kiri_print = exports;
extrude = process.outputShellMult || (process.laserSliceHeight >= 0 ? 1 : 0),
z = slice.z;
function outputTraces(poly, extrude, last) {
function outputTraces(poly, extrude, bounds) {
if (!poly) return;
if (Array.isArray(poly)) {
outputOrderClosest(poly, function(next) {
outputTraces(next, extrude, last);
outputTraces(next, extrude, bounds);
});
} else {
startPoint = scope.polyPrintPath(poly, startPoint, preout, extrude, isFDM && last ? wipeDist : 0);
startPoint = scope.polyPrintPath(poly, startPoint, preout, extrude, function(point) {
checkBisect(startPoint, point, bounds);
});
}
}
@ -445,9 +431,9 @@ var gs_kiri_print = exports;
// check for intersection with bounds and if found
// follow the shortest path around that bounding poly
// if (bounds && startPoint && dist > minSeek) {
// checkBisect(startPoint, p1, bounds);
// }
if (bounds && startPoint && dist > minSeek) {
checkBisect(startPoint, p1, bounds);
}
// preout.push(newOut(p1, dist < minSeek ? seekMult : 0));
preout.push(newOut(p1, 0));
@ -500,10 +486,11 @@ var gs_kiri_print = exports;
outputFills(next.fills, extrude, next.inner);
}
} else {
var bounds = [next.poly].appendAll(next.poly.inner || []);
// top object
outputTraces([].appendAll(next.traces).appendAll(next.innerTraces() || []), extrude);
outputFills(next.fill_lines, extrude, next.inner);
outputSparse(next.fill_sparse, extrude, [next.poly].appendAll(next.poly.inner || []));
outputTraces([].appendAll(next.traces).appendAll(next.innerTraces() || []), extrude, bounds);
outputFills(next.fill_lines, extrude, bounds);
outputSparse(next.fill_sparse, extrude, bounds);
}
}, function(obj) {
return obj instanceof Polygon ? obj : obj.poly;

View file

@ -74,7 +74,6 @@ self.kiri.license = exports.LICENSE;
outputRetractSpeed: 1,
outputBrimCount: 1,
outputBrimOffset: 1,
outputWipeDistance: 1,
outputShortDistance: 1,
outputShortFactor: 1,
outputClockwise: 1,
@ -314,7 +313,6 @@ self.kiri.license = exports.LICENSE;
outputRetractSpeed: 20,
outputBrimCount: 2,
outputBrimOffset: 3,
outputWipeDistance: 1,
outputShortDistance: 5.0,
outputShortFactor: 0.2,
@ -2329,7 +2327,6 @@ self.kiri.license = exports.LICENSE;
outputRetractOver: UC.newInput("retract over", {title:"retract filament for\nnon-print moves\nover this distance\n0 = disable", 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}),
outputWipeDistance: UC.newInput("wipe distance", {title:"wipe at end of loop\nin millimeters", convert:UC.toFloat, modes:FDM}),
outputShortDistance: UC.newInput("short distance", {title:"segment length cutoff\nfor short segments\nin millimeters", bound:UC.bound(0,200), convert:UC.toFloat, modes:FDM}),
outputShortFactor: UC.newInput("short factor", {title:"max speed reduction factor\nfor short segments\nas % of print speed", bound:UC.bound(0.05,1), convert:UC.toFloat, modes:FDM}),
});

View file

@ -1,7 +1,7 @@
var exports = {
COPYRIGHT:"Copyright (C) 2014-2017 Stewart Allen <stewart@neuron.com> - All Rights Reserved",
LICENSE:"Unauthorized copying, modification and re-distribution are strictly prohibited without prior written consent.",
VERSION:"1.0.65"
VERSION:"1.0.66"
};
if (!module) var module = {};
module.exports = exports;