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