]> Creatis software - clitk.git/blob - common/clitkDicomRTStruct2ImageFilter.h
Merge branch 'master' into OpenGL2
[clitk.git] / common / clitkDicomRTStruct2ImageFilter.h
1 /*=========================================================================
2   Program:         vv http://www.creatis.insa-lyon.fr/rio/vv
3   Main authors :   XX XX XX
4
5   Authors belongs to: 
6   - University of LYON           http://www.universite-lyon.fr/
7   - Léon Bérard cancer center    http://www.centreleonberard.fr
8   - CREATIS CNRS laboratory      http://www.creatis.insa-lyon.fr
9
10   This software is distributed WITHOUT ANY WARRANTY; without even
11   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12   PURPOSE.  See the copyright notices for more information.
13
14   It is distributed under dual licence
15   - BSD       http://www.opensource.org/licenses/bsd-license.php
16   - CeCILL-B  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17
18   =========================================================================*/
19
20 #ifndef CLITKDICOMRTSTRUCT2IMAGEFILTER_H
21 #define CLITKDICOMRTSTRUCT2IMAGEFILTER_H
22
23 #include "clitkDicomRT_ROI.h"
24 #include "clitkImageCommon.h"
25 #include <vtkImageData.h>
26 #include <itkImage.h>
27 #include <itkVTKImageToImageFilter.h>
28
29 namespace clitk {
30
31   //--------------------------------------------------------------------
32   class DicomRTStruct2ImageFilter {
33     
34   public:
35     DicomRTStruct2ImageFilter();
36     ~DicomRTStruct2ImageFilter();
37
38     void SetROI(clitk::DicomRT_ROI * roi);
39     ///This is used to create a mask with the same characteristics as an input image
40     void SetImage(vvImage::Pointer image);
41     void SetImageFilename(std::string s);
42     void SetOutputOrigin(const double* origin);
43     void SetOutputSpacing(const double* spacing);
44     void SetOutputSize(const unsigned long* size);
45     void SetOutputImageFilename(std::string s);
46     void Update();    
47     vtkImageData * GetOutput();
48     template <int Dimension> typename itk::Image<unsigned char,Dimension>::ConstPointer GetITKOutput();
49     void SetCropMaskEnabled(bool b);
50     void SetWriteOutputFlag(bool b);
51
52   protected:
53     bool ImageInfoIsSet() const;
54     bool mWriteOutput;
55     bool mCropMask;
56     std::string mOutputFilename;
57     std::vector<double> mSpacing;
58     std::vector<double> mOrigin;
59     std::vector<unsigned long> mSize;
60     clitk::DicomRT_ROI * mROI;
61     vtkSmartPointer<vtkImageData> mBinaryImage;
62   };
63   //--------------------------------------------------------------------
64
65 } // end namespace clitk
66
67
68 //--------------------------------------------------------------------
69
70 template <int Dimension> 
71 typename itk::Image<unsigned char,Dimension>::ConstPointer clitk::DicomRTStruct2ImageFilter::GetITKOutput()
72 {
73   assert(mBinaryImage);
74   typedef itk::Image<unsigned char,Dimension> ConnectorImageType;
75   typedef itk::VTKImageToImageFilter <ConnectorImageType> ConnectorType;
76   typename ConnectorType::Pointer connector = ConnectorType::New();
77   connector->SetInput(mBinaryImage);
78   connector->Update();
79   return connector->GetOutput();
80 }
81 //--------------------------------------------------------------------
82 #endif // CLITKDICOMRT_TRUCT2IMAGEFILTER_H
83