]> Creatis software - clitk.git/blob - common/clitkDicomRTStruct2ImageFilter.h
Merge branch 'master' of git://git.creatis.insa-lyon.fr/clitk
[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 <vtkMatrix4x4.h>
27 #include <itkImage.h>
28 #include <itkVTKImageToImageFilter.h>
29
30 namespace clitk {
31
32   //--------------------------------------------------------------------
33   class DicomRTStruct2ImageFilter {
34     
35   public:
36     DicomRTStruct2ImageFilter();
37     ~DicomRTStruct2ImageFilter();
38
39     void SetROI(clitk::DicomRT_ROI * roi);
40     ///This is used to create a mask with the same characteristics as an input image
41     void SetImage(vvImage::Pointer image);
42     void SetImageFilename(std::string s);
43     void SetOutputOrigin(const double* origin);
44     void SetOutputSpacing(const double* spacing);
45     void SetOutputSize(const unsigned long* size);
46     void SetOutputImageFilename(std::string s);
47     void Update();    
48     vtkImageData * GetOutput();
49     template <int Dimension> typename itk::Image<unsigned char,Dimension>::ConstPointer GetITKOutput();
50     void SetCropMaskEnabled(bool b);
51     void SetWriteOutputFlag(bool b);
52
53   protected:
54     bool ImageInfoIsSet() const;
55     bool mWriteOutput;
56     bool mCropMask;
57     std::string mOutputFilename;
58     std::vector<double> mSpacing;
59     std::vector<double> mOrigin;
60     std::vector<unsigned long> mSize;
61     std::vector< std::vector< double> > mDirection;
62     vtkSmartPointer<vtkMatrix4x4> mTransformMatrix;
63     clitk::DicomRT_ROI * mROI;
64     vtkSmartPointer<vtkImageData> mBinaryImage;
65   };
66   //--------------------------------------------------------------------
67
68 } // end namespace clitk
69
70
71 //--------------------------------------------------------------------
72
73 template <int Dimension> 
74 typename itk::Image<unsigned char,Dimension>::ConstPointer clitk::DicomRTStruct2ImageFilter::GetITKOutput()
75 {
76   assert(mBinaryImage);
77   typedef itk::Image<unsigned char,Dimension> ConnectorImageType;
78   typedef itk::VTKImageToImageFilter <ConnectorImageType> ConnectorType;
79   typename ConnectorType::Pointer connector = ConnectorType::New();
80   connector->SetInput(mBinaryImage);
81   connector->Update();
82   return connector->GetOutput();
83 }
84 //--------------------------------------------------------------------
85 #endif // CLITKDICOMRT_TRUCT2IMAGEFILTER_H
86