cleanup fill/shell extrusion. fix hex spacing

This commit is contained in:
Stewart Allen 2017-10-30 00:35:52 -04:00
commit 6032b8a794
3 changed files with 17 additions and 28 deletions

View file

@ -342,21 +342,19 @@ var gs_kiri_print = exports;
settings = this.settings, settings = this.settings,
process = settings.process, process = settings.process,
minSeek = settings.device.nozzleSize * 1.5, minSeek = settings.device.nozzleSize * 1.5,
wipeDist = process.outputWipeDistance, // todo disable for laser mode
fillMult = process.outputFillMult, fillMult = process.outputFillMult,
seekMult = fillMult * 0.5, shellMult = process.outputShellMult || (process.laserSliceHeight >= 0 ? 1 : 0),
origin = startPoint.add(offset), origin = startPoint.add(offset),
extrude = process.outputShellMult || (process.laserSliceHeight >= 0 ? 1 : 0),
z = slice.z; z = slice.z;
function outputTraces(poly, extrude, bounds) { function outputTraces(poly, bounds) {
if (!poly) return; if (!poly) return;
if (Array.isArray(poly)) { if (Array.isArray(poly)) {
outputOrderClosest(poly, function(next) { outputOrderClosest(poly, function(next) {
outputTraces(next, extrude, bounds); outputTraces(next, bounds);
}); });
} else { } else {
startPoint = scope.polyPrintPath(poly, startPoint, preout, extrude, function(point) { startPoint = scope.polyPrintPath(poly, startPoint, preout, shellMult, function(point) {
checkBisect(startPoint, point, bounds); checkBisect(startPoint, point, bounds);
}); });
} }
@ -371,7 +369,6 @@ var gs_kiri_print = exports;
if (!paths || paths.length !== 2) return; if (!paths || paths.length !== 2) return;
var path = paths[0].perimeter() < paths[1].perimeter() ? paths[0] : paths[1]; var path = paths[0].perimeter() < paths[1].perimeter() ? paths[0] : paths[1];
if (p1.distTo2D(path.first() > p1.distTo2D(path.last()))) path.reverse(); if (p1.distTo2D(path.first() > p1.distTo2D(path.last()))) path.reverse();
// console.log(path === paths[0] ? "first" : "last"); // failing on "last"
path.forEachPoint(function(p) { path.forEachPoint(function(p) {
preout.push(newOut(p, 0)); preout.push(newOut(p, 0));
}); });
@ -382,7 +379,7 @@ var gs_kiri_print = exports;
/** /**
* @param {Polygon[]} polys * @param {Polygon[]} polys
*/ */
function outputSparse(polys, fillMult, bounds) { function outputSparse(polys, bounds) {
if (!polys) return; if (!polys) return;
var proxy = polys.map(function(poly) { var proxy = polys.map(function(poly) {
return {poly: poly, first: poly.first(), last: poly.last()}; return {poly: poly, first: poly.first(), last: poly.last()};
@ -399,9 +396,8 @@ var gs_kiri_print = exports;
}); });
} }
function outputFills(lines, extrude, bounds) { function outputFills(lines, bounds) {
var mindist, p1, p2, dist, point, find, dist, var mindist, p1, p2, dist, point, find, dist;
printMult = extrude || fillMult;
while (lines) { while (lines) {
find = null; find = null;
mindist = Infinity; mindist = Infinity;
@ -435,9 +431,8 @@ var gs_kiri_print = exports;
checkBisect(startPoint, p1, bounds); checkBisect(startPoint, p1, bounds);
} }
// preout.push(newOut(p1, dist < minSeek ? seekMult : 0));
preout.push(newOut(p1, 0)); preout.push(newOut(p1, 0));
preout.push(newOut(p2, printMult)); preout.push(newOut(p2, fillMult));
startPoint = p2; startPoint = p2;
} else { } else {
break; break;
@ -480,17 +475,17 @@ var gs_kiri_print = exports;
if (next instanceof Polygon) { if (next instanceof Polygon) {
// support polygon // support polygon
next.setZ(z); next.setZ(z);
outputTraces([].appendAll(next).appendAll(next.inner || []), extrude); outputTraces([].appendAll(next).appendAll(next.inner || []));
if (next.fills) { if (next.fills) {
next.fills.forEach(function(p) { p.z = z }); next.fills.forEach(function(p) { p.z = z });
outputFills(next.fills, extrude, next.inner); outputFills(next.fills, next.inner);
} }
} else { } else {
var bounds = [next.poly].appendAll(next.poly.inner || []); var bounds = [next.poly].appendAll(next.poly.inner || []);
// top object // top object
outputTraces([].appendAll(next.traces).appendAll(next.innerTraces() || []), extrude, bounds); outputTraces([].appendAll(next.traces).appendAll(next.innerTraces() || []), bounds);
outputFills(next.fill_lines, extrude, bounds); outputFills(next.fill_lines, bounds);
outputSparse(next.fill_sparse, extrude, bounds); outputSparse(next.fill_sparse, bounds);
} }
}, function(obj) { }, function(obj) {
return obj instanceof Polygon ? obj : obj.poly; return obj instanceof Polygon ? obj : obj.poly;

View file

@ -1126,7 +1126,7 @@ var gs_kiri_slice = exports;
*/ */
function sparseFillHex(target) { function sparseFillHex(target) {
// compute segment lengths (vert/horiz and 45) // compute segment lengths (vert/horiz and 45)
var spacing = target.offset(), var spacing = target.offset() / 2,
vhlen = (1 - target.density()) * 4 + spacing, vhlen = (1 - target.density()) * 4 + spacing,
anxlen = ROUND(Math.cos(30 * DEG2RAD) * vhlen, 7), anxlen = ROUND(Math.cos(30 * DEG2RAD) * vhlen, 7),
anylen = ROUND(Math.sin(30 * DEG2RAD) * vhlen, 7), anylen = ROUND(Math.sin(30 * DEG2RAD) * vhlen, 7),

View file

@ -4,23 +4,17 @@
"M104 S{temp} T0 ; set nozzle0 temp", "M104 S{temp} T0 ; set nozzle0 temp",
"M107 ; fan off", "M107 ; fan off",
"G90 ; set absolute positioning", "G90 ; set absolute positioning",
"G28 ; move to origin",
"M132 X Y Z A B ; set axis limits", "M132 X Y Z A B ; set axis limits",
"M6 T0 ; tool change T0",
"M907 X100 Y100 Z40 A80 B20 ; set digital trimpots", "M907 X100 Y100 Z40 A80 B20 ; set digital trimpots",
"M108 T0 ; set extruder speed",
"; pre-extrude", "; pre-extrude",
"G1 X-75 Y-75 Z0.35 F400", "G1 X-75 Y-75 Z0.35 F400",
"G1 X75 E25 F1200", "G1 X75 E25 F1800",
"G1 Y00 E30 F1200" "G1 Y00 E20 F2400"
], ],
"post":[ "post":[
"M107 ; fan off", "M107 ; fan off",
"M104 S0 T0 ; set nozzle0 temp", "M104 S0 T0 ; set nozzle0 temp",
"G162 Z ; home axes maximum", "G162 Z ; lower bed",
"G28 Z ; lower bed",
"G28 X Y ; move to origin",
"M132 X Y Z A B ; set axis limits",
"M18 ; disable all steppers" "M18 ; disable all steppers"
], ],
"cmd":{ "cmd":{