]> Creatis software - clitk.git/blob - registration/clitkDeformationFieldTransform.txx
Merge commit '488f24aa984ae24adc9458bf5fbf3b2351415742'
[clitk.git] / registration / clitkDeformationFieldTransform.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://www.centreleonberard.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 __clitkDeformationFieldTransform_txx
19 #define __clitkDeformationFieldTransform_txx
20 #include "clitkDeformationFieldTransform.h"
21
22
23 namespace clitk
24 {
25
26   // Constructor
27   template<class TScalarType, unsigned int InputDimension, unsigned int OutputDimension, unsigned int SpaceDimension>
28   DeformationFieldTransform<TScalarType, InputDimension, OutputDimension, SpaceDimension>
29 #if ITK_VERSION_MAJOR >= 4
30   ::DeformationFieldTransform():Superclass(1)
31 #else
32   ::DeformationFieldTransform():Superclass(OutputDimension,1)
33 #endif
34   {
35      m_DeformationField=NULL;
36      m_Interpolator=DefaultInterpolatorType::New();
37   }
38     
39    // Transform a point
40   template<class TScalarType, unsigned int InputDimension,unsigned int OutputDimension, unsigned int SpaceDimension>
41   typename DeformationFieldTransform<TScalarType,  InputDimension, OutputDimension, SpaceDimension>::OutputPointType
42   DeformationFieldTransform<TScalarType, InputDimension, OutputDimension, SpaceDimension>::
43   TransformPoint(const InputPointType &inputPoint) const 
44   {
45     OutputPointType outputPoint;
46     outputPoint.Fill(0.);
47     for (unsigned int i=0;i<min(OutputDimension,InputDimension); i++) outputPoint[i]=inputPoint[i];
48     DisplacementType displacement;
49     if (m_Interpolator->IsInsideBuffer(inputPoint) )
50       {
51         displacement=m_Interpolator->Evaluate(inputPoint);
52         for (unsigned int i=0;i<min(OutputDimension,SpaceDimension); i++) 
53           outputPoint[i]+=displacement[i];
54         return outputPoint;
55       }
56
57     // No displacement
58     else return outputPoint;
59         
60   }
61
62   
63 } // namespace clitk
64
65 #endif