X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=plugins%2FPlugins%2FInvertCost.cxx;fp=plugins%2FPlugins%2FInvertCost.cxx;h=fe77e0faa80d890e4ea3ee59031163eb07b38f00;hb=ea46079b5aef76c1782648ed23e70ea944649635;hp=0000000000000000000000000000000000000000;hpb=cabeca5a2968a2af677844c2ac40417638d6116b;p=FrontAlgorithms.git diff --git a/plugins/Plugins/InvertCost.cxx b/plugins/Plugins/InvertCost.cxx new file mode 100644 index 0000000..fe77e0f --- /dev/null +++ b/plugins/Plugins/InvertCost.cxx @@ -0,0 +1,55 @@ +#include +#include + +#include +#include + +// ------------------------------------------------------------------------- +fpaPlugins::InvertCost:: +InvertCost( ) + : Superclass( ) +{ + typedef cpPlugins::BaseObjects::DataObject _TData; + this->_ConfigureOutput< _TData >( "Output" ); + + std::vector< std::string > choices; + choices.push_back( "float" ); + choices.push_back( "double" ); + this->m_Parameters.ConfigureAsChoices( "ResultType", choices ); + this->m_Parameters.SetSelectedChoice( "ResultType", "float" ); +} + +// ------------------------------------------------------------------------- +fpaPlugins::InvertCost:: +~InvertCost( ) +{ +} + +// ------------------------------------------------------------------------- +void fpaPlugins::InvertCost:: +_GenerateData( ) +{ + auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" ); + if ( rtype == "float" ) this->_GD0< float >( ); + else if( rtype == "double" ) this->_GD0< double >( ); +} + +// ------------------------------------------------------------------------- +template< class _TOutput > +void fpaPlugins::InvertCost:: +_GD0( ) +{ + typedef fpa::Base::Functors::Inverse< _TOutput, _TOutput > _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 +} + +// eof - $RCSfile$