alter depth first paths to use proper poly2poly parameter
This commit is contained in:
parent
afedbfb5f9
commit
3b07a089dd
2 changed files with 22 additions and 8 deletions
|
|
@ -441,6 +441,10 @@
|
||||||
* @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], {
|
||||||
|
// z, outs: out, call: collector, minArea: min, count, flat: true
|
||||||
|
// });
|
||||||
|
|
||||||
// prepare alignments for clipper lib
|
// prepare alignments for clipper lib
|
||||||
alignWindings(polys);
|
alignWindings(polys);
|
||||||
polys.forEach(function(poly) {
|
polys.forEach(function(poly) {
|
||||||
|
|
@ -491,6 +495,7 @@
|
||||||
|
|
||||||
let orig = polys,
|
let orig = polys,
|
||||||
opts = opt || {},
|
opts = opt || {},
|
||||||
|
count = numOrDefault(opt.count, 1),
|
||||||
depth = numOrDefault(opt.depth, 0),
|
depth = numOrDefault(opt.depth, 0),
|
||||||
clean = opts.clean !== false,
|
clean = opts.clean !== false,
|
||||||
simple = opts.simple !== false,
|
simple = opts.simple !== false,
|
||||||
|
|
@ -538,12 +543,21 @@
|
||||||
opt.outs = opt.outs || [];
|
opt.outs = opt.outs || [];
|
||||||
// store polys in accumulator
|
// store polys in accumulator
|
||||||
opt.outs.append(polys, opt.flat);
|
opt.outs.append(polys, opt.flat);
|
||||||
if (opt.count > 1) {
|
// callback for expand() compatibility
|
||||||
|
if (opt.call) {
|
||||||
|
opt.call(polys, count);
|
||||||
|
}
|
||||||
|
// check for more offsets
|
||||||
|
if (count > 1) {
|
||||||
// decrement count, increment depth
|
// decrement count, increment depth
|
||||||
opt.count--;
|
opt.count = count - 1;
|
||||||
opt.depth = depth + 1;
|
opt.depth = depth + 1;
|
||||||
// call next offset
|
// call next offset
|
||||||
offset(polys, dist, opt);
|
offset(polys, dist, opt);
|
||||||
|
// } else if (count === 0) {
|
||||||
|
// // depth = 0 means offset until failure
|
||||||
|
// opt.depth = depth + 1;
|
||||||
|
// offset(polys, dist, opt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1096,9 +1096,9 @@
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// do not allow inner and outer polys to mix
|
// do not allow inner and outer polys to mix
|
||||||
if (!above.sameWindings(pool)) {
|
// if (!above.sameWindings(pool)) {
|
||||||
continue;
|
// 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);
|
||||||
|
|
@ -1112,8 +1112,8 @@
|
||||||
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);
|
startPoint = poly2polyEmit(polys, startPoint, emitter, null, false);
|
||||||
startPoint = poly2polyEmit(poolPoly.poolsDown, startPoint, emitPool, "del_pdown");
|
startPoint = poly2polyEmit(poolPoly.poolsDown, startPoint, emitPool, "del_pdown", false);
|
||||||
return startPoint;
|
return startPoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1121,7 +1121,7 @@
|
||||||
// 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");
|
startPoint = poly2polyEmit(pools, startPoint, emitPool, "del_ptop", true);
|
||||||
})
|
})
|
||||||
return startPoint;
|
return startPoint;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue