change purge blocks to spiral rectangles
This commit is contained in:
parent
5030dbd5f3
commit
3717a016d2
3 changed files with 41 additions and 8 deletions
|
|
@ -325,6 +325,31 @@ var gs_base_polygon = exports;
|
||||||
return this;
|
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
|
* add points forming a circle around a center point
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -526,24 +526,27 @@ let gs_kiri_fdm = exports;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let blokpos, walkpos;
|
let blokpos, walkpos, blok;
|
||||||
if (bounds.min.x < bounds.min.y) {
|
if (bounds.min.x < bounds.min.y) {
|
||||||
let dx = ((bounds.max.x - bounds.min.x) - (extcount * 5)) / 2;
|
let dx = ((bounds.max.x - bounds.min.x) - (extcount * 5)) / 2;
|
||||||
blokpos = { x:bounds.min.x + dx, y: bounds.max.y + 5};
|
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 {
|
} else {
|
||||||
let dy = ((bounds.max.y - bounds.min.y) - (extcount * 5)) / 2;
|
let dy = ((bounds.max.y - bounds.min.y) - (extcount * 5)) / 2;
|
||||||
blokpos = { x:bounds.max.x + 5, y: bounds.min.y + dy};
|
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
|
// compute purge blocks
|
||||||
extruders = extruders.map((ext,i) => {
|
extruders = extruders.map((ext,i) => {
|
||||||
if (!ext) return ext;
|
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 = {
|
rec = {
|
||||||
extruder: i,
|
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.x += walkpos.x;
|
||||||
blokpos.y += walkpos.y;
|
blokpos.y += walkpos.y;
|
||||||
|
|
@ -555,7 +558,11 @@ let gs_kiri_fdm = exports;
|
||||||
let rec = track[nozzle];
|
let rec = track[nozzle];
|
||||||
if (rec) {
|
if (rec) {
|
||||||
track[nozzle] = null;
|
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 {
|
} else {
|
||||||
console.log({already_purged: nozzle, from: track, layer});
|
console.log({already_purged: nozzle, from: track, layer});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -512,9 +512,10 @@ let gs_kiri_print = exports;
|
||||||
printSpeed = options.rate || process.outputFeedrate,
|
printSpeed = options.rate || process.outputFeedrate,
|
||||||
moveSpeed = process.outputSeekrate,
|
moveSpeed = process.outputSeekrate,
|
||||||
minSpeed = process.outputMinSpeed,
|
minSpeed = process.outputMinSpeed,
|
||||||
closest = poly.findClosestPointTo(startPoint),
|
closest = options.simple ? poly.first() : poly.findClosestPointTo(startPoint),
|
||||||
perimeter = poly.perimeter(),
|
perimeter = poly.perimeter(),
|
||||||
first = true,
|
first = true,
|
||||||
|
close = !options.open,
|
||||||
last = startPoint,
|
last = startPoint,
|
||||||
wipeDist = options.wipe || 0,
|
wipeDist = options.wipe || 0,
|
||||||
coastDist = options.coast || 0,
|
coastDist = options.coast || 0,
|
||||||
|
|
@ -546,7 +547,7 @@ let gs_kiri_print = exports;
|
||||||
addOutput(output, point, shellMult, printSpeed, tool);
|
addOutput(output, point, shellMult, printSpeed, tool);
|
||||||
}
|
}
|
||||||
last = point;
|
last = point;
|
||||||
}, true, closest.index);
|
}, close, closest.index);
|
||||||
|
|
||||||
return output.last().point;
|
return output.last().point;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue