]> Creatis software - clitk.git/blob - itk/clitkForwardWarpImageFilter.h
7efac8fc8268291bd3564fb0a1a03045a9744cbb
[clitk.git] / itk / clitkForwardWarpImageFilter.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 __clitkForwardWarpImageFilter_h
19 #define __clitkForwardWarpImageFilter_h
20 #include "clitkImageCommon.h"
21
22 //itk include
23 #include "itkImageToImageFilter.h"
24 #include "itkImage.h"
25 #include "itkImageRegionIterator.h"
26 #include "itkImageRegionIteratorWithIndex.h"
27 #include "itkNumericTraits.h"
28 #include "itkSimpleFastMutexLock.h"
29
30 namespace clitk
31 {
32   
33   template <  class InputImageType,  class OutputImageType,  class DeformationFieldType  >  
34   class ForwardWarpImageFilter : public itk::ImageToImageFilter<InputImageType, OutputImageType>
35   
36   {
37   public:
38     typedef ForwardWarpImageFilter     Self;
39     typedef itk::ImageToImageFilter<InputImageType,OutputImageType>     Superclass;
40     typedef itk::SmartPointer<Self>            Pointer;
41     typedef itk::SmartPointer<const Self>      ConstPointer;
42
43    
44     /** Method for creation through the object factory. */
45     itkNewMacro(Self);  
46   
47     /** Determine the image dimension. */
48     itkStaticConstMacro(ImageDimension, unsigned int,
49                         InputImageType::ImageDimension );
50     itkStaticConstMacro(InputImageDimension, unsigned int,
51                         OutputImageType::ImageDimension );
52     itkStaticConstMacro(DeformationFieldDimension, unsigned int,
53                         DeformationFieldType::ImageDimension );
54
55
56     //Some other typedefs
57     typedef double CoordRepType;
58     typedef itk::Image<double, ImageDimension> WeightsImageType;
59     typedef itk::Image<itk::SimpleFastMutexLock, ImageDimension> MutexImageType;
60
61     /** Point type */
62     typedef itk::Point<CoordRepType,itkGetStaticConstMacro(ImageDimension)> PointType;
63
64     /** Inherit some types from the superclass. */
65     typedef typename OutputImageType::IndexType        IndexType;
66     typedef typename OutputImageType::SizeType         SizeType;
67     typedef typename OutputImageType::PixelType        PixelType;
68     typedef typename OutputImageType::SpacingType      SpacingType;
69     
70     //Set & Get Methods (inline)
71     itkSetMacro( Verbose, bool);
72     itkSetMacro( EdgePaddingValue, PixelType );
73     itkSetMacro( DeformationField, typename DeformationFieldType::Pointer);
74 #if ITK_VERSION_MAJOR <= 4
75     void SetNumberOfThreads(unsigned int r )
76 #else
77     void SetNumberOfWorkUnits(unsigned int r )
78 #endif
79     {
80       m_NumberOfThreadsIsGiven=true;
81 #if ITK_VERSION_MAJOR <= 4
82       m_NumberOfThreads=r;
83 #else
84       m_NumberOfWorkUnits=r;
85 #endif
86     }
87     itkSetMacro(ThreadSafe, bool);
88  
89   
90     //ITK concept checking, why not?  
91 #ifdef ITK_USE_CONCEPT_CHECKING
92     /** Begin concept checking */
93     itkConceptMacro(SameDimensionCheck1,
94                     (itk::Concept::SameDimension<ImageDimension, InputImageDimension>));
95     itkConceptMacro(SameDimensionCheck2,
96                     (itk::Concept::SameDimension<ImageDimension, DeformationFieldDimension>));
97     itkConceptMacro(InputHasNumericTraitsCheck,
98                     (itk::Concept::HasNumericTraits<typename InputImageType::PixelType>));
99     itkConceptMacro(DeformationFieldHasNumericTraitsCheck,
100                     (itk::Concept::HasNumericTraits<typename DeformationFieldType::PixelType::ValueType>));
101     /** End concept checking */
102 #endif
103
104   protected:
105     ForwardWarpImageFilter();
106     ~ForwardWarpImageFilter() {};
107     void GenerateData( );
108
109   
110   private:
111     bool m_Verbose;
112     bool m_NumberOfThreadsIsGiven;
113 #if ITK_VERSION_MAJOR <= 4
114     unsigned int m_NumberOfThreads;
115 #else
116     unsigned int m_NumberOfWorkUnits;
117 #endif
118     PixelType m_EdgePaddingValue;
119     typename DeformationFieldType::Pointer m_DeformationField;
120     bool m_ThreadSafe;
121  
122   };
123
124
125
126
127
128 } // end namespace clitk
129 #ifndef ITK_MANUAL_INSTANTIATION
130 #include "clitkForwardWarpImageFilter.txx"
131 #endif
132
133 #endif // #define __clitkForwardWarpImageFilter_h