Why Segments are now initialized with Vertex types instead of indices?

Dec 17, 2015 at 1:53 PM
Edited Dec 17, 2015 at 2:06 PM
Hi,

I really can't understand this, we love to work with vertices and indices and believe that it's the best way to deal with polygons.

How can Triangle.NET fast lookup for vertex indices in this way?

Thanks,

Alberto
Coordinator
Dec 17, 2015 at 3:19 PM
Edited Dec 17, 2015 at 3:23 PM
This was due to a request to have fixed input vertex ids (https://triangle.codeplex.com/discussions/644047). Making the vertex instances part of the segment was the natural way to implement this.

Could you explain what problem you are facing?

If you need to access vertex indices before triangulation, make sure to setup the id's manually:
var polygon = CreateSomePolygon();

int id = 0;

foreach (var p in polygon.Points)
{
    p.ID = id++;
}
Dec 17, 2015 at 3:29 PM
Thanks for your answer.

Do you mean that you pass a Vertex type only to get the integer index value? You aren't using vertex coordinates again, right?

Thanks,

Alberto.
Coordinator
Dec 17, 2015 at 3:43 PM
Edited Dec 17, 2015 at 8:42 PM
I'm not sure what you mean.

Regarding the meshing process:
Before this change, a segment was identified by two integer values: the id's of the two vertices defining the segment. To insert the segment into the triangulation, I had to look up the actual vertices in a dictionary.
Having the segments contain the actual vertex instances eliminates the need of a dictionary (and solved some other problems, making fixed vertex ids work).
Dec 17, 2015 at 3:50 PM
Now I understand, thanks.

In any case, I believe that current approach could lead to problems if somebody changes the dictionary vertex, in Beta 3 approach everything was safe. In addition I would always recommend to leave the old constructor as deprecated.

Thanks again,

Alberto