Skip to content

Commit

Permalink
Fix for overlapping edges
Browse files Browse the repository at this point in the history
  • Loading branch information
mfogel committed Feb 2, 2018
1 parent 4dd24ed commit edfe198
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/subdivide_segments.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = function subdivide(eventQueue, subject, clipping, sbbox, cbbox,
if (next) {
if (possibleIntersection(event, next.key, eventQueue) === 2) {
computeFields(event, prevEvent, operation);
computeFields(event, next.key, operation);
computeFields(next.key, event, operation);
}
}

Expand Down
12 changes: 12 additions & 0 deletions test/edge_cases.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,17 @@ tap.test('Edge cases', function(main) {
t.end();
});

main.test('overlapping edges difference', function (t) { // issue #35
const p1 = [ [ [0,0], [3,0], [3,3], [0,3], [0,0] ] ]
const p2 = [ [ [1,0], [2,0], [2,4], [1,4], [1,0] ] ]

var result = martinez.diff(p1, p2)
t.deepEqual(result, [
[[[0, 0], [1, 0], [1, 3], [0, 3], [0, 0]]],
[[[2, 0], [3, 0], [3, 3], [2, 3], [2, 0]]]
])
t.end()
})

main.end();
});

0 comments on commit edfe198

Please sign in to comment.