]> Creatis software - FrontAlgorithms.git/blob - plugins/ImageFunctors/Tautology.cxx
6763602f3caab300164f419f8cacb5218f3d88be
[FrontAlgorithms.git] / plugins / ImageFunctors / Tautology.cxx
1 #include "Tautology.h"
2
3 #include <cpInstances/DataObjects/Image.h>
4
5 #include <itkImage.h>
6 #include <fpa/Base/Functors/RegionGrow/Tautology.h>
7
8 // -------------------------------------------------------------------------
9 void fpaPlugins_ImageFunctors::Tautology::
10 Instantiate( itk::LightObject* filter )
11 {
12   auto itk_filter = dynamic_cast< itk::ProcessObject* >( filter );
13   if( itk_filter != NULL )
14   {
15     auto inputs = itk_filter->GetInputs( );
16     if( inputs.size( ) > 0 )
17     {
18       cpPlugins_Demangle_Image_ScalarPixels_AllDims_2(
19         inputs[ 0 ].GetPointer( ), _GD0, itk_filter
20         )
21         this->_Error( "Invalid input data." );
22     }
23     else
24       this->_Error( "Not enough inputs." );
25   }
26   else
27     this->_Error( "Invalid instantiation filter." );
28 }
29
30 // -------------------------------------------------------------------------
31 fpaPlugins_ImageFunctors::Tautology::
32 Tautology( )
33   : Superclass( )
34 {
35   this->_ConfigureOutput< cpPlugins::Pipeline::DataObject >( "Functor" );
36   this->GetOutput( "Functor" )->SetITK( this );
37 }
38
39 // -------------------------------------------------------------------------
40 fpaPlugins_ImageFunctors::Tautology::
41 ~Tautology( )
42 {
43 }
44
45 // -------------------------------------------------------------------------
46 void fpaPlugins_ImageFunctors::Tautology::
47 _GenerateData( )
48 {
49 }
50
51 // -------------------------------------------------------------------------
52 template< class _TInput >
53 void fpaPlugins_ImageFunctors::Tautology::
54 _GD0( _TInput* input, itk::ProcessObject* filter )
55 {
56   auto outputs = filter->GetOutputs( );
57   if( outputs.size( ) > 0 )
58   {
59     cpPlugins_Demangle_Image_IntPixels_3(
60       outputs[ 0 ].GetPointer( ), _GD1, _TInput::ImageDimension, input, filter
61       )
62       this->_Error( "Invalid output data." );
63   }
64   else
65     this->_Error( "Not enough outputs." );
66 }
67
68 // -------------------------------------------------------------------------
69 template< class _TInput, class _TOutput >
70 void fpaPlugins_ImageFunctors::Tautology::
71 _GD1( _TOutput* output, _TInput* input, itk::ProcessObject* filter )
72 {
73   typedef typename _TInput::IndexType  _TVertex;
74   typedef typename _TOutput::PixelType _TValue;
75   typedef fpa::Base::Functors::RegionGrow::Tautology< _TVertex, _TValue > _TFunctor;
76
77   auto f = dynamic_cast< _TFunctor* >( this->m_Functor.GetPointer( ) );
78   if( f == NULL )
79   {
80     typename _TFunctor::Pointer ptr_f = _TFunctor::New( );
81     f = ptr_f.GetPointer( );
82     this->m_Functor = f;
83
84   } // fi
85 }
86
87 // eof - $RCSfile$