[Insight-developers] ImageRandomNonRepeatingConstIteratorWithIndex segfault
Luis Ibanez
luis.ibanez at kitware.com
Mon Feb 28 19:04:42 EST 2011
Hi David,
I think the real problem is to attempt to use this notation:
(A) IteratorType it = IteratorType( image, region );
instead of using the simpler:
(B) IteratorType it( image, region );
In (B), we call a constructor,
in (A), you call the default constructor, then the constructor
with arguments, and then the assignment operator,
all to get the same variable that you can get with (B).
----
Unfortunately, there are examples in ITK that use
the unnecessarily convoluted notation of (A).
--
BTW
The operator= that you are implementing is deceitful
in the sense that it only works in a freshly created
iterator.
Luis
------------------------------------------------
On Sat, Feb 26, 2011 at 3:36 PM, David Doria <daviddoria at gmail.com> wrote:
> If I create this iterator with:
> itk::ImageRandomNonRepeatingConstIteratorWithIndex<ImageType>
> imageIterator(image, image->GetLargestPossibleRegion());
> everything works fine. However, if I do this:
> itk::ImageRandomNonRepeatingConstIteratorWithIndex<ImageType> imageIterator;
> imageIterator =
> itk::ImageRandomNonRepeatingConstIteratorWithIndex<ImageType>(image,
> image->GetLargestPossibleRegion());
> it segfaults on the GoToBegin() call.
> The crash is at this line of UpdatePosition():
> PositionValueType position = ( *( this->m_Permutation )
> )[m_NumberOfSamplesDone % m_NumberOfSamplesRequested];
> m_Permutation is valid (it was set when the (image, region) constructor was
> called), but m_Permutation->m_Permutation is NULL. It is valid when I create
> the iterator with the first version (above). The default constructor just
> sets everything to NULL, so I don't see any reason why calling the (image,
> region) constructor after the default constructor wouldn't work.
> Any thoughts?
> David
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
>
>
More information about the Insight-developers
mailing list