]> Creatis software - clitk.git/blob - registration/clitkMultipleBSplineDeformableTransformInitializer.h
Merge branch 'VTK6_Qt5_Overlay4D' into VTK6_Qt5_Binarize
[clitk.git] / registration / clitkMultipleBSplineDeformableTransformInitializer.h
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 __clitkMultipleBSplineDeformableTransformInitializer_h
19 #define __clitkMultipleBSplineDeformableTransformInitializer_h
20 #include "clitkResampleBSplineDeformableTransformImageFilter.h"
21
22 #include "itkObject.h"
23 #include "itkObjectFactory.h"
24 #include <iostream>
25
26 namespace clitk
27 {
28
29   template < class TTransform, class TImage >
30     class ITK_EXPORT MultipleBSplineDeformableTransformInitializer : public itk::Object
31   {
32     public:
33       /** Standard class typedefs. */
34       typedef MultipleBSplineDeformableTransformInitializer     Self;
35       typedef itk::Object                               Superclass;
36       typedef itk::SmartPointer<Self>                   Pointer;
37       typedef itk::SmartPointer<const Self>             ConstPointer;
38
39       /** New macro for creation of through a Smart Pointer. */
40       itkNewMacro( Self );
41
42       /** Run-time type information (and related methods). */
43       itkTypeMacro( MultipleBSplineDeformableTransformInitializer, Object );
44
45       // Typedefs
46       typedef TTransform                                TransformType;
47       typedef typename TransformType::Pointer           TransformPointer;
48       typedef typename TransformType::RegionType        RegionType;
49       typedef typename RegionType::SizeType             SizeType;
50       typedef typename TransformType::SpacingType       SpacingType;
51       itkStaticConstMacro(InputDimension, unsigned int, TransformType::InputDimension);
52       typedef   TImage                                  ImageType;
53       typedef typename ImageType::ConstPointer        ImagePointer;
54       typedef typename TransformType::CoefficientImageType CoefficientImageType;
55       typedef typename TransformType::ParametersType ParametersType;
56
57       // Set and Get
58       itkBooleanMacro(Verbose);
59       itkSetMacro( Verbose, bool);
60       itkGetConstReferenceMacro( Verbose, bool);
61       itkSetObjectMacro( Transform,   TransformType   );
62       itkGetConstObjectMacro( Transform,   TransformType   );
63       itkSetObjectMacro( Image,  ImageType  );
64       itkGetConstObjectMacro( Image,  ImageType  );
65       void SetSplineOrder(const unsigned int & splineOrder)
66       {
67         SizeType s;
68         s.Fill(splineOrder);
69         this->SetSplineOrders(s);
70       }
71       void SetSplineOrders(const SizeType & splineOrders)
72       {
73         m_SplineOrders=splineOrders;
74       }
75       void SetNumberOfControlPointsInsideTheImage(  SizeType & n  )
76       {
77         m_NumberOfControlPointsInsideTheImage=n;
78         m_NumberOfControlPointsIsGiven=true;
79         this->Modified();
80       }
81       void SetNumberOfControlPointsInsideTheImage(  int * n)
82       {
83         SizeType s;
84         for (unsigned int i=0;i<InputDimension;i++)
85           s[i]=n[i];
86         this->SetNumberOfControlPointsInsideTheImage( s );
87       }
88       void SetNumberOfControlPointsInsideTheImage(  unsigned int & n )
89       {
90         SizeType s;
91         s.Fill( n );;
92         this->SetNumberOfControlPointsInsideTheImage( s );
93       }
94       void SetControlPointSpacing( SpacingType n )
95       {
96         m_ControlPointSpacing= n;
97         m_ControlPointSpacingIsGiven=true;
98         this->Modified();
99       }
100       void SetControlPointSpacing( double*& n )
101       {
102         SpacingType s( n );
103         this->SetControlPointSpacing(s);
104       }
105       void SetControlPointSpacing( double n )
106       {
107         SpacingType s;
108         s.Fill( n );
109         this->SetControlPointSpacing(s);
110       }
111       void SetSamplingFactors(  SizeType n  )
112       {
113         m_SamplingFactors=n;
114         m_SamplingFactorIsGiven=true;
115         this->Modified();
116       }
117       void SetSamplingFactors(  int *& n)
118       {
119         SizeType s;
120         for (unsigned int i=0;i<InputDimension;i++)
121           s[i]=n[i];
122         this-> SetSamplingFactors( s );
123       }
124       void SetSamplingFactors( unsigned  int n )
125       {
126         SizeType s;
127         s.Fill( n );
128         this-> SetSamplingFactors( s );
129       }
130       virtual void InitializeTransform();
131       void SetInitialParameters(std::vector<typename CoefficientImageType::Pointer> coefficientImage, ParametersType& params);
132       void SetInitialParameters(const std::string & s, ParametersType& params);
133
134       // For easy acces, declared public
135       std::vector<SizeType> m_NumberOfControlPointsInsideTheImageArray;
136       std::vector<SizeType> m_SamplingFactorsArray;
137       std::vector<SpacingType> m_ControlPointSpacingArray;
138
139       SpacingType   m_ControlPointSpacing;
140       SizeType   m_SamplingFactors;
141       SizeType   m_SplineOrders;
142       SpacingType   m_ChosenSpacing;
143       SizeType   m_NumberOfControlPointsInsideTheImage;
144       bool m_NumberOfControlPointsIsGiven;
145       bool m_ControlPointSpacingIsGiven;
146       bool m_SamplingFactorIsGiven;
147       bool m_TransformRegionIsGiven;
148
149       typename TransformType::ParametersType* m_Parameters;
150
151     protected:
152       MultipleBSplineDeformableTransformInitializer();
153       ~MultipleBSplineDeformableTransformInitializer(){};
154
155     private:
156       MultipleBSplineDeformableTransformInitializer(const Self&); //purposely not implemented
157       void operator=(const Self&); //purposely not implemented
158
159       bool m_Verbose;
160       TransformPointer    m_Transform;
161       ImagePointer        m_Image;
162
163   }; //class MultipleBSplineDeformableTransformInitializer
164
165
166 }  // namespace clitk
167
168
169 #ifndef ITK_MANUAL_INSTANTIATION
170 #include "clitkMultipleBSplineDeformableTransformInitializer.txx"
171 #endif
172
173 #endif /* __clitkMultipleBSplineDeformableTransformInitializer_h */