fix open traces in slice and resulting empty top slices. do not offset open polys in expand()
This commit is contained in:
parent
3c7fe43f24
commit
8ac7d3b89a
8 changed files with 49 additions and 9 deletions
|
|
@ -186,6 +186,16 @@
|
|||
return min;
|
||||
};
|
||||
|
||||
PRO.xray = function(dash = 3) {
|
||||
console.log('xray', this);
|
||||
this.output().setLayer(`xp`, 0x888800).addPolys(this.topPolys());
|
||||
this.lines.forEach((line, i) => {
|
||||
const group = i % dash;
|
||||
const color = [ 0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff ][group];
|
||||
this.output().setLayer(`xl-${group}`, color).addLine(line.p1, line.p2);
|
||||
});
|
||||
};
|
||||
|
||||
function newTop(poly) {
|
||||
return new Top(poly);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,17 @@
|
|||
}
|
||||
}
|
||||
|
||||
// notopok = when genso set, allow empty top array
|
||||
// emptyok = allow empty slices
|
||||
// openok = allow open tops
|
||||
// swapX = swap X/Z
|
||||
// swapY = sawp Y/Z
|
||||
// zList = generate list of z vertices
|
||||
// zline = generate list of z vertices with coplanar lines
|
||||
// trace = find z coplanar trace lines
|
||||
// flatoff = amount to offset z when slicing on detected flats
|
||||
// genso = generate a slice object with tops
|
||||
// each = call for each slice generated from an interval
|
||||
setOptions(options) {
|
||||
Object.assign(this.options, options || {});
|
||||
return this.options;
|
||||
|
|
@ -243,7 +254,7 @@
|
|||
|
||||
if (lines.length) {
|
||||
retn.lines = removeDuplicateLines(lines);
|
||||
retn.tops = POLY.nest(connectLines(retn.lines));
|
||||
retn.tops = POLY.nest(connectLines(retn.lines, opt));
|
||||
|
||||
if (opt.swapX || opt.swapY) {
|
||||
this.unswap(opt.swapX, opt.swapY, retn.lines, retn.tops);
|
||||
|
|
@ -256,11 +267,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (opt.each && (lines.length || opt.emptyok)) {
|
||||
const haslines = lines.length || opt.emptyok;
|
||||
const hastops = !opt.genso || retn.tops.length || opt.notopok;
|
||||
|
||||
if (opt.each && haslines && hastops) {
|
||||
opt.each(retn, index, total, UTIL.time() - mark);
|
||||
}
|
||||
|
||||
return retn;
|
||||
return haslines && hastops ? retn : null;
|
||||
}
|
||||
|
||||
swap(points, options) {
|
||||
|
|
@ -466,7 +480,7 @@
|
|||
* @param {number} [index]
|
||||
* @returns {Array}
|
||||
*/
|
||||
function connectLines(input) {
|
||||
function connectLines(input, opt = {}) {
|
||||
// map points to all other points they're connected to
|
||||
let DBUG = BASE.debug,
|
||||
CONF = BASE.config,
|
||||
|
|
@ -662,7 +676,9 @@
|
|||
tmp, dist, j;
|
||||
|
||||
if (!bridge) {
|
||||
emit(BASE.newPolygon().addPoints(array).setOpen());
|
||||
if (opt.openok) {
|
||||
emit(BASE.newPolygon().addPoints(array).setOpen());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue