fix redundant path output in depth-first mode

This commit is contained in:
Stewart Allen 2021-01-17 22:23:51 -05:00
commit 26c0a5cf69
7 changed files with 19 additions and 12 deletions

View file

@ -53,6 +53,7 @@
# FDM - BELT
* `B` fix supports for belt printing
* `F` in slice mode, allow marking of repeat loop areas. add "loop" expert parameter
# CAM

View file

@ -1,6 +1,6 @@
{
"name": "grid-apps",
"version": "2.6.6D",
"version": "2.6.7D",
"description": "grid.space 3d slice & modeling tools",
"author": "Stewart Allen <sa@grid.space>",
"license": "MIT",

View file

@ -6,7 +6,7 @@
if (!self.kiri) {
self.kiri = {
beta: 2606,
beta: 2607,
driver: {}, // driver modules
loader: [] // module loading: array of functions
};

View file

@ -864,22 +864,21 @@
* to be more like outputOrderClosest() and have the option to account for
* depth in determining distance
*/
function poly2polyEmit(array, startPoint, emitter, options) {
let opt = options || {};
function poly2polyEmit(array, startPoint, emitter, opt = {}) {
let marker = opt.mark || 'delete';
let mindist, dist, found, count = 0;
for (;;) {
found = null;
mindist = Infinity;
array.forEach(function(poly) {
for (let poly of array) {
if (poly[marker]) {
return;
continue;
}
if (poly.isOpen()) {
const d2f = startPoint.distTo2D(poly.first());
const d2l = startPoint.distTo2D(poly.last());
if (d2f > mindist && d2l > mindist) {
return;
continue;
}
if (d2l < mindist && d2l < d2f) {
poly.reverse();
@ -887,7 +886,7 @@
} else if (d2f < mindist) {
found = {poly:poly, index:0, point:poly.first()};
}
return;
continue;
}
let area = poly.open ? 1 : poly.area();
poly.forEachPoint(function(point, index) {
@ -899,7 +898,7 @@
mindist = dist;
}
});
});
}
if (!found || opt.term) {
break;
}
@ -908,7 +907,9 @@
}
// undo delete marks
array.forEach(function(poly) { poly[marker] = false });
if (opt.perm !== true) {
array.forEach(function(poly) { poly[marker] = false });
}
return startPoint;
}

View file

@ -3,7 +3,7 @@
let terms = {
COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
LICENSE: "See the license.md file included with the source distribution",
VERSION: "2.6.D6"
VERSION: "2.6.D7"
};
if (typeof(module) === 'object') {

View file

@ -365,9 +365,14 @@
if (depthFirst) {
let tops = depthData.map(level => {
// return POLY.nest(level.filter(poly => poly.depth === 0));
return POLY.nest(level.filter(poly => poly.depth === 0).clone());
});
printPoint = depthRoughPath(printPoint, 0, depthData, tops, polyEmit);
// printPoint = depthRoughPath(printPoint, 0, depthData, tops, (poly, index, count, start) => {
// console.log({z: poly.getZ(), i: poly.id, index, poly});
// return polyEmit(poly, index, count, start);
// });
}
setPrintPoint(printPoint);

View file

@ -424,7 +424,7 @@
fitted.filter(top => !top.level_emit).forEach(top => {
top.level_emit = true;
let inside = level.filter(poly => poly.isInside(top));
start = poly2polyEmit(inside, start, emitter, { mark: "emark" });
start = poly2polyEmit(inside, start, emitter, { mark: "emark", perm: true });
start = depthRoughPath(start, depth + 1, levels, tops, emitter, top);
});
return start;