]> Creatis software - cpPlugins.git/blob - plugins/ImageSliceFilters/CPRImageFilter.cxx
77c7f81d9ff28cca4c8fa2cd411ed27f5e638d70
[cpPlugins.git] / plugins / ImageSliceFilters / CPRImageFilter.cxx
1 #include <ImageSliceFilters/CPRImageFilter.h>
2 #include <cpPlugins/DataObjects/Image.h>
3 #include <Extensions/Simple3DCurve.h>
4
5 #include <itkImage.h>
6 #include <cpExtensions/DataStructures/Simple3DCurve.h>
7 #include <cpExtensions/Algorithms/CPRImageFilter.h>
8
9 // -------------------------------------------------------------------------
10 cpPluginsImageSliceFilters::CPRImageFilter::
11 CPRImageFilter( )
12   : Superclass( )
13 {
14   typedef cpPlugins::DataObjects::Image      _TImage;
15   typedef cpPluginsExtensions::Simple3DCurve _TCurve;
16   this->_ConfigureInput< _TImage >( "Image", true, false );
17   this->_ConfigureInput< _TCurve >( "Curve", true, false );
18   this->_ConfigureOutput< _TImage >( "Output" );
19
20   this->m_Parameters.ConfigureAsReal( "SliceRadius", 1 );
21 }
22
23 // -------------------------------------------------------------------------
24 cpPluginsImageSliceFilters::CPRImageFilter::
25 ~CPRImageFilter( )
26 {
27 }
28
29 // -------------------------------------------------------------------------
30 void cpPluginsImageSliceFilters::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 cpPluginsImageSliceFilters::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 cpPluginsImageSliceFilters::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$