[Insight-developers] ImageRandomNonRepeatingConstIteratorWithIndex segfault

David Doria daviddoria at gmail.com
Mon Feb 28 20:51:26 EST 2011


On Mon, Feb 28, 2011 at 7:04 PM, Luis Ibanez <luis.ibanez at kitware.com>wrote:

> 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
>

The reason I used that notation was that I have the iterator as a member of
a class, and I don't have the image I want to iterate over inside the class
until later. So in my SetImage() function I set the image as well as
initialize the iterator. You make a good point about it not really being an
operator= function - if you can clarify how to deep copy the m_Permutation
(I replied on Gerrit in more detail) I'll fix it.

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20110228/724c863a/attachment.htm>


More information about the Insight-developers mailing list