Subject: CGAL users discussion list
List archive
- From: Efraim Fogel <>
- To:
- Cc: Ron Wein <>
- Subject: Re: [cgal-discuss] 2D Arrangements
- Date: Thu, 23 Aug 2007 10:42:51 +0300
Here are the answers to your questions assembled by Ron:
In general, as long as you do not remove things, your iterators stay valid. Removing an edge will of course invalidate the iterators/handles to the two deleted halfedges, but it can also
happen that this causes two faces to merge, and in such a case also some face handle is invalidated.
Regarding the specific program, there is a problem with it, as the loop goes over the halfedges. When you delete a halfedge, you also deleted its twin, which is in general the next halfedge in the container, so you get an invalid iterator. The solution is easy: Use an edge iterator instead.
Arrangement arr;
Arrangement::Edge_iterator iter = arr.edges_begin();
while (iter != arr.edges_end())
{
if (SomeCondition(*iter))
{
Arrangement::Edge_iterator t = iter;
iter++;
arr.remove_edge(t);
}
else
iter++;
}
One face is deleted in case of a merge. If the arrangement faces are extended with external data, you can use an observer to keep track of the changes the arrangement undergoes and maintain the external data accordingly (implement before/after_merge_face() in this case). There is an example in the manual showing how to use an observer for this purpose.
wrote:
Hi--
Can I modify a 2D arrangement while traversing it?
For example:
Arrangement arr;
Arrangement::Halfedge_iterator iter = arr.halfedges_begin();
while (iter != arr.halfedges_end())
{
if (SomeCondition(*iter))
{
Arrangement::Halfedge_iterator t = iter;
iter++;
arr.remove_edge(t);
}
else
iter++;
}
If I do this, can I be sure that I'll iterate over each edge exactly once
unless it's deleted?
And btw, if two faces are merged, what happens to their data?
Thanks
____ _ ____ _
/_____/_) o /__________ __ //
(____ ( ( ( (_/ (_/-(-'_(/
_/
- 2D Arrangements, lev, 08/19/2007
- Re: [cgal-discuss] 2D Arrangements, Efraim Fogel, 08/23/2007
- RE: [cgal-discuss] 2D Arrangements, Lev Borovoi, 08/23/2007
- Re: [cgal-discuss] 2D Arrangements, Efi Fogel, 08/26/2007
- RE: [cgal-discuss] 2D Arrangements, Lev Borovoi, 08/23/2007
- Re: [cgal-discuss] 2D Arrangements, Efraim Fogel, 08/23/2007
Archive powered by MHonArc 2.6.16.