]> Creatis software - clitk.git/blob - common/clitkDicomRTStruct2ImageFilter.h
motion masks with and without bands
[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 CLITKDICOMRT_TRUCT2IMAGEFILTER_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 SetImageFilename(std::string s);
41     void SetOutputOrigin(const double* origin);
42     void SetOutputSpacing(const double* spacing);
43     void SetOutputSize(const unsigned long* size);
44     void SetOutputImageFilename(std::string s);
45     void Update();    
46     vtkImageData * GetOutput();
47     template <int Dimension> typename itk::Image<unsigned char,Dimension>::ConstPointer GetITKOutput();
48     void SetCropMaskEnabled(bool b);
49
50   protected:
51     bool ImageInfoIsSet() const;
52     bool mWriteOutput;
53     bool mCropMask;
54     std::string mOutputFilename;
55     std::vector<double> mSpacing;
56     std::vector<double> mOrigin;
57     std::vector<unsigned long> mSize;
58     clitk::DicomRT_ROI * mROI;
59     vtkSmartPointer<vtkImageData> mBinaryImage;
60   };
61   //--------------------------------------------------------------------
62
63 } // end namespace clitk
64
65
66 //--------------------------------------------------------------------
67
68 template <int Dimension> 
69 typename itk::Image<unsigned char,Dimension>::ConstPointer clitk::DicomRTStruct2ImageFilter::GetITKOutput()
70 {
71   assert(mBinaryImage);
72   typedef itk::Image<unsigned char,Dimension> ConnectorImageType;
73   typedef itk::VTKImageToImageFilter <ConnectorImageType> ConnectorType;
74   typename ConnectorType::Pointer connector = ConnectorType::New();
75   connector->SetInput(mBinaryImage);
76   connector->Update();
77   return connector->GetOutput();
78 }
79 //--------------------------------------------------------------------
80 #endif // CLITKDICOMRT_TRUCT2IMAGEFILTER_H
81