[Insight-users] (problem solved) Re: Problems using image smart pointer

IsabelleNg isabelleNg at homeworking.org
Thu Apr 12 21:03:06 EDT 2007


Hi Luis,

Thank you very much for your pointers. I have solved the problem.

The problem stems from the typedefs; I redefined ImageType in the derived
class using the same typedefs in the superclass. I solved this by simply
defining ImageType in the derived class as 

Superclass::ImageType ImageType

Sorry for my seemingly silly mistakes :-( ; I'm new to template programming.

Thanks again,
Isabelle



Luis Ibanez wrote:
> 
> 
> 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
>>>
>>>
>> 
>> 
>> 
>> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 
> 
Quoted from: 
http://www.nabble.com/Problems-using-image-smart-pointer-tf3551006.html#a9943391

-- 
View this message in context: http://www.nabble.com/Problems-using-image-smart-pointer-tf3551006.html#a9971217
Sent from the ITK - Users mailing list archive at Nabble.com.



More information about the Insight-users mailing list