From 32cf1ba69eed2edcfbe23e91eb612f270a3b01ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 27 Dec 2015 18:34:41 +0100 Subject: [PATCH] Partly revert "Treat overlaps as crossings as well." This partly reverts commit deafacdad026bacabe3c6f2353910db4a6c04b16 and closes #868 --- src/path/PathItem.Boolean.js | 6 ++++-- src/path/PathItem.js | 15 ++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/path/PathItem.Boolean.js b/src/path/PathItem.Boolean.js index 163a0eb0..82f8567a 100644 --- a/src/path/PathItem.Boolean.js +++ b/src/path/PathItem.Boolean.js @@ -92,7 +92,9 @@ PathItem.inject(new function() { _path2.reverse(); // Split curves at crossings on both paths. Note that for self- // intersection, path2 is null and getIntersections() handles it. - var crossings = CurveLocation.expand(_path1.getCrossings(_path2)); + var crossings = CurveLocation.expand(_path1.getCrossings(_path2, + // Only handle overlaps when not self-intersecting + !!_path2)); divideLocations(crossings); var segments = [], @@ -140,7 +142,7 @@ PathItem.inject(new function() { return null; var _path1 = preparePath(path1, false), _path2 = preparePath(path2, false), - crossings = _path1.getCrossings(_path2), + crossings = _path1.getCrossings(_path2, true), sub = operation === 'subtract', paths = []; diff --git a/src/path/PathItem.js b/src/path/PathItem.js index 9b525ac0..cf8726b2 100644 --- a/src/path/PathItem.js +++ b/src/path/PathItem.js @@ -140,19 +140,20 @@ var PathItem = Item.extend(/** @lends PathItem# */{ }, /** - * Returns all crossings between two {@link PathItem} items as an array - * of {@link CurveLocation} objects. {@link CompoundPath} items are also - * supported. - * Crossings are intersections where the paths actually are crossing each - * other, as opposed to simply touching. + * Returns all crossings between two {@link PathItem} items as an array of + * {@link CurveLocation} objects. {@link CompoundPath} items are also + * supported. Crossings are intersections where the paths actually are + * crossing each other, as opposed to simply touching. * * @param {PathItem} path the other item to find the crossings with + * @param {Boolean} includeOverlaps whether to also count overlaps as + * crossings * @see #getIntersections(path) */ - getCrossings: function(path) { + getCrossings: function(path, includeOverlaps) { return this.getIntersections(path, function(inter) { // Check overlap first since it's the cheaper test between the two. - return inter.isOverlap() || inter.isCrossing(); + return includeOverlaps && inter.isOverlap() || inter.isCrossing(); }); },