[ITK Community] [Insight-developpers] filter update causes libc++abi error

Matt McCormick matt.mccormick at kitware.com
Mon Feb 17 18:10:25 EST 2014


Hi Thibault,


On Mon, Feb 17, 2014 at 5:40 PM, Thibault Lucidarme
<thibault.lucidarme at gmail.com> wrote:
> Dear Matt,
> I have successfully tried your answer to my registration problem (using
> SetNumberOfRequiredInputs and this->SetInput( 0, fixedImage )  )

Great!

> However this->GetInput() returns a casual pointer instead of a SmartPointer.
> In order to be consistent with the rest of my filters (and the rest of my
> program), I have had to cast it like this:
>
> ImageType::Pointer fixedImage = const_cast<ImageType*>( this->GetInput(0) );

Note that ImageType::ConstPointer can be used here.  Keeping
const-correctness helps to prevent bugs. Even better const ImageType *
can be used since we know that the input is not going to disappear
while the filter is processing, and an extra acquisition of the
reference count is not required.

>
> as per mentioned here:
> http://www.itk.org/pipermail/insight-users/2008-February/024988.html
> Yet, when later on in the code I use
>
> registrator->SetFixedImageRegion( fixedImage->GetLargestPossibleRegion() );
>
> the program ends with a segfault. Somehow the casting does not work and
> returns NULL.
> Do you have any ideas why that is?

Without buildable code it is difficult to tell.  Maybe it is never getting set?

Thanks,
Matt



More information about the Community mailing list