]> Creatis software - cpPlugins.git/blob - plugins/ITKSliceFilters/CPRImageFilter.cxx
...
[cpPlugins.git] / plugins / ITKSliceFilters / CPRImageFilter.cxx
1 #include <ITKSliceFilters/CPRImageFilter.h>
2
3 #include <cpInstances/DataObjects/Image.h>
4 #include <cpInstances/DataObjects/Simple3DCurve.h>
5
6 #include <itkImage.h>
7 #include <cpExtensions/DataStructures/Simple3DCurve.h>
8 #include <cpExtensions/Algorithms/CPRImageFilter.h>
9
10 // -------------------------------------------------------------------------
11 cpPluginsITKSliceFilters::CPRImageFilter::
12 CPRImageFilter( )
13   : Superclass( )
14 {
15   typedef cpInstances::DataObjects::Image         _TImage;
16   typedef cpInstances::DataObjects::Simple3DCurve _TCurve;
17   this->_ConfigureInput< _TImage >( "Image", true, false );
18   this->_ConfigureInput< _TCurve >( "Curve", true, false );
19   this->_ConfigureOutput< _TImage >( "Output" );
20   this->m_Parameters.ConfigureAsReal( "SliceRadius", 1 );
21 }
22
23 // -------------------------------------------------------------------------
24 cpPluginsITKSliceFilters::CPRImageFilter::
25 ~CPRImageFilter( )
26 {
27 }
28
29 // -------------------------------------------------------------------------
30 void cpPluginsITKSliceFilters::CPRImageFilter::
31 _GenerateData( )
32 {
33   auto o = this->GetInputData( "Image" );
34   cpPlugins_Demangle_Image_ScalarPixels_1( o, _GD0, 3 )
35     this->_Error( "Invalid input image." );
36 }
37
38 // -------------------------------------------------------------------------
39 template< class _TImage >
40 void cpPluginsITKSliceFilters::CPRImageFilter::
41 _GD0( _TImage* image )
42 {
43   auto o = this->GetInputData( "Curve" );
44   cpPlugins_Demangle_Simple3DCurve_All_2( o, _GD1, image )
45     this->_Error( "Invalid input curve." );
46 }
47
48 // -------------------------------------------------------------------------
49 template< class _TCurve, class _TImage >
50 void cpPluginsITKSliceFilters::CPRImageFilter::
51 _GD1( _TCurve* curve, _TImage* image )
52 {
53   typedef cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve > _TFilter;
54
55   auto filter = this->_CreateITK< _TFilter >( );
56   filter->SetInput( image );
57   filter->SetCurve( curve );
58   filter->SetSliceRadius( this->m_Parameters.GetReal( "SliceRadius" ) );
59   filter->Update( );
60   this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
61 }
62
63 // eof - $RCSfile$