[Insight-users] Problems using image smart pointer

Luis Ibanez luis.ibanez at kitware.com
Wed Apr 11 12:31:26 EDT 2007


Hi IsabelleNg,

Could you please post the *full* error message that you got ?

The error that you posted is usually followed by a specification
of what the template parameters are, in particular it should
specify what "TPixel" and "VImageDimension" are.


Also,


1) Do you have a typedef for ImageType in your derived class ?
   if so, could you please post it too.

2) Please verify that you have not overloaded the method
    GetImage() in your derived class.

3) Maybe you should post to the list the code of the
    derived class.... that will make things easier.


Note that itkGetConstObjectMacro() *DOES NOT* return a SmartPointer.

Instead, it returns a const raw pointer to the object.

You may want to look at the definition of this macro in:

    Insight/Code/Common/itkMacro.h

lines : 345 - 350.

The code already invokes internally GetPointer()
on the smart pointer object.


    Regards,


       Luis


-------------------
IsabelleNg wrote:
> 
> IsabelleNg wrote:
> 
>>Hi everyone, 
>>
>>I have having problems with the following code: 
>>
>>typedef itk::ImageFileWriter< ImageType > WriterType; 
>>WriterType::Pointer writer = WriterType::New(); 
>>writer->SetFileName("test.mhd"); 
>>writer->SetInput( this->GetImage()->GetPointer()); 
>>
>>This code is inside a function of a derived class.  GetImage() should
>>return a smartpointer obj returned by its supercass, using the macro: 
>>
>>itkGetConstObjectMacro( Image, ImageType ); 
>>
>>And m_Image is defined in this superclass as: 
>>
>>typedef SmartPointer< ImageType >     ImagePointer; 
>>ImagePointer m_Image; 
>>
>>
>>The error that I got is 
>>        
>>error C2664: 'itk::ImageFileWriter<TInputImage>::SetInput' : cannot
>>convert parameter 1 from 'const itk::Image<TPixel,VImageDimension> *' to
>>'const itk::Image<TPixel,VImageDimension> *' 
>>
>>
>>Thanks for any of your help, 
>>Isabelle
>>
> 
> 
> Hi,
> 
> Neither of the following worked...
> 
> writer->SetInput( this->GetImage()->GetPointer()); 
> // writer->SetInput( this->GetImage().GetPointer() );   <-- doesn't work
> either
> 
> For the latter, I would get the following:
> error C2228: left of '.GetPointer' must have class/struct/union
> 
> 
> David Cole wrote:
> 
>>On 4/10/07, IsabelleNg <isabelleNg at homeworking.org> wrote:
>>
>>>writer->SetInput( this->GetImage()->GetPointer());
>>
>>Try
>>" ...... GetImage().GetPointer() ......... "
>>
>>"." instead of "->" on the smart pointer object...
>>
>>HTH,
>>David
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org
>>http://www.itk.org/mailman/listinfo/insight-users
>>
>>
> 
> 
> 
> 


More information about the Insight-users mailing list