]> Creatis software - FrontAlgorithms.git/blob - plugins/Plugins/SimpleImageDijkstraCost.cxx
...
[FrontAlgorithms.git] / plugins / Plugins / SimpleImageDijkstraCost.cxx
1 #include <plugins/Plugins/SimpleImageDijkstraCost.h>
2 #include <cpPlugins/DataObjects/Image.h>
3
4 #include <fpa/Image/Functors/SimpleDijkstraCost.h>
5 #include <fpa/Image/Functors/SimpleDijkstraCost.hxx>
6
7 // -------------------------------------------------------------------------
8 fpaPlugins::SimpleImageDijkstraCost::
9 SimpleImageDijkstraCost( )
10   : Superclass( )
11 {
12   typedef cpPlugins::BaseObjects::DataObject _TData;
13   typedef cpPlugins::DataObjects::Image _TImage;
14
15   this->_ConfigureInput< _TImage >( "Input", true, false );
16   this->_ConfigureOutput< _TData >( "Output" );
17
18   std::vector< std::string > choices;
19   choices.push_back( "float" );
20   choices.push_back( "double" );
21   this->m_Parameters.ConfigureAsChoices( "ResultType", choices );
22   this->m_Parameters.ConfigureAsBool( "UseImageSpacing" );
23
24   this->m_Parameters.SetSelectedChoice( "ResultType", "float" );
25   this->m_Parameters.SetBool( "UseImageSpacing", false );
26 }
27
28 // -------------------------------------------------------------------------
29 fpaPlugins::SimpleImageDijkstraCost::
30 ~SimpleImageDijkstraCost( )
31 {
32 }
33
34 // -------------------------------------------------------------------------
35 void fpaPlugins::SimpleImageDijkstraCost::
36 _GenerateData( )
37 {
38   auto o = this->GetInputData( "Input" );
39   cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 );
40   else this->_Error( "Invalid input image." );
41 }
42
43 // -------------------------------------------------------------------------
44 template< class _TImage >
45 void fpaPlugins::SimpleImageDijkstraCost::
46 _GD0( _TImage* image )
47 {
48   auto rtype = this->m_Parameters.GetSelectedChoice( "ResultType" );
49   if     ( rtype == "float"  ) this->_GD1< _TImage, float >( image );
50   else if( rtype == "double" ) this->_GD1< _TImage, double >( image );
51 }
52
53 // -------------------------------------------------------------------------
54 template< class _TImage, class _TOutput >
55 void fpaPlugins::SimpleImageDijkstraCost::
56 _GD1( _TImage* image )
57 {
58   typedef
59     fpa::Image::Functors::SimpleDijkstraCost< _TImage, _TOutput >
60     _TFunctor;
61   auto out = this->GetOutput( "Output" );
62   auto f = out->GetITK< _TFunctor >( );
63   if( f == NULL )
64   {
65     typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
66     f = ptr_f.GetPointer( );
67     out->SetITK( f );
68
69   } // fi
70   f->SetUseImageSpacing( this->m_Parameters.GetBool( "UseImageSpacing" ) );
71 }
72
73 // eof - $RCSfile$