stage new routing test
This commit is contained in:
parent
8d57ed0883
commit
b0647ec727
4 changed files with 60 additions and 16 deletions
|
|
@ -623,7 +623,23 @@ var gs_base_polygon = exports;
|
|||
};
|
||||
|
||||
/**
|
||||
* emit new open poly between two intersection points
|
||||
* using two points, split polygon into two open polygons
|
||||
* or return null if p1,p2 does not intersect or poly is open
|
||||
*/
|
||||
PRO.bisect = function(p1, p2) {
|
||||
if (this.isOpen()) return null;
|
||||
|
||||
var copy = this.clone().setClockwise();
|
||||
|
||||
var int = copy.intersections(p1, p2);
|
||||
if (!int || int.length !== 2) return null;
|
||||
|
||||
return [ copy.emitSegment(int[0], int[1]), copy.emitSegment(int[1], int[0]) ];
|
||||
};
|
||||
|
||||
/**
|
||||
* emit new open poly between two intersection points of a clockwise poly.
|
||||
* used in cam tabs and fdm output perimeter traces on infill
|
||||
*/
|
||||
PRO.emitSegment = function(i1, i2) {
|
||||
var poly = newPolygon(),
|
||||
|
|
|
|||
|
|
@ -244,6 +244,7 @@ var gs_kiri_fdm = exports;
|
|||
}
|
||||
|
||||
if (layerout.length) output.append(layerout);
|
||||
// console.log({layer: output.length, len: layerout.length});
|
||||
layer++;
|
||||
update(layer / maxLayers);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,6 +250,7 @@ var gs_kiri_print = exports;
|
|||
});
|
||||
view = KIRI.newLayer(scope.group);
|
||||
scope.layerView.push(view);
|
||||
// console.log({move:move, print:print});
|
||||
if (showMoves) view.lines(move, moveColor);
|
||||
view.lines(print, 0x5566aa);
|
||||
view.render();
|
||||
|
|
@ -378,7 +379,7 @@ var gs_kiri_print = exports;
|
|||
/**
|
||||
* @param {Polygon[]} polys
|
||||
*/
|
||||
function outputSparse(polys) {
|
||||
function outputSparse(polys, fillMult, bounds) {
|
||||
if (!polys) return;
|
||||
var lines = [], p1, p2, iter;
|
||||
polys.forEach(function(poly) {
|
||||
|
|
@ -387,15 +388,16 @@ var gs_kiri_print = exports;
|
|||
lines.push(p2.clone());
|
||||
}, true);
|
||||
});
|
||||
outputFills(lines);
|
||||
outputFills(lines, fillMult, bounds);
|
||||
}
|
||||
|
||||
function outputFills(lines, extrude) {
|
||||
var mindist, p1, p2, dist, point, find,
|
||||
function outputFills(lines, extrude, bounds) {
|
||||
var mindist, p1, p2, dist, point, find, dist,
|
||||
printMult = extrude || fillMult;
|
||||
while (lines) {
|
||||
find = null;
|
||||
mindist = Infinity;
|
||||
// find next closes line
|
||||
for (i=0; i<lines.length; i++) {
|
||||
point = lines[i];
|
||||
if (point.del) continue;
|
||||
|
|
@ -406,6 +408,7 @@ var gs_kiri_print = exports;
|
|||
}
|
||||
}
|
||||
if (find) {
|
||||
// order segment by closest to farthest point
|
||||
if (find.i % 2 === 0) {
|
||||
p1 = find.p;
|
||||
p2 = lines[find.i + 1];
|
||||
|
|
@ -413,9 +416,30 @@ var gs_kiri_print = exports;
|
|||
p1 = find.p;
|
||||
p2 = lines[find.i - 1];
|
||||
}
|
||||
// mark as used (temporary)
|
||||
p1.del = true;
|
||||
p2.del = true;
|
||||
preout.push(newOut(p1, SQRT(startPoint.distToSq2D(p1)) < minSeek ? seekMult : 0));
|
||||
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
|
||||
// follow the shortest path around that bounding poly
|
||||
if (false && bounds && startPoint && dist > minSeek) {
|
||||
var more = true;
|
||||
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(p2, printMult));
|
||||
startPoint = p2;
|
||||
} else {
|
||||
|
|
@ -459,18 +483,21 @@ var gs_kiri_print = exports;
|
|||
if (next instanceof Polygon) {
|
||||
// support polygon
|
||||
next.setZ(z);
|
||||
outputTraces(next, extrude);
|
||||
outputTraces(next.inner, extrude);
|
||||
outputTraces([].appendAll(next).appendAll(next.inner || []), extrude);
|
||||
// outputTraces(next, extrude);
|
||||
// outputTraces(next.inner, extrude);
|
||||
if (next.fills) {
|
||||
next.fills.forEach(function(p) { p.z = z });
|
||||
outputFills(next.fills, extrude);
|
||||
outputFills(next.fills, extrude, next.inner);
|
||||
}
|
||||
} else {
|
||||
// top object
|
||||
outputTraces(next.traces, extrude);
|
||||
outputTraces(next.innerTraces(), extrude);
|
||||
outputFills(next.fill_lines);
|
||||
outputSparse(next.fill_sparse);
|
||||
var inner = next.innerTraces();
|
||||
outputTraces([].appendAll(next.traces).appendAll(inner || []), extrude);
|
||||
// outputTraces(next.traces, extrude);
|
||||
// outputTraces(next.innerTraces(), extrude);
|
||||
outputFills(next.fill_lines, extrude, inner);
|
||||
outputSparse(next.fill_sparse, extrude, inner);
|
||||
}
|
||||
}, function(obj) {
|
||||
return obj instanceof Polygon ? obj : obj.poly;
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@
|
|||
"buffer-crc32": "^0.2.13",
|
||||
"compression": "^1.7.1",
|
||||
"connect": "^3.6.5",
|
||||
"express-useragent": "^1.0.7",
|
||||
"express-useragent": "^1.0.8",
|
||||
"leveldown": "^1.9.0",
|
||||
"levelup": "^1.3.9",
|
||||
"moment": "^2.19.0",
|
||||
"moment": "^2.19.1",
|
||||
"n3d-threejs": "^72.0.0",
|
||||
"pixi.js": "^4.5.5",
|
||||
"pixi.js": "^4.6.0",
|
||||
"request": "^2.83.0",
|
||||
"serve-static": "^1.13.1",
|
||||
"tween.js": "^0.14.0",
|
||||
|
|
|
|||
Loading…
Reference in a new issue