Remove need for __segment property and further simplify computeBoolean() code.

This commit is contained in:
Jürg Lehni 2013-05-04 02:50:18 -07:00
parent 43b7afb961
commit 9fb7340aac
2 changed files with 9 additions and 14 deletions

View file

@ -57,14 +57,14 @@ var CurveLocation = this.CurveLocation = Base.extend(/** @lends CurveLocation# *
* @type Segment * @type Segment
* @bean * @bean
*/ */
getSegment: function() { getSegment: function(/* preferFirst */) {
if (!this._segment) { if (!this._segment) {
var curve = this.getCurve(), var curve = this.getCurve(),
parameter = this.getParameter(); parameter = this.getParameter();
if (parameter === 0) { if (parameter === 1) {
this._segment = curve._segment1;
} else if (parameter === 1) {
this._segment = curve._segment2; this._segment = curve._segment2;
} else if (parameter === 0 || arguments[0]) {
this._segment = curve._segment1;
} else if (parameter == null) { } else if (parameter == null) {
return null; return null;
} else { } else {

View file

@ -57,7 +57,6 @@ PathItem.inject(new function() {
segment = curve && curve.getSegment1() || loc.getSegment(); segment = curve && curve.getSegment1() || loc.getSegment();
if (others) if (others)
others.push(other); others.push(other);
other.__segment = segment;
segment._ixPair = other; segment._ixPair = other;
} }
return others; return others;
@ -168,22 +167,18 @@ PathItem.inject(new function() {
continue; continue;
var path = node.path, var path = node.path,
nuPath = new Path(), nuPath = new Path(),
firstNode = node, end = node._ixPair && node._ixPair.getSegment(true);
intersectNode = null;
if (node.getPrevious()._INVALID) { if (node.getPrevious()._INVALID) {
node.setHandleIn(node._ixPair node.setHandleIn(node._ixPair
? node._ixPair.getIntersection().__segment._handleIn ? node._ixPair.getSegment(true)._handleIn
: Point.create(0, 0)); : Point.create(0, 0));
} }
while (node && !node._visited && node !== intersectNode) { do {
node._visited = true; node._visited = true;
intersectNode = intersectNode || firstNode._ixPair
&& firstNode._ixPair.getIntersection().__segment;
// node._ixPair is this node's intersection CurveLocation object // node._ixPair is this node's intersection CurveLocation object
// node._ixPair.getIntersection() is the other CurveLocation object this node intersects with
if (node._ixPair) { if (node._ixPair) {
var nextNode = node._INVALID var nextNode = node._INVALID
? node._ixPair.getIntersection().__segment ? node._ixPair.getSegment(true)
: node; : node;
nuPath.add(new Segment(node._point, node._handleIn, nuPath.add(new Segment(node._point, node._handleIn,
nextNode._handleOut)); nextNode._handleOut));
@ -193,7 +188,7 @@ PathItem.inject(new function() {
nuPath.add(node); nuPath.add(node);
} }
node = node.getNext(); node = node.getNext();
} } while (node && !node._visited && node !== end);
// Avoid stray segments and incomplete paths // Avoid stray segments and incomplete paths
if (nuPath._segments.length > 2) { if (nuPath._segments.length > 2) {
nuPath.setClosed(true); nuPath.setClosed(true);