1 #include "InvertCostFunction.h"
3 #include <cpPlugins/Image.h>
4 #include <fpa/Base/Functors/InvertCostFunction.h>
6 // -------------------------------------------------------------------------
7 fpaPlugins::InvertCostFunction::
11 this->_AddOutput< cpPlugins::DataObject >( "Output" );
13 this->m_Parameters.ConfigureAsReal( "Alpha" );
14 this->m_Parameters.ConfigureAsReal( "Beta" );
16 std::vector< std::string > choices;
17 choices.push_back( "float" );
18 choices.push_back( "double" );
19 this->m_Parameters.ConfigureAsChoices( "ScalarType", choices );
21 this->m_Parameters.SetReal( "Alpha", 1 );
22 this->m_Parameters.SetReal( "Beta", 1 );
23 this->m_Parameters.SetSelectedChoice( "ScalarType", "float" );
26 // -------------------------------------------------------------------------
27 fpaPlugins::InvertCostFunction::
28 ~InvertCostFunction( )
32 // -------------------------------------------------------------------------
33 void fpaPlugins::InvertCostFunction::
36 auto choice = this->m_Parameters.GetSelectedChoice( "ScalarType" );
37 if ( choice == "float" ) this->_GD0< float >( );
38 else if( choice == "double" ) this->_GD0< double >( );
39 else this->_Error( "Invalid scalar type." );
42 // -------------------------------------------------------------------------
43 template< class _TScalar >
44 void fpaPlugins::InvertCostFunction::
47 typedef fpa::Base::Functors::InvertCostFunction< _TScalar > _TFunctor;
48 auto out = this->GetOutput( "Output" );
49 auto f = out->GetITK< _TFunctor >( );
52 typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
53 f = ptr_f.GetPointer( );
57 f->SetAlpha( this->m_Parameters.GetReal( "Alpha" ) );
58 f->SetBeta( this->m_Parameters.GetReal( "Beta" ) );