davideberly / GeometricTools

A collection of source code for computing in the fields of mathematics, geometry, graphics, image analysis and physics.
Boost Software License 1.0
1.08k stars 202 forks source link

ConstrainedDelaunay2 "Failed to find vertex in graph." #54

Closed Cray-1 closed 1 year ago

Cray-1 commented 1 year ago

I have created a ConstrainedDelaunay2 and added the following 7 vertices: (-1, -1), (-1, 1), (1, -1), (0, 0), (0, -1), (-1, 0), (0, 0). When I insert the edge (3, 4) I get the error "Failed to find vertex in graph." in GetLinkEdges. I assume this has something to do with the duplicated vertex. The vmap in GetLinkEdges contains only 6 vertices. But GetNumVertices() and GetNumUniqueVertices() of ConstrainedDelaunay2 both return 7. Might this be a bug or isn't it allowed to add duplicated vertices or am I doing something else wrong? I would very appreciate any help.

davideberly commented 1 year ago

Thank you for reporting this. I am looking into the issue. It might be a regression when I switched from using 'set' to 'unordered_set'. I should have a resolution in one or two days.

Cray-1 commented 1 year ago

Is there still a chance that this will be fixed soon? I just wanted to ask so I know if it is worth waiting or if I should better look for another solution.

davideberly commented 1 year ago

The regression occurred in Delaunay2 when I switched from 'set' to 'unordered_set'. The ProcessedVertex Hash(...) and operator==(...) functions incorrectly used the 'location' member function. I also modified ConstrainedDelaunay2::InsertEdge to replace the incoming edge by the equivalence-class vertex indices (via mDuplicates) in case InsertEdge is called with a duplicated vertex. The Delaunay2D sample has another test case added to it. The fixed code has been pushed.