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