I have a CGAL::Polygon_2<Kernel>
and iterate over its vertices with CGAL vertex circulator
. In the CGAL documentation, I cannot find any information about how to use the erase function correctly. Deleting in the middle isn't a problem, but how to handle the circulator, when the first element of it is deleted?
The naive iterator erasing approach works only in the first case, in the second case, the loop finished after one iteration.
// p is of type CGAL::Polygon_2<Kernel>
auto ci = p.vertices_circulator();
auto start = ci;
int i = 0;
do {
if (i == 0) {
ci = p.erase(ci);
} else {
++ci;
}
++i;
} while (ci != start);
This means start
points to the formerly second element/now first element after erasing the first one?
How can I handle that case? Thanks!
Aucun commentaire:
Enregistrer un commentaire