]> Creatis software - clitk.git/blob - common/clitkDicomRT_ROI.h
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
[clitk.git] / common / clitkDicomRT_ROI.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 CLITKDICOMRT_ROI_H
21 #define CLITKDICOMRT_ROI_H
22
23 #include "clitkDicomRT_Contour.h"
24 #include "vvImage.h"
25
26 #include "clitkConfiguration.h"
27 #if CLITK_USE_SYSTEM_GDCM == 1
28 #include <vtkGDCMPolyDataReader.h>
29 #include <vtkRTStructSetProperties.h>
30 #endif
31
32 namespace clitk {
33
34 //--------------------------------------------------------------------
35 class DicomRT_ROI : public itk::LightObject
36 {
37   
38 public:
39   typedef DicomRT_ROI Self;
40   typedef itk::SmartPointer<Self> Pointer;
41   itkNewMacro(Self);
42
43   void Print(std::ostream & os = std::cout) const;
44   void SetFromBinaryImage(vvImage::Pointer image, int n, 
45         std::string name, 
46         std::vector<double> color, 
47         std::string filename);
48
49   int GetROINumber() const;
50   void SetROINumber(int);
51   const std::string & GetName() const;
52   const std::string & GetFilename() const;
53   const std::vector<double> & GetDisplayColor() const;
54   vtkPolyData * GetMesh();
55   vvImage * GetImage() const;
56
57   void SetDisplayColor(double r, double v, double b);
58   std::vector<double> & GetDisplayColor() { return mColor; }
59   
60   double GetBackgroundValueLabelImage() const;
61   void SetBackgroundValueLabelImage(double bg);
62   
63   double GetForegroundValueLabelImage() const;
64   void SetForegroundValueLabelImage(double bg);
65   
66   void SetImage(vvImage::Pointer im);
67   DicomRT_Contour* GetContour(int n);
68
69   // Compute a vtk mesh from the dicom contours
70   void ComputeMeshFromContour();
71   void ComputeContoursFromImage();
72   
73   // Indicate if the mesh is uptodate according to the dicom
74   void SetDicomUptodateFlag(bool b) { m_DicomUptodateFlag = b; }
75   bool GetDicomUptoDateFlag() const { return m_DicomUptodateFlag; }
76   void SetName(std::string n) { mName = n; }
77
78   // Read from DICOM RT STRUCT
79 #if GDCM_MAJOR_VERSION == 2
80   bool Read(gdcm::Item * itemInfo, gdcm::Item * itemContour);
81   void UpdateDicomItem();
82 #else
83   void Read(std::map<int, std::string> & rois, gdcm::SQItem * item);
84 #endif
85
86 #if CLITK_USE_SYSTEM_GDCM == 1
87   void Read(vtkSmartPointer<vtkGDCMPolyDataReader> & reader, int roiindex);
88 #endif
89
90 protected:
91   std::string mName;
92   std::string mFilename;
93   int mNumber;
94   std::vector<double> mColor;
95   std::vector<DicomRT_Contour::Pointer> mListOfContours;
96   vtkSmartPointer<vtkPolyData> mMesh;
97   bool mMeshIsUpToDate;
98   vvImage::Pointer mImage;
99   double mBackgroundValue;
100   double mForegroundValue;
101   bool m_DicomUptodateFlag;
102
103 #if GDCM_MAJOR_VERSION == 2
104   gdcm::Item * mItemInfo;
105   gdcm::Item * mItemContour;
106   gdcm::SmartPointer<gdcm::SequenceOfItems> mContoursSequenceOfItems;
107 #endif
108
109 private:
110   DicomRT_ROI();
111   ~DicomRT_ROI();
112 };
113 //--------------------------------------------------------------------
114
115 } // end namespace clitk
116 #endif // CLITKDICOMRT_ROI_H
117