Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
citystrawman opened this issue Sep 3, 2024 · 1 comment

Comments

@citystrawman
Copy link

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

  • Operating system (Windows/Mac/Linux, 32/64 bits):
  • Compiler:
  • Release or debug mode:
  • Specific flags used (if any):
  • CGAL version:
  • Boost version:
  • Other libraries versions if used (Eigen, TBB, etc.):
@sloriot
Copy link
Member

sloriot commented Sep 3, 2024

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

@sloriot sloriot closed this as completed Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants