Partly revert "Treat overlaps as crossings as well."

This partly reverts commit deafacdad0 and closes #868
This commit is contained in:
Jürg Lehni 2015-12-27 18:34:41 +01:00
parent a7a07fb6d5
commit 32cf1ba69e
2 changed files with 12 additions and 9 deletions

View file

@ -92,7 +92,9 @@ PathItem.inject(new function() {
_path2.reverse(); _path2.reverse();
// Split curves at crossings on both paths. Note that for self- // Split curves at crossings on both paths. Note that for self-
// intersection, path2 is null and getIntersections() handles it. // 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); divideLocations(crossings);
var segments = [], var segments = [],
@ -140,7 +142,7 @@ PathItem.inject(new function() {
return null; return null;
var _path1 = preparePath(path1, false), var _path1 = preparePath(path1, false),
_path2 = preparePath(path2, false), _path2 = preparePath(path2, false),
crossings = _path1.getCrossings(_path2), crossings = _path1.getCrossings(_path2, true),
sub = operation === 'subtract', sub = operation === 'subtract',
paths = []; paths = [];

View file

@ -140,19 +140,20 @@ var PathItem = Item.extend(/** @lends PathItem# */{
}, },
/** /**
* Returns all crossings between two {@link PathItem} items as an array * Returns all crossings between two {@link PathItem} items as an array of
* of {@link CurveLocation} objects. {@link CompoundPath} items are also * {@link CurveLocation} objects. {@link CompoundPath} items are also
* supported. * supported. Crossings are intersections where the paths actually are
* Crossings are intersections where the paths actually are crossing each * crossing each other, as opposed to simply touching.
* other, as opposed to simply touching.
* *
* @param {PathItem} path the other item to find the crossings with * @param {PathItem} path the other item to find the crossings with
* @param {Boolean} includeOverlaps whether to also count overlaps as
* crossings
* @see #getIntersections(path) * @see #getIntersections(path)
*/ */
getCrossings: function(path) { getCrossings: function(path, includeOverlaps) {
return this.getIntersections(path, function(inter) { return this.getIntersections(path, function(inter) {
// Check overlap first since it's the cheaper test between the two. // Check overlap first since it's the cheaper test between the two.
return inter.isOverlap() || inter.isCrossing(); return includeOverlaps && inter.isOverlap() || inter.isCrossing();
}); });
}, },