artem-ogre/CDT

Callback for `addNewVertex`?

svenpilz opened this issue · 2 comments

Hello fellow triangle enthusiasts,

I'm trying the awesome IntersectingConstraintEdges::Resolve feature and wonder if it would be possible to get a callback for addNewVertex, so we could update auxiliary information outside CDT. For example, we "emulate" 3D triangulation by running CDT in parameter space (aka uv, aka texture coordinates) and map the result back to 3D by just keeping the input 3D vertex positions. For that, we would like to just linearly interpolate auxiliary information. Meaning a callback given two vertices and the intersection or distance along the edge would be really helpful.

What do you think?

Thanks and greetings from Berlin
Sven

Hello, Sven,

What you describe is indeed common, e.g., when triangulating 2.5D surface interpolation is needed to calculate the heights at edge intersections. The solution we have in CDT is different from using a callback. Instead we maintain a 'pieces to original edges' mapping: for each edge in final triangulation that resulted from splitting original constraint edges it stores the list of original edges.

example
In the example above if original constraints are (0,2), (1,3) the mapping will be: (0,4)->[(0,2)], (2,4)->[(0,2)], (1,4)->[(1,3)], (3,4)->[(1,3)].
CDT has following helper-functions included: CDT::EdgeToPiecesMapping and CDT::EdgeToSplitVertices. These helpers can be chained to convert the mapping to something more actionable: mapping from original edge to new vertices:
(0,2)->[4], (1,3)->4.
In our case this is already enough to perform the interpolation using end point of one of the original edges. But if you need to know both edges for interpolation new helper could be introduced SplitVerticesToEdges which would give you
4 ->[(0,2), (1,3)]
Pull-requests or feature requests are welcome :)

I hope this helps you to solve your task. Feel free to ask if you have any questions.

I’m closing the issue for now. Let me know if you think I should reopen it.