Adding additional data to each point

Nov 18, 2013 at 10:31 PM
So basically, I need a way to associate extra data to each vertex of the final mesh (not just the coordinates). Is there a way to do this?

If not, is there some way I can reliably check if one point in the output triangles is the same as some other point that I used in the input (in order to make a dictionary for the extra data)?

I've used the Poly2Tri library before where I could either extend their build in Point class and just fill it with the data I needed and then pass it to the triangulation algorithm. The output triangles contained the same points that were inputted so there were no problems there.
Nov 19, 2013 at 7:41 AM
Edited Nov 19, 2013 at 7:45 AM
There are a couple of ways to do this, while the one you propose is currently not possible. But I could add a method InputGeometry.AddPoint(Vertex v) so one could derive from Vertex and add data as needed.

At the moment, you could for example use InputGeometry.AddPoint(double x, double y, int boundary) and use the boundary mark as an index to an array holding your data. Or, if your data is real, use InputGeometry.AddPoint(double x, double y, int boundary, double[] attribs) and use the attribs array for your data.
Nov 19, 2013 at 9:31 AM
Ok then. I'll use the index. It would be nice to have the other feature implemented though.
Nov 20, 2013 at 9:37 PM
It doesn't seem that the boundary method works. When I try it with the points (0,0), (100, 0), (100, 100), (0, 100) and assign them boundaries 0, 1, 2, 3, after triangulation the point (0, 0) has the boundary 1. I can't use it as an index if it gets changed.
Nov 20, 2013 at 9:50 PM
Nov 20, 2013 at 9:50 PM
My current solution is (inputGeom.Points as List<Vertex>).Add(myVertexInstance) where myVertexInstanceis an instance of a subclass of Vertex that includes additional data. Then later I do (triangle.GetVertex(0) as MyVertexClass).Data.

Does this break for any input? As in, are the inputted vertices replaced by new ones with the same coordinates at any point? So far it seems to work.
Nov 20, 2013 at 10:05 PM
Edited Nov 20, 2013 at 10:43 PM
No, the vertex instances get directly added to the mesh. But bypassing the InputGeometry.Add(...) methods is not a good idea, since the bounding box gets calculated there. The easiest way would be an additional method InputGeometry.AddPoint(Vertex v), so I will add it.

Regarding the boundary mark: Triangle will automatically set vertex marks form 0 to 1, if they are on a boundary segment (I missed that, sorry). You could start indexing from any k > 1. That should work.

EDIT: Thanks a5r for the link. It explains the problem using 0 or 1 for the vertex marker.