]> Creatis software - FrontAlgorithms.git/blob - plugins/DijkstraFunctors/InvertCost.cxx
f5a13382dade691dce0db5d913789d1800dc4563
[FrontAlgorithms.git] / plugins / DijkstraFunctors / InvertCost.cxx
1 #include <DijkstraFunctors/InvertCost.h>
2 #include <cpInstances/DataObjects/Image.h>
3
4 #include <fpa/Base/Functors/Inverse.h>
5
6 // -------------------------------------------------------------------------
7 fpaPluginsDijkstraFunctors::InvertCost::
8 InvertCost( )
9   : Superclass( )
10 {
11   typedef cpPlugins::Pipeline::DataObject _TData;
12   this->_ConfigureOutput< _TData >( "Output" );
13
14   std::vector< std::string > choices;
15   choices.push_back( "float" );
16   choices.push_back( "double" );
17   this->m_Parameters.ConfigureAsChoices( "ResultType", choices );
18   this->m_Parameters.ConfigureAsReal( "NegativeValue", -1 );
19   this->m_Parameters.SetSelectedChoice( "ResultType", "float" );
20 }
21
22 // -------------------------------------------------------------------------
23 fpaPluginsDijkstraFunctors::InvertCost::
24 ~InvertCost( )
25 {
26 }
27
28 // -------------------------------------------------------------------------
29 void fpaPluginsDijkstraFunctors::InvertCost::
30 _GenerateData( )
31 {
32   auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
33   if     ( rtype == "float"  ) this->_GD0< float >( );
34   else if( rtype == "double" ) this->_GD0< double >( );
35 }
36
37 // -------------------------------------------------------------------------
38 template< class _TOutput >
39 void fpaPluginsDijkstraFunctors::InvertCost::
40 _GD0( )
41 {
42   typedef fpa::Base::Functors::Inverse< _TOutput, _TOutput > _TFunctor;
43
44   auto out = this->GetOutput( "Output" );
45   auto f = out->GetITK< _TFunctor >( );
46   if( f == NULL )
47   {
48     typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
49     f = ptr_f.GetPointer( );
50     out->SetITK( f );
51
52   } // fi
53   f->SetNegativeValue( this->m_Parameters.GetReal( "NegativeValue" ) );
54 }
55
56 // eof - $RCSfile$