Improve debug logging.

This commit is contained in:
Jürg Lehni 2015-09-17 01:15:41 +02:00
parent 2750c34090
commit 1508b8fc75

View file

@ -224,9 +224,12 @@ PathItem.inject(new function() {
clearSegments.push(segment); clearSegments.push(segment);
} }
// Link the new segment with the intersection on the other curve // Link the new segment with the intersection on the other curve
if (segment._intersection) if (segment._intersection) {
console.log('Oh dear there was one already: ' + segment._intersection); console.log('Segment already has an intersection: '
segment._intersection = loc._intersection; + segment._intersection + ', ' + loc._intersection);
} else {
segment._intersection = loc._intersection;
}
// loc._setCurve(segment.getCurve()); // loc._setCurve(segment.getCurve());
loc._segment = segment; loc._segment = segment;
loc._parameter = t; loc._parameter = t;
@ -542,7 +545,7 @@ PathItem.inject(new function() {
// intersection. // intersection.
drawSegment(seg, 'add', i, 'black'); drawSegment(seg, 'add', i, 'black');
} else if (other._path === seg._path) { // Self-intersection } else if (other._path === seg._path) { // Self-intersection
drawSegment(seg, 'self-int', i, 'red'); drawSegment(seg, 'self-int', i, 'purple');
// Switch to the intersecting segment, as we need to // Switch to the intersecting segment, as we need to
// resolving self-Intersections. // resolving self-Intersections.
seg = other; seg = other;
@ -569,12 +572,12 @@ PathItem.inject(new function() {
drawSegment(seg, 'exclude-cross', i, 'green'); drawSegment(seg, 'exclude-cross', i, 'green');
seg = other; seg = other;
} else { } else {
drawSegment(seg, 'exclude-stay', i, 'orange'); drawSegment(seg, 'exclude-stay', i, 'blue');
} }
} else if (operator(seg._winding)) { } else if (operator(seg._winding)) {
// Do not switch to the intersecting segment as this segment // Do not switch to the intersecting segment as this segment
// is part of the the boolean result. // is part of the the boolean result.
drawSegment(seg, 'ignore-keep', i, 'black'); drawSegment(seg, 'keep', i, 'black');
} else if (operator(other._winding) && inter.isCrossing()) { } else if (operator(other._winding) && inter.isCrossing()) {
// The other segment is part of the boolean result, and we // The other segment is part of the boolean result, and we
// are at crossing, switch over. // are at crossing, switch over.
@ -582,7 +585,7 @@ PathItem.inject(new function() {
seg = other; seg = other;
} else { } else {
// Keep on truckin' // Keep on truckin'
drawSegment(seg, 'stay', i, 'orange'); drawSegment(seg, 'stay', i, 'blue');
} }
if (seg._visited) { if (seg._visited) {
// We didn't manage to switch, so stop right here. // We didn't manage to switch, so stop right here.
@ -599,9 +602,8 @@ PathItem.inject(new function() {
inter = seg && seg._intersection; inter = seg && seg._intersection;
other = inter && inter._segment; other = inter && inter._segment;
if (seg === start || seg === otherStart) { if (seg === start || seg === otherStart) {
drawSegment(seg, 'close', i, 'red'); drawSegment(seg, 'done', i, 'red');
} } else if (seg._visited && (!other || other._visited)) {
if (seg._visited && (!other || other._visited)) {
drawSegment(seg, 'visited', i, 'red'); drawSegment(seg, 'visited', i, 'red');
} }
if (!inter && !operator(seg._winding)) { if (!inter && !operator(seg._winding)) {