]> Creatis software - FrontAlgorithms.git/blob - plugins/Plugins/GaussianCostFunctor.cxx
Architecture revisited.
[FrontAlgorithms.git] / plugins / Plugins / GaussianCostFunctor.cxx
1 #include "GaussianCostFunctor.h"
2
3 #include <fpa/Base/Functors/GaussianCost.h>
4 #include <fpa/Base/Functors/GaussianCost.hxx>
5
6 // -------------------------------------------------------------------------
7 fpaPlugins::GaussianCostFunctor::
8 GaussianCostFunctor( )
9   : Superclass( )
10 {
11   this->_ConfigureOutput< cpPlugins::BaseObjects::DataObject >( "Output" );
12   this->_ConfigureOutput< cpPlugins::BaseObjects::DataObject >( "Estimator" );
13   std::vector< std::string > choices;
14   choices.push_back( "float" );
15   choices.push_back( "double" );
16   this->m_Parameters.ConfigureAsChoices( "ResultType", choices );
17   this->m_Parameters.SetSelectedChoice( "ResultType", "float" );
18   this->m_Parameters.ConfigureAsUint( "SupportSize" );
19   this->m_Parameters.ConfigureAsReal( "MinimumCost" );
20   this->m_Parameters.SetUint( "SupportSize", 30 );
21   this->m_Parameters.SetReal( "MinimumCost", 1e-5 );
22 }
23
24 // -------------------------------------------------------------------------
25 fpaPlugins::GaussianCostFunctor::
26 ~GaussianCostFunctor( )
27 {
28 }
29
30 // -------------------------------------------------------------------------
31 void fpaPlugins::GaussianCostFunctor::
32 _GenerateData( )
33 {
34   auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
35   if     ( rtype == "float"  ) this->_GD0< float >( );
36   else if( rtype == "double" ) this->_GD0< double >( );
37 }
38
39 // -------------------------------------------------------------------------
40 template< class _TResult >
41 void fpaPlugins::GaussianCostFunctor::
42 _GD0( )
43 {
44   typedef fpa::Base::Functors::GaussianCost< _TResult > _TFunctor;
45   auto out = this->GetOutput( "Output" );
46   auto f = out->GetITK< _TFunctor >( );
47   if( f == NULL )
48   {
49     typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
50     f = ptr_f.GetPointer( );
51     out->SetITK( f );
52
53   } // fi
54   f->SetSupportSize( this->m_Parameters.GetUint( "SupportSize" ) );
55   f->SetMinimumCost( this->m_Parameters.GetReal( "MinimumCost" ) );
56   this->GetOutput( "Estimator" )->SetITK( f->GetModel( ) );
57 }
58
59 // eof - $RCSfile$