[Insight-developers] Smart Pointer (continue)
Yinpeng Jin
yj76@columbia.edu
Thu, 25 Apr 2002 11:38:17 -0400
Luis:
that was my first thought, too, I tried
const InputImageType*
and InputImageConstPointer input
both give me similar error.
I think the reason is that
this->GetInput() returns a InputImageConstPointer (from ImageToImageFilter)
but the iterator need a "TImage *" as the first par.
maybe something needs to change in ImageToImageFilter or
ImageRegionIteratorWithIndex
I am not sure if my understanding is correct.
But if we don't want to change ImageToImageFilter or
ImageRegionIteratorWithIndex,
is there anything I can do? static cast?
yinpeng.
----- Original Message -----
From: "Luis Ibanez" <luis.ibanez@kitware.com>
To: "Yinpeng Jin" <yj76@columbia.edu>
Cc: <Insight-developers@public.kitware.com>
Sent: Thursday, April 25, 2002 11:27 AM
Subject: Re: [Insight-developers] Smart Pointer (continue)
>
>
> Hi Yinpeng
>
> The input to the filters should be
> of type:
>
> const ImageType *
>
> So the signature of your SetInput()
> function should be:
>
> void SetInput( const ImageType * )
>
> The reason for the "const" is that a
> filter should not modify its input.
>
> The two main reasons for using a
> raw pointer instead of the smart
> pointer are:
>
> 1) It allows polymorphism, so you can
> pass an image that derives from ImageType
> and that will be accepted. (SmartPointers
> don't allow polymorphism directly)
>
> 2) Passing a SmartPointer will produce
> an extra construction of the smartpointer
> which implies a Mutex on the way. It is
> not a big performance concern since SetInput()
> should be called initially while the pipeline
> is set up but nevertheless is an unecessary
> operation.
>
>
>
> So, the SetInput() method should look like:
>
>
> void SetInput( const InputImageType * input)
> {
> Superclass::SetInput(input);
>
> // Note that the "Const" iterator must be used here
> itk::ImageRegionConstIteratorWithIndex <InputImageType>
> iit(this->GetInput(),region);
> ....
> }
>
>
> Please let us know if that helps.
>
>
> Thanks
>
> Luis
>
>
>
> ==================================================
>
> Yinpeng Jin wrote:
> > I think I should also give the "background":
> > I overwrited the SetInput()
> >
> >
> > SetInput(InputImagePointer input)
> > {
> > Superclass::SetInput(input);
> > .......
> > itk::ImageRegionIteratorWithIndex <InputImageType>
iit(this->GetInput(),
> > region);
> > // compiler error here
> >
> > }
> >
> >
> > and typedefs in .h:
> > typedef TInputImage InputImageType;
> > typedef typename TInputImage::Pointer InputImagePointer;
> >
> >
> > here is the error message again:
> > error C2664: '__thiscall itk::ImageRegionIteratorWithIndex<class
> > itk::Image<class itk::Vector<unsigned char,3>,2>
> >
> >>::itk::ImageRegionIteratorWithIndex<class itk::Image<cl
> >>
> > ass itk::Vector<unsigned char,3>,2> >(class itk::Image<class
> > itk::Vector<unsigned char,3>,2> *,const class itk::ImageRegion<2> &)' :
> > cannot convert parameter 1 from 'class itk::SmartPointer<class
> > itk::Image<class itk::Vector<unsigned char,3>,2> cons
> > t >' to 'class itk::Image<class itk::Vector<unsigned char,3>,2> *'
> > No user-defined-conversion operator available that can perform
this
> > conversion, or the operator cannot be called
> > C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xtree(552)
:
> > while compiling class-template member function 'void __thiscall
> > itk::VoronoiSegmentationRGBImageFilter<class itk::Image<class
> > itk::Vector<unsigned char,3>,2>,class itk::Image
> > <bool,2> >::SetInput(class itk::SmartPointer<class itk::Image<class
> > itk::Vector<unsigned char,3>,2> >)'
> >
> > so, how to fix it?
> >
> > thanks.
> >
> > Yinpeng.
> >
> >
> > _______________________________________________
> > Insight-developers mailing list
> > Insight-developers@public.kitware.com
> > http://public.kitware.com/mailman/listinfo/insight-developers
> >
> >
>
>
>
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers