CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
4.93k stars 1.38k forks source link

using halfedges_around_source(v_source, mesh) to loop the halfedges results infinite loop #8454

Closed citystrawman closed 1 month ago

citystrawman commented 1 month ago

Please use the following template to help us solving your issue.

Issue Details

I am using halfedges_around_source(v_source, mesh) to loop through all halfedges around a source vertex. The code is as follows:

//find out v_source...

for (halfedge_descriptor h_around : halfedges_around_source(v_source, mesh)) {
    if (h_around != h_next && target(h_around, mesh) == v_next_target) {
        CGAL::draw(mesh);
        CGAL::Euler::flip_edge(h_around, mesh);
        CGAL::draw(mesh);
    }
}

when code goes into this loop, there're 3 halfedges around the source, which has id_x as 148874, 151104 and 151099 respectively, However, the code keeps iterating through the 3 halfedges and does not jump out of the loop. Is it because flip_edge somehow changed the iterator range?

May I know what shoud I do so that the code can jump out of the loop after the 3 halfedges are all iterated?

Source Code

If your issue arises by using CGAL in your own source code, please provide a minimalist example that we can compile easily to reproduce the bug. If your issue arises from using a CGAL program (demo, example, etc.), please let us know which one. Helping you solving an issue is much easier and efficient if we can reproduce it.

Environment

sloriot commented 1 month ago

You cannot modify the mesh while iterating around vertices. As already said in another context, you need to collect and then modify.