]> Creatis software - clitk.git/blob - registration/clitkDeformationFieldTransform.txx
Debug RTStruct conversion with empty struc
[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>::DeformationFieldTransform():Superclass(1)
29
30   {
31      m_DeformationField=NULL;
32      m_Interpolator=DefaultInterpolatorType::New();
33   }
34     
35    // Transform a point
36   template<class TScalarType, unsigned int InputDimension,unsigned int OutputDimension, unsigned int SpaceDimension>
37   typename DeformationFieldTransform<TScalarType,  InputDimension, OutputDimension, SpaceDimension>::OutputPointType
38   DeformationFieldTransform<TScalarType, InputDimension, OutputDimension, SpaceDimension>::
39   TransformPoint(const InputPointType &inputPoint) const 
40   {
41     OutputPointType outputPoint;
42     outputPoint.Fill(0.);
43     for (unsigned int i=0;i<min(OutputDimension,InputDimension); i++) outputPoint[i]=inputPoint[i];
44     DisplacementType displacement;
45     if (m_Interpolator->IsInsideBuffer(inputPoint) )
46       {
47         displacement=m_Interpolator->Evaluate(inputPoint);
48         for (unsigned int i=0;i<min(OutputDimension,SpaceDimension); i++) 
49           outputPoint[i]+=displacement[i];
50         return outputPoint;
51       }
52
53     // No displacement
54     else return outputPoint;
55         
56   }
57
58   
59 } // namespace clitk
60
61 #endif