Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite loop bug #9

Closed
wants to merge 14 commits into from
Prev Previous commit
Next Next commit
Changed maxPossibleEvents
ctessum committed May 7, 2016
commit a928b5b206f4fcbed01534d5a8675febadd98513
7 changes: 2 additions & 5 deletions clipper.go
Original file line number Diff line number Diff line change
@@ -115,11 +115,8 @@ func (c *clipper) compute(operation Op) Polygon {

// From the manuscript, the cycle is executed
// n + 4k times, where n is the number of segments and k is the number of
// intersections. I believe the maximum k would be about n^2, but
// we assume it here to be 2*n. This may not be the absolute maximum
// number of events, but it is not likely that there would be more intersections
// than this in a real polygon.
maxPossibleEvents := numSegments * 9
// intersections. I believe the maximum k would be about n^2.
maxPossibleEvents := numSegments + 4*numSegments*numSegments

for !c.eventQueue.IsEmpty() {