]> Creatis software - clitk.git/blob - registration/clitkResampleBSplineDeformableTransformImageFilter.h
Debug RTStruct conversion with empty struc
[clitk.git] / registration / clitkResampleBSplineDeformableTransformImageFilter.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 clitkResampleBSplineDeformableTransformImageFilter_h
19 #define clitkResampleBSplineDeformableTransformImageFilter_h
20
21 /* =================================================
22  * @file   clitkResampleBSplineDeformableTransformImageFilter.h
23  * @author 
24  * @date   
25  * 
26  * @brief 
27  * 
28  ===================================================*/
29
30
31 // clitk include
32 #include "clitkIO.h"
33 #include "clitkCommon.h"
34 #include "clitkVectorBSplineDecompositionImageFilterWithOBD.h"
35 #include "clitkVectorBSplineResampleImageFunction.h"
36
37 //itk include
38 #include "itkImageToImageFilter.h"
39 #include "itkVectorResampleImageFilter.h"
40 #include "itkCastImageFilter.h"
41
42
43 namespace clitk 
44 {
45
46   template <class InputImageType, class OutputImageType>
47   class ITK_EXPORT ResampleBSplineDeformableTransformImageFilter :
48     public itk::ImageToImageFilter<InputImageType, OutputImageType>
49   {
50   public:
51     //----------------------------------------
52     // ITK
53     //----------------------------------------
54     typedef ResampleBSplineDeformableTransformImageFilter                                                 Self;
55     typedef itk::ImageToImageFilter<InputImageType, OutputImageType>  Superclass;
56     typedef itk::SmartPointer<Self>                                   Pointer;
57     typedef itk::SmartPointer<const Self>                             ConstPointer;
58    
59     // Method for creation through the object factory
60     itkNewMacro(Self);  
61
62     // Run-time type information (and related methods)
63     itkTypeMacro( ResampleBSplineDeformableTransformImageFilter, ImageToImageFilter );
64
65     /** Dimension of the domain space. */
66     itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension);
67
68     //----------------------------------------
69     // Typedefs
70     //----------------------------------------
71     typedef typename InputImageType::PointType              InputPointType;
72     typedef typename InputImageType::IndexType              IndexType;
73     
74     typedef typename OutputImageType::RegionType            OutputImageRegionType;
75     typedef typename OutputImageType::PointType             OutputPointType;
76     typedef typename OutputImageType::SpacingType           OutputSpacingType;
77     typedef typename OutputImageType::DirectionType         OutputDirectionType;
78     typedef typename OutputImageType::IndexType             OutputIndexType;
79     typedef typename OutputImageType::SizeType             OutputSizeType;
80
81
82     //----------------------------------------
83     // Set & Get
84     //----------------------------------------    
85     itkBooleanMacro(Verbose);
86     itkSetMacro( Verbose, bool);
87     itkGetConstReferenceMacro( Verbose, bool);
88
89     // Properties of the output 
90     itkSetMacro( Size, OutputSizeType );
91     itkGetConstReferenceMacro( Size, OutputSizeType );
92     itkSetMacro(OutputSpacing, OutputSpacingType);
93     virtual void SetOutputSpacing( const double* values);
94     itkGetConstReferenceMacro( OutputSpacing, OutputSpacingType );
95     itkSetMacro(OutputOrigin, OutputPointType);
96     virtual void SetOutputOrigin( const double* values);
97     itkGetConstReferenceMacro( OutputOrigin, OutputPointType );
98     itkSetMacro(OutputDirection, OutputDirectionType);
99     itkGetConstReferenceMacro(OutputDirection, OutputDirectionType);
100     itkSetMacro( OutputStartIndex, OutputIndexType );
101     itkGetConstReferenceMacro( OutputStartIndex, OutputIndexType );
102     void SetOutputParametersFromImage ( typename OutputImageType::Pointer Image )
103     {
104       this->SetOutputOrigin ( Image->GetOrigin() );
105       this->SetOutputSpacing ( Image->GetSpacing() );
106       this->SetOutputDirection ( Image->GetDirection() );
107       this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
108       this->SetOutputStartIndex(Image->GetLargestPossibleRegion().GetIndex());
109     }
110
111     void SetOutputParametersFromConstImage ( typename OutputImageType::ConstPointer Image )
112     {
113       this->SetOutputOrigin ( Image->GetOrigin() );
114       this->SetOutputSpacing ( Image->GetSpacing() );
115       this->SetOutputDirection ( Image->GetDirection() );
116       this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
117       this->SetOutputStartIndex(Image->GetLargestPossibleRegion().GetIndex());
118     }
119    
120
121   protected:
122
123     //----------------------------------------  
124     // Constructor & Destructor
125     //----------------------------------------  
126     ResampleBSplineDeformableTransformImageFilter();
127     ~ResampleBSplineDeformableTransformImageFilter() {};
128
129     //----------------------------------------  
130     // Update
131     //----------------------------------------  
132     // Generate Data
133     void GenerateData(void);
134     //     // Threaded Generate Data
135     //     void BeforeThreadedGenerateData(void );
136     //     void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, int threadId );
137     //     void AfterThreadedGenerateData(void );
138     //     // Override defaults
139     //     virtual void GenerateInputRequestedRegion();
140     //     virtual void GenerateOutputInformation (void);
141     //     virtual void EnlargeOutputRequestedRegion(DataObject *data);
142     void AllocateOutputs(){};
143
144     //----------------------------------------  
145     // Data members
146     //----------------------------------------
147     bool m_Verbose;
148     OutputSizeType                m_Size;              // Size of the output image
149     OutputSpacingType             m_OutputSpacing;     // output image spacing
150     OutputPointType               m_OutputOrigin;      // output image origin
151     OutputDirectionType           m_OutputDirection;   // output image direction cosines
152     OutputIndexType               m_OutputStartIndex;  // output image start index
153     OutputSizeType                m_SplineOrders;
154
155     //----------------------------------------  
156     // Components
157     //----------------------------------------
158     typedef itk::VectorResampleImageFilter<InputImageType, OutputImageType> ResamplerType;
159     typedef VectorBSplineResampleImageFunction<InputImageType, double> FunctionType;
160     typedef itk::IdentityTransform<double,InputImageDimension> IdentityTransformType; 
161     typedef VectorBSplineDecompositionImageFilterWithOBD<OutputImageType, OutputImageType> DecompositionType;
162     typename ResamplerType::Pointer m_Resampler;
163     typename FunctionType::Pointer m_Function;
164     typename IdentityTransformType::Pointer m_Identity;
165     typename DecompositionType::Pointer m_Decomposition;
166
167
168   };
169
170
171 } // end namespace clitk
172
173 #ifndef ITK_MANUAL_INSTANTIATION
174 #include "clitkResampleBSplineDeformableTransformImageFilter.txx"
175 #endif
176
177 #endif // #define clitkResampleBSplineDeformableTransformImageFilter_h
178
179