update pool ordering strategy. change expand() to use offset()
This commit is contained in:
parent
3b07a089dd
commit
fd4270d29f
2 changed files with 21 additions and 9 deletions
|
|
@ -441,9 +441,9 @@
|
||||||
* @returns {Polygon[]} last offset
|
* @returns {Polygon[]} last offset
|
||||||
*/
|
*/
|
||||||
function expand(polys, distance, z, out, count, distance2, collector, min) {
|
function expand(polys, distance, z, out, count, distance2, collector, min) {
|
||||||
// return offset(polys, [distance, distance2 || distance], {
|
return offset(polys, [distance, distance2 || distance], {
|
||||||
// z, outs: out, call: collector, minArea: min, count, flat: true
|
z, outs: out, call: collector, minArea: min, count, flat: true
|
||||||
// });
|
});
|
||||||
|
|
||||||
// prepare alignments for clipper lib
|
// prepare alignments for clipper lib
|
||||||
alignWindings(polys);
|
alignWindings(polys);
|
||||||
|
|
|
||||||
|
|
@ -1095,10 +1095,6 @@
|
||||||
// console.log({skip_open_above:above});
|
// console.log({skip_open_above:above});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// do not allow inner and outer polys to mix
|
|
||||||
// if (!above.sameWindings(pool)) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// if pool fits into smallest above pool, add it and break
|
// if pool fits into smallest above pool, add it and break
|
||||||
if (polygonFitsIn(pool, above, 0.1)) {
|
if (polygonFitsIn(pool, above, 0.1)) {
|
||||||
above.poolsDown.push(pool);
|
above.poolsDown.push(pool);
|
||||||
|
|
@ -1109,7 +1105,9 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const emitPool = function(poolPoly) {
|
const emitPool = function(poolPoly) {
|
||||||
if (poolPoly.mark) return;
|
if (poolPoly.mark) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
poolPoly.mark = true;
|
poolPoly.mark = true;
|
||||||
const polys = poolPoly.pool.slice().append(poolPoly);
|
const polys = poolPoly.pool.slice().append(poolPoly);
|
||||||
startPoint = poly2polyEmit(polys, startPoint, emitter, null, false);
|
startPoint = poly2polyEmit(polys, startPoint, emitter, null, false);
|
||||||
|
|
@ -1121,8 +1119,22 @@
|
||||||
// pools are sorted smallest to largest. pools are polygons with an
|
// pools are sorted smallest to largest. pools are polygons with an
|
||||||
// attached 'pool' array of polygons
|
// attached 'pool' array of polygons
|
||||||
layers.forEach(function(pools) {
|
layers.forEach(function(pools) {
|
||||||
startPoint = poly2polyEmit(pools, startPoint, emitPool, "del_ptop", true);
|
pools.forEach(ppoly => {
|
||||||
|
if (!(ppoly.pool && ppoly.pool.length)) {
|
||||||
|
return ppoly.smallest = ppoly;
|
||||||
|
}
|
||||||
|
ppoly.pool.sort((a, b) => {
|
||||||
|
return a.perimeter() - b.perimeter();
|
||||||
|
});
|
||||||
|
ppoly.smallest = ppoly.pool[0];
|
||||||
|
});
|
||||||
|
pools.sort((a, b) => {
|
||||||
|
return a.smallest.perimeter() - b.smallest.perimeter();
|
||||||
|
}).forEach((ppoly, count) => {
|
||||||
|
startPoint = emitPool(ppoly) || startPoint;
|
||||||
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
return startPoint;
|
return startPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue