abellgithub / delaunator-cpp

A really fast C++ library for Delaunay triangulation of 2D points
MIT License
154 stars 33 forks source link

INVALID_INDEX problem #20

Closed mirecc414 closed 10 months ago

mirecc414 commented 10 months ago

Hello, I don't have any other means to contact you, so I resorted to creating new issue. I am trying to figure out what am I doing wrong - I have ~1000 points defined and I am trying to run triangulation on them. Then i am iterating halfedges for some further processing but some of them are pointing to "INVALID_INDEX" (std::numeric_limits::max()). It occours close the end of halfedges vector. What can cause this behavior? Positions of points that I am feeding into Delaunator are in magnitude of 100-s.

Thanks in advance and sorry for this form of contact.

image

abellgithub commented 10 months ago

I haven't looked at this code in a long time, but I think that if you have an invalid index, it means that the edge is on the outside of the triangulation (there is no triangle on the other side of the edge). If you want to provide the data and code you're using I can take a look.

mirecc414 commented 10 months ago

Thanks, It makes a lot of sense to me now, I wonder how i didn't see it. I tried to run super simple example from your READ ME:

std::vector<double> coords = { -1, 1, 1, 1, 1, -1, -1, -1 };
delaunator::Delaunator del = delaunator::Delaunator(coords);

results look like this image