change sparse output to use tip2tipEmit
This commit is contained in:
parent
b0647ec727
commit
3084bfbc1e
2 changed files with 36 additions and 28 deletions
|
|
@ -244,7 +244,6 @@ var gs_kiri_fdm = exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layerout.length) output.append(layerout);
|
if (layerout.length) output.append(layerout);
|
||||||
// console.log({layer: output.length, len: layerout.length});
|
|
||||||
layer++;
|
layer++;
|
||||||
update(layer / maxLayers);
|
update(layer / maxLayers);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -376,19 +376,40 @@ var gs_kiri_print = exports;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkBisect(p1, p2, bounds) {
|
||||||
|
if (p1.distTo2D(p2) < minSeek) return;
|
||||||
|
var more = true;
|
||||||
|
bounds.forEach(function(bp) {
|
||||||
|
if (!more) return;
|
||||||
|
var paths = bp.bisect(startPoint, p1);
|
||||||
|
if (!paths || paths.length !== 2) return;
|
||||||
|
var path = paths[0].perimeter() < paths[1].perimeter() ? paths[0] : paths[1];
|
||||||
|
// console.log({bisect: path.length, z: path.first().z, l:path.perimeter()});
|
||||||
|
path.forEachPoint(function(p) {
|
||||||
|
preout.push(newOut(p, 0));
|
||||||
|
});
|
||||||
|
more = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Polygon[]} polys
|
* @param {Polygon[]} polys
|
||||||
*/
|
*/
|
||||||
function outputSparse(polys, fillMult, bounds) {
|
function outputSparse(polys, fillMult, bounds) {
|
||||||
if (!polys) return;
|
if (!polys) return;
|
||||||
var lines = [], p1, p2, iter;
|
var proxy = polys.map(function(poly) {
|
||||||
polys.forEach(function(poly) {
|
return {poly: poly, first: poly.first(), last: poly.last()};
|
||||||
poly.forEachSegment(function(p1,p2) {
|
});
|
||||||
lines.push(p1.clone());
|
// var lp = startPoint;
|
||||||
lines.push(p2.clone());
|
startPoint = tip2tipEmit(proxy, startPoint, function(el, point, count) {
|
||||||
}, true);
|
var poly = el.poly;
|
||||||
|
if (poly.last() === point) poly.reverse();
|
||||||
|
poly.forEachPoint(function(p, i) {
|
||||||
|
// if (i === 0 && lp) checkBisect(lp, p, bounds);
|
||||||
|
preout.push(newOut(p, i === 0 ? 0 : fillMult));
|
||||||
|
});
|
||||||
|
// lp = point;
|
||||||
});
|
});
|
||||||
outputFills(lines, fillMult, bounds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function outputFills(lines, extrude, bounds) {
|
function outputFills(lines, extrude, bounds) {
|
||||||
|
|
@ -420,26 +441,15 @@ var gs_kiri_print = exports;
|
||||||
p1.del = true;
|
p1.del = true;
|
||||||
p2.del = true;
|
p2.del = true;
|
||||||
dist = SQRT(startPoint.distToSq2D(p1));
|
dist = SQRT(startPoint.distToSq2D(p1));
|
||||||
preout.push(newOut(p1, 0));
|
|
||||||
// preout.push(newOut(p1, dist < minSeek ? seekMult : 0));
|
|
||||||
|
|
||||||
// check for intersection with bounds and if found
|
// check for intersection with bounds and if found
|
||||||
// follow the shortest path around that bounding poly
|
// follow the shortest path around that bounding poly
|
||||||
if (false && bounds && startPoint && dist > minSeek) {
|
// if (bounds && startPoint && dist > minSeek) {
|
||||||
var more = true;
|
// checkBisect(startPoint, p1, bounds);
|
||||||
if (more) bounds.forEach(function(bp) {
|
// }
|
||||||
var paths = bp.bisect(startPoint, p1);
|
|
||||||
if (!paths || paths.length !== 2) return;
|
|
||||||
var path = paths[0].perimeter() < paths[1].perimeter() ? paths[0] : paths[1];
|
|
||||||
// console.log({bisect: path.length, z: path.first().z, l:path.perimeter()});
|
|
||||||
path.forEachSegment(function(p1, p2) {
|
|
||||||
preout.push(newOut(p1, 0));
|
|
||||||
preout.push(newOut(p2, 0));
|
|
||||||
});
|
|
||||||
more = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// preout.push(newOut(p1, dist < minSeek ? seekMult : 0));
|
||||||
|
preout.push(newOut(p1, 0));
|
||||||
preout.push(newOut(p2, printMult));
|
preout.push(newOut(p2, printMult));
|
||||||
startPoint = p2;
|
startPoint = p2;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -492,12 +502,11 @@ var gs_kiri_print = exports;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// top object
|
// top object
|
||||||
var inner = next.innerTraces();
|
outputTraces([].appendAll(next.traces).appendAll(next.innerTraces() || []), extrude);
|
||||||
outputTraces([].appendAll(next.traces).appendAll(inner || []), extrude);
|
|
||||||
// outputTraces(next.traces, extrude);
|
// outputTraces(next.traces, extrude);
|
||||||
// outputTraces(next.innerTraces(), extrude);
|
// outputTraces(next.innerTraces(), extrude);
|
||||||
outputFills(next.fill_lines, extrude, inner);
|
outputFills(next.fill_lines, extrude, next.inner);
|
||||||
outputSparse(next.fill_sparse, extrude, inner);
|
outputSparse(next.fill_sparse, extrude, next.inner);
|
||||||
}
|
}
|
||||||
}, function(obj) {
|
}, function(obj) {
|
||||||
return obj instanceof Polygon ? obj : obj.poly;
|
return obj instanceof Polygon ? obj : obj.poly;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue