Subject: CGAL users discussion list
List archive
- From: Sylvain Pion <>
- To:
- Subject: Re: [cgal-discuss] Cell_handle iterators
- Date: Thu, 10 Dec 2009 00:30:20 +0100
Panagiotis Foteinos a écrit :
Taking the low level details out, the following code is compiled
successfully, but throws a segmentation fault (see the dashed arrow below):
*********************************************************************************************************************************************************************
typedef CGAL::Triangulation_hierarchy_3<Dt> Dh;
typedef Dh::Finite_cells_iterator Finite_cells_iterator;
std::list<Cell_handle*> red_elements;
main()
{
Dh T;
//Insert some vertices into T.
for(Finite_cells_iterator c = T.finite_cells_begin(); i !=
T.finite_cells_end(); i++)
if(c->info().color == red)
{
Cell_handle* cell_handle_pointer = new Cell_handle();
*cell_handle_pointer = c;
red_elements.push_back(cell_handle_pointer);
}
//Do stuff with T by removing, inserting, changing the color of some
elements...
//red_elements list is not touched, however.
for(std::list<Cell_handle*>::iterator i = red_elements.begin(); i !=
red_elements.end(); i++)
{
Cell_handle c = **i;
if(T.is_cell(c) == false || c->info().color != red)
red_elements.erase(i); ---------------------------------> segmentation fault the first time
this line is executed.
}
}
Did you try the debug mode of your STL (e.g. -D_GLIBCXX_DEBUG for GCC) ?
You are erasing a list element, and then doing ++ on the iterator
formerly pointing to it => Boom. A classical problem, not CGAL related.
--
Sylvain Pion
INRIA Sophia-Antipolis
Geometrica Project-Team
CGAL, http://cgal.org/
- [cgal-discuss] Cell_handle iterators, Panagiotis Foteinos, 12/09/2009
- Re: [cgal-discuss] Cell_handle iterators, Sylvain Pion, 12/09/2009
- Re: [cgal-discuss] Cell_handle iterators, Panagiotis Foteinos, 12/10/2009
- Re: [cgal-discuss] Cell_handle iterators, Sylvain Pion, 12/10/2009
- Re: [cgal-discuss] Cell_handle iterators, Panagiotis Foteinos, 12/10/2009
- Re: [cgal-discuss] Cell_handle iterators, Sylvain Pion, 12/09/2009
Archive powered by MHonArc 2.6.16.