Some comment clean-ups.

This commit is contained in:
Jürg Lehni 2015-10-21 02:24:54 +02:00
parent 341fe1ab4e
commit 3daa7f78b4

View file

@ -472,15 +472,15 @@ PathItem.inject(new function() {
// See if this segment and the next are both not visited yet, or // See if this segment and the next are both not visited yet, or
// are bringing us back to the beginning, and are both part of // are bringing us back to the beginning, and are both part of
// the boolean result. // the boolean result.
// Handling overlaps correctly here is a bit tricky business, // Handling overlaps correctly here is tricky, requiring two
// and requires two passes, first with `strict = true`, then // passes, first with strict = true, then false:
// `false`: In strict mode, the current segment and the next // In strict mode, the current and the next segment are both
// segment are both checked for validity, and only the current // checked for validity, and only the current one is allowed to
// one is allowed to be an overlap (passing true for // be an overlap (passing true for unadjusted in isValid()).
// `unadjusted` in isValid()). If this pass does not yield a // If this pass does not yield a result, the non-strict mode is
// result, the non-strict mode is used, in which invalid current // used, in which invalid current segments are tolerated, and
// segments are tolerated, and overlaps for the next segment are // overlaps for the next segment are allowed as long as they are
// allowed as long as they are valid when not adjusted. // valid when not adjusted.
if (isStart(nextSeg) if (isStart(nextSeg)
|| !seg._visited && !nextSeg._visited || !seg._visited && !nextSeg._visited
// Self-intersections (!operator) don't need isValid() calls // Self-intersections (!operator) don't need isValid() calls
@ -538,6 +538,8 @@ PathItem.inject(new function() {
// Do not adjust winding when checking overlaps. // Do not adjust winding when checking overlaps.
if (other && isValid(other, inter.isOverlap())) if (other && isValid(other, inter.isOverlap()))
seg = other; seg = other;
// If the new segment is visited already, check if we're back
// at the start.
if (seg._visited) { if (seg._visited) {
finished = isStart(seg); finished = isStart(seg);
if (!finished && inter) { if (!finished && inter) {
@ -580,9 +582,9 @@ PathItem.inject(new function() {
} }
// Add the path to the result, while avoiding stray segments and // Add the path to the result, while avoiding stray segments and
// paths that are incomplete or cover no area. // paths that are incomplete or cover no area.
// As an optimization, only check paths with 4 or less segments // As an optimization, only check paths with 8 or less segments
// for their area, and assume that they cover an area when more. // for their area, and assume that they cover an area when more.
if (path && (path._segments.length > 4 if (path && (path._segments.length > 8
|| !Numerical.isZero(path.getArea()))) { || !Numerical.isZero(path.getArea()))) {
paths.push(path); paths.push(path);
path = null; path = null;