]> Creatis software - cpPlugins.git/blob - plugins/ITKImageInterpolators/LinearInterpolateImageFunction.cxx
...
[cpPlugins.git] / plugins / ITKImageInterpolators / LinearInterpolateImageFunction.cxx
1 #include <ITKImageInterpolators/LinearInterpolateImageFunction.h>
2 #include <cpInstances/Image.h>
3 #include <itkImage.h>
4 #include <itkLinearInterpolateImageFunction.h>
5
6 // -------------------------------------------------------------------------
7 cpPluginsITKImageInterpolators::LinearInterpolateImageFunction::
8 LinearInterpolateImageFunction( )
9   : Superclass( )
10 {
11 }
12
13 // -------------------------------------------------------------------------
14 cpPluginsITKImageInterpolators::LinearInterpolateImageFunction::
15 ~LinearInterpolateImageFunction( )
16 {
17 }
18
19 // -------------------------------------------------------------------------
20 void cpPluginsITKImageInterpolators::LinearInterpolateImageFunction::
21 CreateInterpolator(
22   itk::LightObject* image, const std::string& precision_type
23   )
24 {
25   this->m_PrecisionType = precision_type;
26   cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( image, _GD0 )
27     this->_Error( "Invalid input image." );
28 }
29
30 // -------------------------------------------------------------------------
31 void cpPluginsITKImageInterpolators::LinearInterpolateImageFunction::
32 _GenerateData( )
33 {
34 }
35
36 // -------------------------------------------------------------------------
37 template< class _TImage >
38 void cpPluginsITKImageInterpolators::LinearInterpolateImageFunction::
39 _GD0( _TImage* image )
40 {
41   if( this->m_PrecisionType == "float" )
42     this->_GD1< _TImage, float >( image );
43   else if( this->m_PrecisionType == "double" )
44     this->_GD1< _TImage, double >( image );
45 }
46
47 // -------------------------------------------------------------------------
48 template< class _TImage, class _TScalar >
49 void cpPluginsITKImageInterpolators::LinearInterpolateImageFunction::
50 _GD1( _TImage* image )
51 {
52   typedef itk::LinearInterpolateImageFunction< _TImage, _TScalar > _TFunction;
53
54   auto function = this->_CreateITK< _TFunction >( );
55   this->GetOutput( "Output" )->SetITK( function );
56 }
57
58 // eof - $RCSfile$