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