-
Notifications
You must be signed in to change notification settings - Fork 133
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 in cureLocalIntersections #90
base: master
Are you sure you want to change the base?
Conversation
Sorry for the late reply. Could you please add a Fixture / test-case to this PR to verify its function and guard against regression? |
Ref #89 |
Hey ! So I have this exact problem, your fix fixes it though it breaks some of our tests. I am not sure whether or not this is the right fix. However, here is my situation with the nodes when going into the 'if' block within A sequence in the do-while if block.ExpectationsBefore remove: After remove: StepsRemove Remove With real datafirst iteration of the
|
The problem can be reproduced as follows:
|
Thanks for the sample, I'll take a look and maybe merge the PR if @mourner doesn't chime in. I'd prefer if the changes came upstream from earcut.js though. |
Yep — let me check if the test case above reproduces there and whether the fix affects other test cases. |
Just tried that test case and it triangulates fine in JS (added in a branch here mapbox/earcut@4c4b306), so maybe that bug is C++-specific? Not sure, perhaps worth investigating. |
I think I found the problem: it relates to double precision on a given platform. If I change the Point to structure with the following:
On my platform, round_factor is 15 and the tests passes. Any value above, and the test goes infinite loop. |
Interesting! JS uses double precision but there's no issue there, so this must be something weird platform-specific... But doing an equivalent change in JS, all the tests still pass, so I think no harm landing this. |
It seems to integrate this change the Fixture / test-case needs to be added to that PR. |
I am running into this same (original) issue, where my application end up in an infinite loop in cureLocalIntersections. Is there any progress on this PR? |
I have been looking into this a bit further, trying to find what could be causing this problem. I added debugging to see what the pointers are doing when it fails and when it works (after switching the two lines. Below is an example of failed run. The first number is the iteration, the second one is the number of times the The REMOVE lines are printed around the removeNode calls:
After the third remove-cycle the administration looks corrupted: Now for a run with the order of the removeNode line changed:
And then the function exits, as it should: So it looks like this is working (at least for this data-set). Another option could be to only continue the while loop when Looking at the last Remove cycle in both examples, the count of elements in the list is 2, which (I think) does not have to be executed, as there cannot be a selfintersection (if I understand the function correctly). So could changing the while condition to this also work:
|
No description provided.