[Insight-developers] iterators in a reverse direction?
Damion Shelton
dmsst59+@pitt.edu
Fri, 18 May 2001 12:18:20 -0400
Hi...
I played with ReflectiveImageRegionIterator and although it appears to be
working correctly, I don't know the behavior is exactly what I'm looking for
though. In the case of a 2D image, ReflectiveImageRegionIterator seems to
proceed by:
walk x forwards and back, next y, walk x forwards and back, next y, etc.
while what I'm looking for is:
walk x forwards, next y, walk x forwards, next y, walk x back, previous y,
etc.
I would volunteer to implement this but I'm not comfortable playing in the
guts of iterators just yet. I like the idea of an iterator that iterates
both forwards and back in a manner transparent to the user, though. I don't
know whether this should be a separate implementation or a modification of
the existing ImageRegionIterator (i.e. support the -- operator).
-Damion-
----- Original Message -----
From: "Luis Ibanez" <ibanez@choroid.cs.unc.edu>
Subject: Re: [Insight-developers] iterators in a reverse direction?
> ITK don't have reverse iterators yet,
> but nothing prevent them from being implemented.
> It is just a matter of volonteers :-)
>
> We implemented a ReflectiveIterator for being
> used in the Danielsson distance algorithm.
> It is in Code/BasicFilters.
>
> This iterator walks line by line, first forward
> and then backwards. The fact is that if you
> take its operator++ method, the code on the option
>
> if( ! firstpass )
>
> is what has to be written in the normal operator++
> of a reverse iterator.
>
> another option, as you suggest, is to add a operator--,
> which could be more intuitive. We are not passing
> iterators around, so the common API of ++ used in STL
> is less necessary.
>
> ---
>
> A word of caution. The notion of Begin() and End()
> is a bit ambiguous in reverse iterators... STL
> uses rbegin() and rend() to clarify, maybe we should
> follow that.
>
>
> Luis
>
>
> On Wed, 16 May 2001, Damion Shelton wrote:
>
> > Hi...
> >
> > Is there an easy way to iterate through an image in the "reverse" of the
> > normal direction? The code fragment:
> >
> > for ( outIt.Begin(); !outIt.IsAtEnd(); ++outIt)
> >
> > iterates forwards. Prior to looking at the documentation, I assumed that
the
> > line:
> >
> > for ( outIt.End(); !outIt.IsAtBegin(); --outIt)
> >
> > would also be legal; the "--" operator is not defined, though. So, how
do I
> > go about iterating backwards.
> >
> > Thanks,
> >
> > -Damion-
> >
> >
> > _______________________________________________
> > Insight-developers mailing list
> > Insight-developers@public.kitware.com
> > http://public.kitware.com/mailman/listinfo/insight-developers
> >
>
> --
> Luis Ibanez CB#: 7060
> Research Assistan Professor phone: (919) 843 6941
> Division of Neurosurgery fax: (919) 966 6627
> University of North Carolina at Chapel Hill email: ibanez@cs.unc.edu
> Chapel Hill, NC 27599-7060
http://www.cs.unc.edu/~ibanez
>
>
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers
>