]> Creatis software - clitk.git/blob - itk/clitkExtractSliceFilter.h
Ensure compatibility with VTK6 for Image2DicomRTStruct tool
[clitk.git] / itk / clitkExtractSliceFilter.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
19 #ifndef CLITKEXTRACTSLICEFILTER_H
20 #define CLITKEXTRACTSLICEFILTER_H
21
22 // clitk
23 #include "clitkFilterBase.h"
24
25 // itk
26 #include "itkPasteImageFilter.h"
27
28 // itk ENST
29 #include "RelativePositionPropImageFilter.h"
30
31 namespace clitk {
32   
33   //--------------------------------------------------------------------
34   /*
35     Let A be an initial label image.
36     Let B be a label image with an object. 
37     Let o be an orientation relatively to the B object (for example RightTo, AntTo, InferiorTo ...)
38
39     This filter removes (=set background) from A all points that are
40     not in the wanted o orientation. It uses downsampled version for
41     faster processing, and (try to) take into account discretization
42     problem. Uses [Bloch 1999].
43   */
44   //--------------------------------------------------------------------
45   
46   template <class ImageType>
47   class ITK_EXPORT ExtractSliceFilter:
48     public clitk::FilterBase, 
49     public itk::ImageToImageFilter<ImageType, 
50                                    typename itk::Image<typename ImageType::PixelType, ImageType::ImageDimension-1> >
51   {
52
53   public:
54     /** Some convenient typedefs. */
55     typedef typename ImageType::ConstPointer ImageConstPointer;
56     typedef typename ImageType::Pointer      ImagePointer;
57     typedef typename ImageType::RegionType   RegionType; 
58     typedef typename ImageType::PixelType    PixelType;
59     typedef typename ImageType::SpacingType  SpacingType;
60     typedef typename ImageType::SizeType     SizeType;
61     typedef typename ImageType::IndexType    IndexType;
62     
63     /** ImageDimension constants */
64     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
65
66     /** Slice image type **/
67     typedef itk::Image<PixelType, ImageDimension-1> SliceType;
68     typedef typename SliceType::Pointer             SliceTypePointer;
69
70     /** Standard class typedefs. */
71     typedef itk::ImageToImageFilter<ImageType, SliceType>   Superclass;
72     typedef ExtractSliceFilter                              Self;
73     typedef itk::SmartPointer<Self>                         Pointer;
74     typedef itk::SmartPointer<const Self>                   ConstPointer;
75        
76     /** Method for creation through the object factory. */
77     itkNewMacro(Self);
78     
79     /** Run-time type information (and related methods). */
80     itkTypeMacro(ExtractSliceFilter, ImageToImageFilter);
81     FILTERBASE_INIT;
82
83     /** Input : initial image and object */
84     void SetInput(const ImageType * image);
85     
86     // Options
87     itkGetConstMacro(Direction, int);
88     itkSetMacro(Direction, int);
89     
90     // Get results
91     void GetOutputSlices(std::vector<typename SliceType::Pointer> & o);
92
93   protected:
94     ExtractSliceFilter();
95     virtual ~ExtractSliceFilter() {}
96     
97     int m_Direction;
98
99     virtual void GenerateOutputInformation();
100     virtual void GenerateInputRequestedRegion();
101     virtual void GenerateData();
102
103     int m_NumberOfSlices;
104     ImagePointer input;
105     ImagePointer object;
106     SliceType *  output;
107     
108     RegionType m_region;
109     SizeType   m_size;
110     IndexType  m_index;
111
112   private:
113     ExtractSliceFilter(const Self&); //purposely not implemented
114     void operator=(const Self&); //purposely not implemented
115     
116   }; // end class
117   //--------------------------------------------------------------------
118
119 } // end namespace clitk
120 //--------------------------------------------------------------------
121
122 #ifndef ITK_MANUAL_INSTANTIATION
123 #include "clitkExtractSliceFilter.txx"
124 #endif
125
126 #endif