1 #include "VertexCost.h"
3 #include <cpInstances/DataObjects/Image.h>
6 #include <fpa/Image/Functors/VertexCost.h>
8 // -------------------------------------------------------------------------
9 void fpaPlugins_ImageFunctors::VertexCost::
10 Instantiate( itk::LightObject* filter )
12 auto itk_filter = dynamic_cast< itk::ProcessObject* >( filter );
13 if( itk_filter != NULL )
15 auto inputs = itk_filter->GetInputs( );
16 if( inputs.size( ) > 0 )
18 cpPlugins_Demangle_Image_ScalarPixels_AllDims_2(
19 inputs[ 0 ].GetPointer( ), _GD0, itk_filter
21 this->_Error( "Invalid input data." );
24 this->_Error( "Not enough inputs." );
27 this->_Error( "Invalid instantiation filter." );
30 // -------------------------------------------------------------------------
31 fpaPlugins_ImageFunctors::VertexCost::
35 this->_ConfigureOutput< cpPlugins::Pipeline::DataObject >( "Functor" );
36 this->m_Parameters.ConfigureAsBool( "UseImageSpacing", false );
37 this->GetOutput( "Functor" )->SetITK( this );
40 // -------------------------------------------------------------------------
41 fpaPlugins_ImageFunctors::VertexCost::
46 // -------------------------------------------------------------------------
47 void fpaPlugins_ImageFunctors::VertexCost::
52 // -------------------------------------------------------------------------
53 template< class _TInput >
54 void fpaPlugins_ImageFunctors::VertexCost::
55 _GD0( _TInput* input, itk::ProcessObject* filter )
57 auto outputs = filter->GetOutputs( );
58 if( outputs.size( ) > 0 )
60 cpPlugins_Demangle_Image_ScalarPixels_3(
61 outputs[ 0 ].GetPointer( ), _GD1, _TInput::ImageDimension, input, filter
63 this->_Error( "Invalid output data." );
66 this->_Error( "Not enough outputs." );
69 // -------------------------------------------------------------------------
70 template< class _TInput, class _TOutput >
71 void fpaPlugins_ImageFunctors::VertexCost::
72 _GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter )
74 typedef typename _TInput::PixelType _TIValue;
75 typedef typename _TOutput::PixelType _TOValue;
76 typedef fpa::Image::Functors::VertexCost< _TInput, _TOValue > _TFunctor;
78 auto f = dynamic_cast< _TFunctor* >( this->m_Functor.GetPointer( ) );
81 typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
82 f = ptr_f.GetPointer( );
86 f->SetUseImageSpacing( this->m_Parameters.GetReal( "UseImageSpacing" ) );