checkpoint anti-backlash

This commit is contained in:
Stewart Allen 2018-02-11 07:49:57 -05:00
commit bdca904c61
3 changed files with 30 additions and 12 deletions

View file

@ -626,8 +626,10 @@ var gs_base_polygons = exports;
var p1 = newPoint(start.x - raySlope.dx * 1000, start.y - raySlope.dy * 1000, zpos, NOKEY), var p1 = newPoint(start.x - raySlope.dx * 1000, start.y - raySlope.dy * 1000, zpos, NOKEY),
p2 = newPoint(start.x + raySlope.dx * 1000, start.y + raySlope.dy * 1000, zpos, NOKEY); p2 = newPoint(start.x + raySlope.dx * 1000, start.y + raySlope.dy * 1000, zpos, NOKEY);
lines.push([p1,p2]); // store origin line for distance tests in print
if (i == 0) rayint.oline = [p1,p2];
lines.push([p1,p2]);
start.x += stepX; start.x += stepX;
start.y += stepY; start.y += stepY;
} }

View file

@ -567,12 +567,14 @@ var gs_kiri_print = exports;
} }
function outputFills(lines, bounds) { function outputFills(lines, bounds) {
var mindist, p1, p2, dist, point, find, list, len, lastout, pass = 0, origin; var mindist, p1, p2, dist, point, find, list, len, lastout, origin, lastDist2Origin,
skip = false,
pass = 0;
while (lines) { while (lines) {
list = []; list = [];
mindist = Infinity; mindist = Infinity;
origin = antiBacklash && pass === 0 ? lines.origin : startPoint; origin = skip || (antiBacklash && pass === 0) ? lines.origin : startPoint;
// order all points by distance to last point // 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];
@ -595,6 +597,20 @@ var gs_kiri_print = exports;
dist = startPoint.distTo2D(p1); dist = startPoint.distTo2D(p1);
// find next closest to fill origin on seek
if (antiBacklash) {
var dist2Origin = p1.distToLine(lines.oline[0], lines.oline[1]);
if (!skip) {
if (lastDist2Origin && dist2Origin < lastDist2Origin) {
lastDist2Origin = null;
skip = true;
continue;
}
}
lastDist2Origin = dist2Origin;
}
skip = false;
// mark as used (temporary) // mark as used (temporary)
p1.del = true; p1.del = true;
p2.del = true; p2.del = true;
@ -616,7 +632,7 @@ var gs_kiri_print = exports;
// anti-backlash take out slack by moving toward origin // anti-backlash take out slack by moving toward origin
if (antiBacklash && dist > retractDist) { if (antiBacklash && dist > retractDist) {
addOutput(preout, p1.add({x:1,y:-1,z:0}), 0, moveSpeed); addOutput(preout, p1.add({x:2,y:-2,z:0}), 0, moveSpeed);
} }
// bridge ends of fill when they're close together // bridge ends of fill when they're close together

View file

@ -260,7 +260,7 @@ self.kiri.license = exports.LICENSE;
sliceHeight: 0.25, sliceHeight: 0.25,
sliceShells: 2, sliceShells: 2,
sliceShellSpacing: 1, sliceShellSpacing: 1.0,
sliceFillAngle: 45, sliceFillAngle: 45,
sliceFillOverlap: 0.3, sliceFillOverlap: 0.3,
sliceFillSpacing: 1.0, sliceFillSpacing: 1.0,
@ -275,10 +275,10 @@ self.kiri.license = exports.LICENSE;
sliceSupportExtra: 0, sliceSupportExtra: 0,
sliceSupportSpan: 6, sliceSupportSpan: 6,
sliceSolidMinArea: 0.1, sliceSolidMinArea: 5,
sliceSolidLayers: 2, sliceSolidLayers: 3,
sliceBottomLayers: 2, sliceBottomLayers: 2,
sliceTopLayers: 2, sliceTopLayers: 3,
sliceVase: false, sliceVase: false,
firstSliceHeight: 0.25, firstSliceHeight: 0.25,
@ -298,13 +298,13 @@ self.kiri.license = exports.LICENSE;
outputFillMult: 1.2, outputFillMult: 1.2,
outputSparseMult: 1.3, outputSparseMult: 1.3,
outputRetractOver: 5.0, outputRetractOver: 5.0,
outputRetractDist: 0.5, outputRetractDist: 1.0,
outputRetractSpeed: 40, outputRetractSpeed: 40,
outputRetractDwell: 20, outputRetractDwell: 30,
outputBrimCount: 2, outputBrimCount: 2,
outputBrimOffset: 3, outputBrimOffset: 2,
outputShortPoly: 15.0, outputShortPoly: 15.0,
outputShortDistance: 5.0, outputShortDistance: 0.0,
outputShortFactor: 0.2, outputShortFactor: 0.2,
outputFinishFactor: 0, outputFinishFactor: 0,
detectThinWalls: false, detectThinWalls: false,