Add debug logging for intersections again.

This commit is contained in:
Jürg Lehni 2015-08-28 16:18:14 +02:00
parent 0e26b53053
commit e07d8f55ea

View file

@ -232,6 +232,24 @@ PathItem.inject(new function() {
* @param {CurveLocation[]} intersections Array of CurveLocation objects * @param {CurveLocation[]} intersections Array of CurveLocation objects
*/ */
function splitPath(intersections) { function splitPath(intersections) {
console.log('splitting', intersections.length);
intersections.forEach(function(inter) {
var log = ['CurveLocation', inter._id, 'p', inter.getPath()._id,
'i', inter.getIndex(), 't', inter._parameter,
'i2', inter._curve2 ? inter._curve2.getIndex() : null,
't2', inter._parameter2, 'o', !!inter._overlap];
if (inter._other) {
inter = inter.getIntersection();
log.push('Other', inter._id, 'p', inter.getPath()._id,
'i', inter.getIndex(), 't', inter._parameter,
'i2', inter._curve2 ? inter._curve2.getIndex() : null,
't2', inter._parameter2, 'o', !!inter._overlap);
}
console.log(log.map(function(v) {
return v == null ? '-' : v
}).join(' '));
});
// TODO: Make public in API, since useful! // TODO: Make public in API, since useful!
var tMin = /*#=*/Numerical.TOLERANCE, var tMin = /*#=*/Numerical.TOLERANCE,
tMax = 1 - tMin, tMax = 1 - tMin,
@ -417,6 +435,10 @@ PathItem.inject(new function() {
return Math.max(abs(windLeft), abs(windRight)); return Math.max(abs(windLeft), abs(windRight));
} }
var segmentOffset = {};
var pathIndices = {};
var pathIndex = 0;
/** /**
* Private method to trace closed contours from a set of segments according * Private method to trace closed contours from a set of segments according
* to a set of constraints-winding contribution and a custom operator. * to a set of constraints-winding contribution and a custom operator.
@ -431,9 +453,8 @@ PathItem.inject(new function() {
*/ */
function tracePaths(segments, monoCurves, operation) { function tracePaths(segments, monoCurves, operation) {
var segmentCount = 0; var segmentCount = 0;
var segmentOffset = {};
var reportSegments = false && !window.silent; var reportSegments = false && !window.silent;
var reportWindings = false && !window.silent; var reportWindings = true && !window.silent;
var textAngle = 0; var textAngle = 0;
var fontSize = 4 / paper.project.activeLayer.scaling.x; var fontSize = 4 / paper.project.activeLayer.scaling.x;
@ -476,13 +497,19 @@ PathItem.inject(new function() {
, color); , color);
} }
for (var i = 0; i < (reportWindings ? segments.length : 0); i++) { for (var i = 0; i < (reportWindings ? segments.length : 0); i++) {
var seg = segments[i]; var seg = segments[i];
path = seg._path,
id = path._id,
point = seg.point, point = seg.point,
inter = seg._intersection; inter = seg._intersection;
labelSegment(seg, i if (!(id in pathIndices))
pathIndices[id] = ++pathIndex;
labelSegment(seg, '#' + pathIndex + '.' + (i + 1)
+ ' i: ' + !!inter + ' i: ' + !!inter
+ ' p: ' + seg._path._id
+ ' x: ' + seg._point.x + ' x: ' + seg._point.x
+ ' y: ' + seg._point.y + ' y: ' + seg._point.y
+ ' o: ' + (inter && inter._overlap || 0) + ' o: ' + (inter && inter._overlap || 0)