]> Creatis software - clitk.git/blob - itk/clitkGenericInterpolator.txx
Reformatted using new coding style
[clitk.git] / itk / clitkGenericInterpolator.txx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef __clitkGenericInterpolator_txx
19 #define __clitkGenericInterpolator_txx
20 #include "clitkGenericInterpolator.h"
21
22
23 namespace clitk
24 {
25
26 //=========================================================================================================================
27 //constructor
28 template <class args_info_type,  class ImageType, class TCoordRep>
29 GenericInterpolator<args_info_type, ImageType, TCoordRep>::GenericInterpolator()
30 {
31   m_Interpolator=NULL;
32   m_Verbose=false;
33 }
34
35
36 //=========================================================================================================================
37 //Get the pointer
38 template <class args_info_type,  class ImageType, class TCoordRep>
39 typename GenericInterpolator<args_info_type, ImageType, TCoordRep>::InterpolatorPointer
40 GenericInterpolator<args_info_type, ImageType, TCoordRep>::GetInterpolatorPointer()
41 {
42   //============================================================================
43   // We retrieve the type of interpolation from the command line
44   //============================================================================
45   typename InterpolatorType::Pointer interpolator;
46
47   switch ( m_ArgsInfo.interp_arg ) {
48   case 0:
49
50     interpolator= itk::NearestNeighborInterpolateImageFunction< ImageType,TCoordRep >::New();
51     if (m_Verbose) std::cout<<"Using nearestneighbor interpolation..."<<std::endl;
52     break;
53
54   case 1:
55
56     interpolator = itk::LinearInterpolateImageFunction< ImageType,TCoordRep >::New();
57     if (m_Verbose) std::cout<<"Using linear interpolation..."<<std::endl;
58     break;
59
60   case 2: {
61     typename itk::BSplineInterpolateImageFunction< ImageType,TCoordRep >::Pointer m =itk::BSplineInterpolateImageFunction< ImageType,TCoordRep >::New();
62     m->SetSplineOrder(m_ArgsInfo.interpOrder_arg);
63     interpolator=m;
64     if (m_Verbose) std::cout<<"Using Bspline interpolation..."<<std::endl;
65     break;
66   }
67
68   case 3: {
69     typename itk::BSplineInterpolateImageFunctionWithLUT< ImageType,TCoordRep >::Pointer m =itk::BSplineInterpolateImageFunctionWithLUT< ImageType,TCoordRep >::New();
70     m->SetSplineOrder(m_ArgsInfo.interpOrder_arg);
71     m->SetLUTSamplingFactor(m_ArgsInfo.interpSF_arg);
72     interpolator=m;
73     if (m_Verbose) std::cout<<"Using BLUT interpolation..."<<std::endl;
74     break;
75   }
76
77
78   }//end of switch
79
80
81   //============================================================================
82   //return the pointer
83   return interpolator;
84 }
85
86 }
87
88 #endif