Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Cell_handle and cell_iterator

Subject: CGAL users discussion list

List archive

[cgal-discuss] Cell_handle and cell_iterator


Chronological Thread 
  • From: "cdoucet" <>
  • To:
  • Subject: [cgal-discuss] Cell_handle and cell_iterator
  • Date: Wed, 07 May 2014 13:11:44 +0200

Hello,

in a C++ code which uses CGAL, there is a loop like the following:

----------------------------------
for ( std::vector<Cell_handle>::iterator iter = cells.begin(); iter!
=cells.end(); ++iter)
(*iter)->info() +=2;
----------------------------------

I need to store more than one integer in iter.
Thus, I wrote a class MyCell_handle which is a Cell_handle (public
inheritance).
Then, I added a data member, say my_data, and wrote a accessor and a mutator
so that I can write:

----------------------------------
for ( std::vector<MyCell_handle>::iterator iter = cells.begin(); iter!
=cells.end(); ++iter)
{
(*iter)->info() +=2;
iter->my_data() += 2;
}
----------------------------------

However, I do not understand why I access to info with ->, i.e. (*iter)-
>info(), whereas I access to my_data with ., i.e. (*iter).my_data() or
equivalently iter->my_data().

Do you understand why?

After initializing info and my_data, there is a writing in a file with a loop
like this:

--------------------------------------------------------------------------------------------
Finite_cells_iterator iter;
for ( iter=mesh.finite_cells_begin() ; iter != mesh.finite_cells_end() ; +
+iter )
{
int info = iter->info();
file.write((char*)&info,sizeof(info));
}
--------------------------------------------------------------------------------------------

However, I do not see how to access to my_data because I do not see the
relationship between MyCell_handle and Finite_cells_iterator.
Is there a way to acces to my_data?

Thank you very much for your help.

Best regards,

Cédric Doucet
INRIA Paris-Rocquencourt



Archive powered by MHonArc 2.6.18.

Top of Page