Comments (9)
@alexbol99 Any chance of getting PR #56 merged? I'm currently using that branch on a webserver to avoid this bug crashing the webserver...
@jovankrajevski In case it's useful: you can use the branch for PR #56 from npm with npm i OliverColeman/flatten-js#preventinfiniteloop
. Then you can catch the exception thrown when an infinite loops seems to be occurring and handle it gracefully.
from flatten-js.
Still working on it
from flatten-js.
Do you have any suggestions on which types of polygons we should be avoiding so that we can avoid the infinite looping while you are working on this issue?
from flatten-js.
I would prefer to see PR #56 merged tbh. imo it is better to have an error thrown, so that we could fall back on some other heuristic, than have the browser/server looping forever.
from flatten-js.
I would not fix it in this way. The reason of infinite loop is illegal merge of two polygon caused by numeric errors. I know how to prevent it in the way that it throw error before it comes to infinite loop. It just takes me some time to implement. Sorry for delay.
from flatten-js.
Do you have any suggestions on which types of polygons we should be avoiding so that we can avoid the infinite looping while you are working on this issue?
Operation is stable when polygon has no almost zero length edges. Intersection between two edges when one of them is big and other has length closed to zero is numerically unstable. Try to filter your polygons from tiny edges that have no meaning, and the result will be fine.
from flatten-js.
@alexbol99 thanks. I actually solved my problem by just casting the coordinates to ints, but I will make sure that I do not have edges with length < 1. I am not sure if you are aware that this bug happens sometimes with floating point coordinates, and not just with edges that are really small, so I just wanted to point that out.
from flatten-js.
@jovankrajevski , @OliverColeman
Ok, I added infinite loop detection using infamous "turtle and rabbit" algorithm.
It throws an "Infinite loop" error if additional loop detected in the chain of edges supposed to form face.
Fix available in the version v1.2.11.
Best,
Alex
from flatten-js.
Awesome, thanks for this :). I am wondering if it would be even better to put that code into CircularLinkedList.js rather than face.js? At the moment face.js is the only code that uses CircularLinkedList, but if in the future some other code uses it and causes an infinite loop, it would still be caught.
from flatten-js.
Related Issues (20)
- Incorrect unify result #55 HOT 6
- Bad performance with boolean operations HOT 2
- Typings exported incorrectly HOT 1
- Intersect ray with ray or line HOT 1
- Support stroke-dasharray HOT 4
- Cannot figure out a workaround for INFINITE LOOP while unifying polygons HOT 4
- Add method to easy check equal polygons HOT 9
- Incorrect return type on `Relations.relate`
- Infinite Loop when intersecting Polygons (v1.3.4) HOT 7
- fillOpacity is not being used when applying svg() on Box type ( translated to Rect ) HOT 1
- IntervalTree search is a bottleneck HOT 14
- feature request: construct Arc from the parameters used in SVG HOT 3
- v1.4 Relations.intersect() doesn't allow Polygon argument HOT 3
- ray and segment intersect HOT 5
- HELP - What is the best way to create parallel segments ? HOT 3
- Adding Point to Vector HOT 3
- Errors export HOT 2
- Cannot cut polygon with MultiLine HOT 3
- Can I merge duplicated edges and merge faces in Polygon? HOT 3
- Segment Wrong points after rotate? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flatten-js.