]> Creatis software - clitk.git/blob - itk/clitkMeshToBinaryImageFilter.h
Merge branch 'master' into OpenGL2
[clitk.git] / itk / clitkMeshToBinaryImageFilter.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 CLITKMESHTOBINARYIMAGEFILTER_H
20 #define CLITKMESHTOBINARYIMAGEFILTER_H
21
22 // clitk
23 #include "clitkCommon.h"
24
25 // itk
26 #include <itkImageSource.h>
27
28 // vtk
29 #include <vtkSmartPointer.h>
30 #include <vtkPolyData.h>
31
32 namespace clitk {
33     
34   /* --------------------------------------------------------------------     
35      Convert a mesh composed of a list of 2D contours, into a 3D binray
36      image.     
37      -------------------------------------------------------------------- */
38   
39   template <class ImageType>
40   class ITK_EXPORT MeshToBinaryImageFilter: public itk::ImageSource<ImageType>
41   {
42
43   public:
44     /** Standard class typedefs. */
45     typedef itk::ImageSource<ImageType>   Superclass;
46     typedef MeshToBinaryImageFilter       Self;
47     typedef itk::SmartPointer<Self>       Pointer;
48     typedef itk::SmartPointer<const Self> ConstPointer;
49        
50     /** Method for creation through the object factory. */
51     itkNewMacro(Self);
52     
53     /** Run-time type information (and related methods). */
54     itkTypeMacro(MeshToBinaryImageFilter, Superclass);
55
56     /** ImageDimension constants */
57     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
58     typedef itk::Image<float, ImageDimension> FloatImageType;
59
60     /** Some convenient typedefs. */
61     typedef typename ImageType::ConstPointer ImageConstPointer;
62     typedef typename ImageType::Pointer      ImagePointer;
63     typedef typename ImageType::RegionType   RegionType; 
64     typedef typename ImageType::PixelType    PixelType;
65     typedef typename ImageType::SpacingType  SpacingType;
66     typedef typename ImageType::SizeType     SizeType;
67     typedef typename ImageType::PointType    PointType;
68     typedef itk::Image<PixelType, ImageDimension-1> SliceType;
69     
70     /** Input : initial image and object */
71     itkSetMacro(Mesh, vtkSmartPointer<vtkPolyData>);
72     itkGetConstMacro(Mesh, vtkSmartPointer<vtkPolyData>);
73
74     itkSetMacro(LikeImage, ImagePointer);
75     itkGetConstMacro(LikeImage, ImagePointer);
76
77     itkSetMacro(Extrude, bool);
78     itkGetMacro(Extrude, bool);
79     itkBooleanMacro(Extrude);    
80
81   protected:
82     MeshToBinaryImageFilter();
83     virtual ~MeshToBinaryImageFilter() {}
84     
85     virtual void GenerateOutputInformation();
86     virtual void GenerateData();
87
88     bool m_Extrude;
89     ImagePointer m_LikeImage;
90     vtkSmartPointer<vtkPolyData> m_Mesh;
91
92   private:
93     MeshToBinaryImageFilter(const Self&); //purposely not implemented
94     void operator=(const Self&); //purposely not implemented
95     
96   }; // end class
97   //--------------------------------------------------------------------
98
99 } // end namespace clitk
100 //--------------------------------------------------------------------
101
102 #ifndef ITK_MANUAL_INSTANTIATION
103 #include "clitkMeshToBinaryImageFilter.txx"
104 #endif
105
106 #endif