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