Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Cell_handle iterators

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Cell_handle iterators


Chronological Thread 
  • From: Panagiotis Foteinos <>
  • To:
  • Subject: Re: [cgal-discuss] Cell_handle iterators
  • Date: Wed, 09 Dec 2009 18:18:45 -0500
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=nHeEAK3udftQFc5460JwEes3H0NzMQ7ianajg7wu+Z7L/AIs5p3r0RwQHoi+Cl/lWY Ww6ukudBYkrWE+6JSjpT+9yTIa1IR5g3sPULiFjYV2ybVVcAWHq60E6UAH5zJwPA3CVk 6zxhkv7Z4yVpZf/B2D0dSWet7Qbg/VW+CcSBc=

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.
}

}
*********************************************************************************************************************************************************************

Let me know if the problem is still unclear.

Thanks,
Panagiotis


Sylvain Pion wrote:
> Panagiotis Foteinos a écrit :
>> Hello all.
>>
>> I have a list of Cell_handle pointers: std::list<Cell_handle*> my_list.
>> This list (i.e., my_list) contains pointers of specific Cell_handles.
>> For example, it may contain pointers that point to Cell_handles of color
>> red.
>>
>> After processing the ith element of my_list, I erase this element by
>> doing my_list.erase(i). Of course, the destructor of the ith pointer is
>> called, which is no-op, while the destructor of the pointed Cell_handle
>> is not.
>>
>> Unfortunately, I am not able to erase elements without a segmentation
>> fault and I do not understand why: the elements of my_list are pointers
>> to objects and not objects (Cell_handle is not exactly a pointer...).
>>
>>
>> How could I resolve this problem?
>
> I fear that there is not enough information in your mail to determine
> the cause of your problem.
>




Archive powered by MHonArc 2.6.16.

Top of Page