another pool nesting fix requiring matching windings

This commit is contained in:
Stewart Allen 2020-10-31 22:05:45 -04:00
commit 273eed2bb9
2 changed files with 11 additions and 0 deletions

View file

@ -645,6 +645,13 @@
}
};
/**
* @returns {boolean} true if both polygons wind the same way
*/
PRO.sameWindings = function(poly) {
return this.isClockwise() === poly.isClockwise();
};
/**
* reverse direction of polygon points.
* @returns {Polygon} self

View file

@ -1056,6 +1056,10 @@
// console.log({skip_open_above:above});
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 (polygonFitsIn(pool, above, 0.1)) {
above.poolsDown.push(pool);