#include "InvertCostFunction.h" #include #include // ------------------------------------------------------------------------- fpaPlugins::InvertCostFunction:: InvertCostFunction( ) : Superclass( ) { this->_AddOutput< cpPlugins::DataObject >( "Output" ); this->m_Parameters.ConfigureAsReal( "Alpha" ); this->m_Parameters.ConfigureAsReal( "Beta" ); std::vector< std::string > choices; choices.push_back( "float" ); choices.push_back( "double" ); this->m_Parameters.ConfigureAsChoices( "ScalarType", choices ); this->m_Parameters.SetReal( "Alpha", 1 ); this->m_Parameters.SetReal( "Beta", 1 ); this->m_Parameters.SetSelectedChoice( "ScalarType", "float" ); } // ------------------------------------------------------------------------- fpaPlugins::InvertCostFunction:: ~InvertCostFunction( ) { } // ------------------------------------------------------------------------- void fpaPlugins::InvertCostFunction:: _GenerateData( ) { auto choice = this->m_Parameters.GetSelectedChoice( "ScalarType" ); if ( choice == "float" ) this->_GD0< float >( ); else if( choice == "double" ) this->_GD0< double >( ); else this->_Error( "Invalid scalar type." ); } // ------------------------------------------------------------------------- template< class _TScalar > void fpaPlugins::InvertCostFunction:: _GD0( ) { typedef fpa::Base::Functors::InvertCostFunction< _TScalar > _TFunctor; auto out = this->GetOutput( "Output" ); auto f = out->GetITK< _TFunctor >( ); if( f == NULL ) { typename _TFunctor::Pointer ptr_f = _TFunctor::New( ); f = ptr_f.GetPointer( ); out->SetITK( f ); } // fi f->SetAlpha( this->m_Parameters.GetReal( "Alpha" ) ); f->SetBeta( this->m_Parameters.GetReal( "Beta" ) ); } // eof - $RCSfile$