]> Creatis software - FrontAlgorithms.git/blob - plugins/fpa/InvertCostFunction.cxx
...
[FrontAlgorithms.git] / plugins / fpa / InvertCostFunction.cxx
1 #include "InvertCostFunction.h"
2
3 #include <cpPlugins/Image.h>
4 #include <fpa/Base/Functors/InvertCostFunction.h>
5
6 // -------------------------------------------------------------------------
7 fpaPlugins::InvertCostFunction::
8 InvertCostFunction( )
9   : Superclass( )
10 {
11   this->_AddOutput< cpPlugins::DataObject >( "Output" );
12
13   this->m_Parameters.ConfigureAsReal( "Alpha" );
14   this->m_Parameters.ConfigureAsReal( "Beta" );
15
16   std::vector< std::string > choices;
17   choices.push_back( "float" );
18   choices.push_back( "double" );
19   this->m_Parameters.ConfigureAsChoices( "ScalarType", choices );
20
21   this->m_Parameters.SetReal( "Alpha", 1 );
22   this->m_Parameters.SetReal( "Beta", 1 );
23   this->m_Parameters.SetSelectedChoice( "ScalarType", "float" );
24 }
25
26 // -------------------------------------------------------------------------
27 fpaPlugins::InvertCostFunction::
28 ~InvertCostFunction( )
29 {
30 }
31
32 // -------------------------------------------------------------------------
33 std::string fpaPlugins::InvertCostFunction::
34 _GenerateData( )
35 {
36   auto choice = this->m_Parameters.GetSelectedChoice( "ScalarType" );
37   if     ( choice == "float" )  return( this->_GD0< float >( ) );
38   else if( choice == "double" ) return( this->_GD0< double >( ) );
39   else
40     return( "fpaPlugins::InvertCostFunction: invalid scalar type." );
41 }
42
43 // -------------------------------------------------------------------------
44 template< class _TScalar >
45 std::string fpaPlugins::InvertCostFunction::
46 _GD0( )
47 {
48   typedef fpa::Base::Functors::InvertCostFunction< _TScalar > _TFunctor;
49   auto out = this->GetOutputData( "Output" );
50   auto f = out->GetITK< _TFunctor >( );
51   if( f == NULL )
52   {
53     typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
54     f = ptr_f.GetPointer( );
55     out->SetITK( f );
56
57   } // fi
58   f->SetAlpha( this->m_Parameters.GetReal( "Alpha" ) );
59   f->SetBeta( this->m_Parameters.GetReal( "Beta" ) );
60   return( "" );
61 }
62
63 // eof - $RCSfile$