change purge blocks to spiral rectangles

This commit is contained in:
Stewart Allen 2020-04-10 21:26:07 -04:00
commit 3717a016d2
3 changed files with 41 additions and 8 deletions

View file

@ -325,6 +325,31 @@ var gs_base_polygon = exports;
return this;
};
/**
* create square spiral (used for purge blocks)
*/
PRO.centerSpiral = function(center, lenx, leny, offset, count) {
count *= 4;
offset /= 2;
let pos = { x: center.x - lenx/2, y: center.y + leny/2, z: center.z },
dir = { x: 1, y: 0, i: 0 }, t;
while (count-- > 0) {
this.push(newPoint(pos.x, pos.y, pos.z));
pos.x += dir.x * lenx;
pos.y += dir.y * leny;
switch (dir.i++) {
case 0: t = dir.x; dir.x = dir.y; dir.y = -t; break;
case 1: t = dir.x; dir.x = dir.y; dir.y = t; break;
case 2: t = dir.x; dir.x = dir.y; dir.y = -t; break;
case 3: t = dir.x; dir.x = dir.y; dir.y = t; break;
}
lenx -= offset/2;
leny -= offset/2;
dir.i = dir.i % 4;
}
return this;
};
/**
* add points forming a circle around a center point
*

View file

@ -526,24 +526,27 @@ let gs_kiri_fdm = exports;
}
});
let blokpos, walkpos;
let blokpos, walkpos, blok;
if (bounds.min.x < bounds.min.y) {
let dx = ((bounds.max.x - bounds.min.x) - (extcount * 5)) / 2;
blokpos = { x:bounds.min.x + dx, y: bounds.max.y + 5};
walkpos = { x:10, y: 0};
walkpos = { x:10, y:0 };
blok = { x:9, y:4 };
} else {
let dy = ((bounds.max.y - bounds.min.y) - (extcount * 5)) / 2;
blokpos = { x:bounds.max.x + 5, y: bounds.min.y + dy};
walkpos = { x:0, y: 10};
walkpos = { x:0, y:10 };
blok = { x:4, y:9 };
}
// compute purge blocks
extruders = extruders.map((ext,i) => {
if (!ext) return ext;
let pos = {x:blokpos.x, y:blokpos.y, z:0},
let noz = device.extruders[i].extNozzle,
pos = {x:blokpos.x, y:blokpos.y, z:0},
rec = {
extruder: i,
poly: BASE.newPolygon().centerRectangle(pos, 8, 8)
poly: BASE.newPolygon().centerSpiral(pos, blok.x, blok.y, noz*2, 3)
};
blokpos.x += walkpos.x;
blokpos.y += walkpos.y;
@ -555,7 +558,11 @@ let gs_kiri_fdm = exports;
let rec = track[nozzle];
if (rec) {
track[nozzle] = null;
return print.polyPrintPath(rec.poly.clone().setZ(z), start, layer, {tool:using || nozzle});
return print.polyPrintPath(rec.poly.clone().setZ(z), start, layer, {
tool: using || nozzle,
open: true,
simple: true
});
} else {
console.log({already_purged: nozzle, from: track, layer});
}

View file

@ -512,9 +512,10 @@ let gs_kiri_print = exports;
printSpeed = options.rate || process.outputFeedrate,
moveSpeed = process.outputSeekrate,
minSpeed = process.outputMinSpeed,
closest = poly.findClosestPointTo(startPoint),
closest = options.simple ? poly.first() : poly.findClosestPointTo(startPoint),
perimeter = poly.perimeter(),
first = true,
close = !options.open,
last = startPoint,
wipeDist = options.wipe || 0,
coastDist = options.coast || 0,
@ -546,7 +547,7 @@ let gs_kiri_print = exports;
addOutput(output, point, shellMult, printSpeed, tool);
}
last = point;
}, true, closest.index);
}, close, closest.index);
return output.last().point;
};