]> Creatis software - clitk.git/blob - itk/clitkBinaryImageToMeshFilter.h
First version to convert image to dicomrtstruct
[clitk.git] / itk / clitkBinaryImageToMeshFilter.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 CLITKBINARYIMAGETOMESHFILTER_H
20 #define CLITKMESHTOBINARYIMAGEFILTER_H
21
22 // clitk
23 #include "clitkCommon.h"
24 #include "vvFromITK.h"
25
26 // itk
27 #include <itkProcessObject.h>
28
29 // vtk
30 #include <vtkSmartPointer.h>
31 #include <vtkPolyData.h>
32 #include <vtkImageClip.h>
33 #include <vtkMarchingSquares.h>
34 #include <vtkAppendPolyData.h>
35 #include <vtkDecimatePro.h>
36 #include <vtkStripper.h>
37
38 namespace clitk {
39     
40   /* --------------------------------------------------------------------     
41      Convert a 3D binary image into a list of 2D contours (vtkpolydata)
42      -------------------------------------------------------------------- */
43   
44   template<class ImageType>
45   class ITK_EXPORT BinaryImageToMeshFilter:public itk::Object //:public clitk::FilterBase
46   {
47
48   public:
49     /** Standard class typedefs. */
50     //    typedef itk::ImageToMeshFilter<ImageType, vtkPolyData>   Superclass;
51     typedef itk::ProcessObject   Superclass;
52     typedef BinaryImageToMeshFilter       Self;
53     typedef itk::SmartPointer<Self>       Pointer;
54     typedef itk::SmartPointer<const Self> ConstPointer;
55        
56     /** Method for creation through the object factory. */
57     itkNewMacro(Self);
58  
59     /** Run-time type information (and related methods). */
60     itkTypeMacro(BinaryImageToMeshFilter, Superclass);
61
62     /** ImageDimension constants */
63     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
64
65     // /** Some convenient typedefs. */
66     // typedef typename ImageType::ConstPointer ImageConstPointer;
67     typedef typename ImageType::Pointer      ImagePointer;
68     // typedef typename ImageType::RegionType   RegionType; 
69     typedef typename ImageType::PixelType    PixelType;
70     // typedef typename ImageType::SpacingType  SpacingType;
71     // typedef typename ImageType::SizeType     SizeType;
72     // typedef typename ImageType::PointType    PointType;
73     //typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
74     //    typedef vtkSmartPointer<vtkPolyData> DataObjectPointer;
75
76     //    using Superclass::SetInput;
77     // void SetInput(unsigned int idx, const ImageType *input);
78     // void SetInput(const ImageType *input)
79     // {
80     //   m_this->SetInput(0, input);
81     // }
82     
83     // const ImageType * GetInput(unsigned int idx);
84     // const ImageType * GetInput()
85     // {
86     //   return this->GetInput(0);
87     // }
88     
89     //virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx);
90     //    virtual void GenerateData();
91     //    virtual void GenerateOutputInformation();
92
93     /** Input : initial image and object */
94     // itkSetMacro(Mesh, vtkSmartPointer<vtkPolyData>);
95     // itkGetConstMacro(Mesh, vtkSmartPointer<vtkPolyData>);
96
97     // itkSetMacro(LikeImage, ImagePointer);
98     // itkGetConstMacro(LikeImage, ImagePointer);
99
100     // itkSetMacro(Extrude, bool);
101     // itkGetMacro(Extrude, bool);
102     // itkBooleanMacro(Extrude);    
103     itkSetMacro(Input, ImagePointer);
104     itkGetConstMacro(Input, ImagePointer);
105     itkGetMacro(OutputMesh, vtkSmartPointer<vtkPolyData>);
106
107     // virtual void GenerateOutputInformation();
108     virtual void Update();
109
110   protected:
111     BinaryImageToMeshFilter();
112     virtual ~BinaryImageToMeshFilter() {}
113     
114     ImagePointer m_Input;
115     vtkSmartPointer<vtkPolyData> m_OutputMesh;
116
117   private:
118     BinaryImageToMeshFilter(const Self&); //purposely not implemented
119     void operator=(const Self&); //purposely not implemented
120     
121   }; // end class
122   //--------------------------------------------------------------------
123
124 } // end namespace clitk
125 //--------------------------------------------------------------------
126
127 #ifndef ITK_MANUAL_INSTANTIATION
128 #include "clitkBinaryImageToMeshFilter.txx"
129 #endif
130
131 #endif