[Insight-developers] multiple output filters

Antonin Perrot-Audet antonin07130 at gmail.com
Thu Mar 31 12:12:48 EDT 2011


Hello,

I still have trouble understanding the function of
ProcessObject::MakeOutput
method.

I have a filter with multiple outputs, and I must admit that I have 
trouble understanding the principle of the example provided in
itkEigenAnalysis2DImageFilter
MakeOutput seems to *return a RAW pointer instead of a SMART POINTER* ?

template< class TInputImage, class TEigenValueImage, class 
TEigenVectorImage >
DataObject::Pointer
EigenAnalysis2DImageFilter< TInputImage, TEigenValueImage, 
TEigenVectorImage >
::MakeOutput(unsigned int idx)
{
   DataObject::Pointer output;

   switch ( idx )
     {
     case 0:
       output = ( EigenValueImageType::New() ).GetPointer();
       break;
     case 1:
       output = ( EigenValueImageType::New() ).GetPointer();
       break;
     case 2:
       output = ( EigenVectorImageType::New() ).GetPointer();
       break;
     }
   return output.GetPointer();
}

then , in the function, to get a pointer to those images, there is 
another function, with a dynamic cast... I must say that I don't really 
understand the principle.

template< class TInputImage, class TEigenValueImage, class 
TEigenVectorImage >
typename EigenAnalysis2DImageFilter< TInputImage, TEigenValueImage, 
TEigenVectorImage >::EigenValueImageType *
EigenAnalysis2DImageFilter< TInputImage, TEigenValueImage, 
TEigenVectorImage >
::GetMaxEigenValue(void)
{
   return dynamic_cast< EigenValueImageType * >(
            this->ProcessObject::GetOutput(0) );
}


Can anyone give me more insights ? I am trying to develop a filter with 
multiple outputs, and find it more challenging than I though...

-- 
Antonin



More information about the Insight-developers mailing list