← Back to team overview

dolfin team mailing list archive

Re: Mesh iterators

 



Anders Logg wrote:
On Tue, Feb 10, 2009 at 09:52:20AM +0000, Garth N. Wells wrote:
I know that we discussed const and mesh iterators a while ago, but can someone remind me why I can't do

   void myfunction(const Cell& cell) const
   {
       for (VertexIterator vertex(cell); !vert.end(); ++vert)
       {
	 . . . .
       }
   }

but have to do

   void myfunction(const Cell& cell) const
   {
for (VertexIterator vertex(const_cast<Cell&>(cell)); !vert.end();
            ++vert)
       {
	 . . . .
       }
   }

instead?

You shouldn't have to. The class VertexIterator takes a const Cell
argument:

  VertexIterator(const MeshEntity& entity) : MeshEntityIterator(entity, 0) {}

This is at the bottom of Vertex.h.

Push it to sandbox/misc and I'll look at it.


Oops, I was compiling against an old version of DOLFIN in which the iterators are not const.

Garth




------------------------------------------------------------------------

_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev


References