kedmegas / poly2tri

Automatically exported from code.google.com/p/poly2tri
Other
0 stars 0 forks source link

StackOverflowException when triangulating a ConstrainedPointSet #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

It is quite complicated to describe but if you make a serializable (to XML)
for Constrained point sets, I can just send you that instead :)

What version of the product are you using? On what operating system?

The Java version

Please provide any additional information below.

The stacktrace:

java.lang.StackOverflowError
    at
org.poly2tri.triangulation.TriangulationUtil.inScanArea(TriangulationUtil.java:1
51)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:643
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:682
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:682
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:682
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:682
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:682
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:682
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:682
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:682
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:682
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:682
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:682
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:682
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:682
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipEdgeEvent(DTSweep.java:682
)
    at
org.poly2tri.triangulation.delaunay.sweep.DTSweep.flipScanEdgeEvent(DTSweep.java
:806)

and so on....

Original issue reported on code.google.com by nyblom...@gmail.com on 9 Feb 2010 at 12:16

GoogleCodeExporter commented 9 years ago
Here is an XML-file for the example where the triangulation goes crazy.

Original comment by nyblom...@gmail.com on 9 Feb 2010 at 1:53

Attachments:

GoogleCodeExporter commented 9 years ago
Forgot to mention that the lines are supposed to be the constrained edges, but 
you
might have figured that out anyway ;)

I also attached a file that shows the lines and the points.

Original comment by nyblom...@gmail.com on 9 Feb 2010 at 1:57

Attachments:

GoogleCodeExporter commented 9 years ago
I tried to perturb the input points randomly and this made it work. I guess 
that the
problem has something to do with points that lies on the same line.
In the book "Numerical Recipies" the "fix" this in their Delaunay triangulator 
by
randomness when this problem happens. They are not proud of it though :)

Original comment by nyblom...@gmail.com on 9 Feb 2010 at 2:12

GoogleCodeExporter commented 9 years ago
Sorry didn't notice this until now. Thought I would get an email or something 
if a 
bug was posted :).

I'll take a look. In constrained triangulation I know these errors can happen 
if 
there is duplicate points, eg two points with same coordinate.

Original comment by thahlen@gmail.com on 9 Feb 2010 at 3:52

GoogleCodeExporter commented 9 years ago
Yes I think I see the issue just by looking at the xml file.

Every polygon has the same start and end point defined. So you actually get two 
points on the same coordinate and this will make my constrained implementation 
confused. I can't easily detect the duplicate point issue in that code so I 
would 
have to add some verification code that checks the input for duplicates :). For 
now 
I assume the given input doesn't have duplicates. 

If you look at the Polygon constuctor I have added this check to remove the 
last 
point from pointsets where the polygon is defined with a start and end point at 
the 
same position. Since I noticed several external polygon editors export polygons 
with 
duplicate points
        if( points.get(0).equals( points.get(points.size()-1) ) )
        {
            points.remove( points.size()-1 );
        }

So instead of perturbing your input points just do a simple check if first and 
last 
point on the polygon is the same and remove it.

Original comment by thahlen@gmail.com on 9 Feb 2010 at 4:15

GoogleCodeExporter commented 9 years ago
Oh, I see! Thanks!

Original comment by nyblom...@gmail.com on 9 Feb 2010 at 6:58

GoogleCodeExporter commented 9 years ago
Need to add some validation code to input data that can be run optionally to 
detect 
input errors when triangulation fails.

Original comment by thahlen@gmail.com on 17 Feb 2010 at 8:23

GoogleCodeExporter commented 9 years ago
Marked this as fixed since it wasn't an error from the beginning :)

Original comment by thahlen@gmail.com on 27 Aug 2010 at 10:20