[Insight-developers] iterator troubles

Miller, James V (CRD) millerjv@crd.ge.com
Thu, 19 Jul 2001 17:31:06 -0400


Ahh,

You have hit upon a problem supporting the DataAccessors/ImageAdaptors.

ImageRegionIterator::Get() returned a reference to a pixel last week.  But merging the API's of the
ImageIterators, I realized that Get() needs to return by value.  This is needed to properly support
the ImageAdaptors since an Adaptor cannot return by reference.

What you can do is bypass the Get()/Set() methods and used the ImageIterator::Value() methods which
bypass any adaptor applied to an image. The result of the Value() method can be used as an lvalue or
rvalue.

Jim


-----Original Message-----
From: Damion Shelton [mailto:dmsst59+@pitt.edu]
Sent: Thursday, July 19, 2001 4:57 PM
To: 'insight-Developers'
Subject: [Insight-developers] iterator troubles


Hi...

I've been following the iterator discussion and updated my code to account
for the GoToBegin() syntax change. Unfortunately, I've hit a snag relating
to the Get() function of ImageRegionIterator.

In the following examples, note that bpiterator is a blox pixel iterator
(just your basic stl list iterator) of type itk::BloxPixel::iterator. Also,
bloxIt is an ImageRegionIterator which walks an itk::BoundaryPointImage
(inherited from Image).

The following code fragment compiles and executes correctly.

for (bpiterator = bloxIt.Value().begin(); bpiterator !=
bloxIt.Value().end(); ++bpiterator)
{
...use bpiterator
}

As does (bloxindex obtained from bloxIt.GetIndex() ):

for (bpiterator = bloxBoundaryPointImage->GetPixel(bloxindex).begin();
      bpiterator != bloxBoundaryPointImage->GetPixel(bloxindex).end();
      ++bpiterator)
{
...use bpiterator
}

However, the following code block DOES NOT work, and did last week:

for (bpiterator = bloxIt.Get().begin(); bpiterator != bloxIt.Get().end();
++bpiterator)
{
...use bpiterator
}

Any ideas? What differs between, Value(), Get(), and manually accessing the
pixel via the index? This should hopefully clear up the remaining bug in the
example that illustrates how to use spatial functions, bloxels and blolumes,
etc.

Thanks in advance,

-Damion-


_______________________________________________
Insight-developers mailing list
Insight-developers@public.kitware.com
http://public.kitware.com/mailman/listinfo/insight-developers