From 4770cfe2f844bc1e93b8315592bf87626f6fcb1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 10 Sep 2015 05:18:56 +0200 Subject: [PATCH] Minor intersection refactoring clean up. --- src/path/CurveLocation.js | 7 +++++-- src/path/PathItem.js | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/path/CurveLocation.js b/src/path/CurveLocation.js index fd3e056c..2c13bc86 100644 --- a/src/path/CurveLocation.js +++ b/src/path/CurveLocation.js @@ -65,9 +65,9 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{ this._distance = _distance; this._overlap = _overlap; this._intersection = _intersection; - this._other = false; if (_intersection) { _intersection._intersection = this; + // TODO: Remove this once debug logging is removed. _intersection._other = true; } // Also store references to segment1 and segment2, in case path @@ -325,6 +325,9 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{ res; // Sort by path-id, curve, parameter, curve2, parameter2 so we // can easily remove duplicates with calls to equals() after. + // NOTE: We don't call getCurve() / getParameter() here, since + // this code is used internally in boolean operations where all + // this information remains valid during processing. if (path1 === path2) { if (curve1 === curve2) { var diff = l1._parameter - l2._parameter; @@ -334,7 +337,7 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{ curve21 = i1 && i1._curve, curve22 = i2 && l2._curve; res = curve21 === curve22 // equal or both null - ? (i1 ? i1._parameter : 0) - (i2 ? i2._parameter : 0) + ? i1 && i2 ? i1._parameter - i2._parameter : 0 : curve21 && curve22 ? curve21.getIndex() - curve22.getIndex() : curve21 ? 1 : -1; diff --git a/src/path/PathItem.js b/src/path/PathItem.js index c370c98a..d6d2b7a6 100644 --- a/src/path/PathItem.js +++ b/src/path/PathItem.js @@ -106,8 +106,8 @@ var PathItem = Item.extend(/** @lends PathItem# */{ var parts = Curve.subdivide(values1); Curve._getIntersections(parts[0], parts[1], curve1, curve1, locations, { - // Only possible if there is only one curve: - startConnected: length1 === 1, + // Only possible if there is only one closed curve: + startConnected: length1 === 1 && p1.equals(p2), // After splitting, the end is always connected: endConnected: true, reparametrize: function(t1, t2) {