jhasse / poly2tri

2D constrained Delaunay triangulation library
BSD 3-Clause "New" or "Revised" License
429 stars 89 forks source link

Crash with a relatively simple polygon #53

Open nirvn opened 11 months ago

nirvn commented 11 months ago

The following polygon crashes poly2try:

image

The polygon is relatively simple. One particularity is the presence of two overlapping vertices here:

image

I'm including a .dat file that triggers the crash using testbed's p2t (i.e. ./p2t crash.dat):

crash.zip

aismann commented 9 months ago

Have you check this:

nirvn commented 9 months ago

@aismann , the polygon has no holes, only an exterior polyline that ends up having two vertices (i.e. vertex #3 and #6) overlapping each other:

image

aismann commented 9 months ago

If you are given input and aren't sure same point exist twice you need to check for this yourself.

nirvn commented 9 months ago

@aismann , in this case, removing one point (either 3 or 6) would dramatically change the shape of the polygon. Is the solution to move the point of a insignificant distance (visually speaking)?

aismann commented 9 months ago

@aismann , in this case, removing one point (either 3 or 6) would dramatically change the shape of the polygon. Is the solution to move the point of a insignificant distance (visually speaking)?

Take the left/right neighborhood points for each triangle (3/6) => not the same!