]> Creatis software - clitk.git/blob - common/clitkDicomRT_ROI.h
Debug try with ImageReslice update and autoCrop
[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   const std::string & GetName() const;
51   const std::string & GetFilename() const;
52   const std::vector<double> & GetDisplayColor() const;
53   vtkPolyData * GetMesh();
54   vvImage * GetImage() const;
55
56   void SetDisplayColor(double r, double v, double b);
57   std::vector<double> & GetDisplayColor() { return mColor; }
58   
59   double GetBackgroundValueLabelImage() const;
60   void SetBackgroundValueLabelImage(double bg);
61   
62   double GetForegroundValueLabelImage() const;
63   void SetForegroundValueLabelImage(double bg);
64   
65   void SetImage(vvImage::Pointer im);
66   DicomRT_Contour* GetContour(int n);
67
68   // Compute a vtk mesh from the dicom contours
69   void ComputeMeshFromContour();
70   void ComputeContoursFromImage();
71   
72   // Indicate if the mesh is uptodate according to the dicom
73   void SetDicomUptodateFlag(bool b) { m_DicomUptodateFlag = b; }
74   bool GetDicomUptoDateFlag() const { return m_DicomUptodateFlag; }
75   void SetName(std::string n) { mName = n; }
76
77   // Read from DICOM RT STRUCT
78 #if GDCM_MAJOR_VERSION == 2
79   bool Read(gdcm::Item * itemInfo, gdcm::Item * itemContour);
80   void UpdateDicomItem();
81 #else
82   void Read(std::map<int, std::string> & rois, gdcm::SQItem * item);
83 #endif
84
85 #if CLITK_USE_SYSTEM_GDCM == 1
86   void Read(vtkSmartPointer<vtkGDCMPolyDataReader> & reader, int roiindex);
87 #endif
88
89 protected:
90   std::string mName;
91   std::string mFilename;
92   int mNumber;
93   std::vector<double> mColor;
94   std::vector<DicomRT_Contour::Pointer> mListOfContours;
95   vtkSmartPointer<vtkPolyData> mMesh;
96   bool mMeshIsUpToDate;
97   vvImage::Pointer mImage;
98   double mBackgroundValue;
99   double mForegroundValue;
100   bool m_DicomUptodateFlag;
101
102 #if GDCM_MAJOR_VERSION == 2
103   gdcm::Item * mItemInfo;
104   gdcm::Item * mItemContour;
105   gdcm::SmartPointer<gdcm::SequenceOfItems> mContoursSequenceOfItems;
106 #endif
107
108 private:
109   DicomRT_ROI();
110   ~DicomRT_ROI();
111 };
112 //--------------------------------------------------------------------
113
114 } // end namespace clitk
115 #endif // CLITKDICOMRT_ROI_H
116