]> Creatis software - clitk.git/blob - common/clitkDicomRT_StructureSet.h
Update to enable GDCMv3
[clitk.git] / common / clitkDicomRT_StructureSet.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_STRUCTURESET_H
21 #define CLITKDICOMRT_STRUCTURESET_H
22
23 // clitk
24 #include "clitkCommon.h" 
25 #include "clitkDicomRT_ROI.h"
26
27 //vtk
28 #include "vtkMatrix4x4.h"
29
30 // vv
31 #include "vvImage.h"
32
33 // gdcm
34 #include "clitkConfiguration.h"
35 #if CLITK_USE_SYSTEM_GDCM == 1
36 #include <vtkGDCMPolyDataReader.h>
37 #include <vtkRTStructSetProperties.h>
38 #endif
39
40 // gdcm
41 #if GDCM_MAJOR_VERSION >= 2
42 // This is not use if CLITK_USE_SYSTEM_GDCM==1
43 #include "gdcmReader.h"
44 #include "gdcmWriter.h"
45 #include "gdcmAttribute.h"
46 #endif
47
48 namespace clitk {
49
50 //--------------------------------------------------------------------
51 class DicomRT_StructureSet : public itk::LightObject{
52   
53 public:
54   typedef DicomRT_StructureSet Self;
55   typedef itk::SmartPointer<Self> Pointer;
56   itkNewMacro(Self);
57
58   typedef std::map<int, clitk::DicomRT_ROI::Pointer> ROIMapContainer;
59   typedef ROIMapContainer::iterator ROIIteratorType;
60   typedef ROIMapContainer::const_iterator ROIConstIteratorType;
61
62   void Print(std::ostream & os = std::cout) const;
63   void Read(const std::string & filename);
64   void SetTransformMatrix(vtkMatrix4x4* matrix);
65   bool IsDicomRTStruct(const std::string & filename);
66   void Write(const std::string & filename);
67
68   clitk::DicomRT_ROI * GetROIFromROINumber(int n);
69   clitk::DicomRT_ROI* GetROIFromROIName(const std::string& name);
70   //clitk::DicomRT_ROI* GetROIFromROINameRegEx(const std::string& regEx);
71   clitk::DicomRT_ROI* GetROIFromROINameSubstr(const std::string& s);
72   ROIMapContainer * GetROIsFromROINameSubstr(const std::string& s);
73   ROIMapContainer & GetROIs() { return mROIs; }
74   const std::string & GetStudyID() const;
75   const std::string & GetStudyTime() const;
76   const std::string & GetStudyDate() const;
77   const std::string & GetLabel() const;
78   const std::string & GetName() const;
79   const std::string & GetDate() const;
80   const std::string & GetTime() const;
81
82   int AddBinaryImageAsNewROI(vvImage * i, std::string name);
83   
84 #if GDCM_MAJOR_VERSION >= 2
85   // Static
86   static int ReadROINumber(const gdcm::Item & item);
87 #endif
88
89 protected:
90   std::string mStudyID;
91   std::string mStudyTime;
92   std::string mStudyDate;
93   std::string mLabel;
94   std::string mName;
95   std::string mDate;
96   std::string mTime;
97   vtkSmartPointer<vtkMatrix4x4> mTransformMatrix;
98
99   std::map<int, clitk::DicomRT_ROI::Pointer> mROIs;
100   std::map<int, std::string> mMapOfROIName;
101 #if GDCM_MAJOR_VERSION >= 2
102   gdcm::Reader * mReader;
103   gdcm::SmartPointer<gdcm::SequenceOfItems> mROIInfoSequenceOfItems;
104   gdcm::SmartPointer<gdcm::SequenceOfItems> mROIContoursSequenceOfItems;  
105 #endif
106   gdcm::File * mFile;
107
108 private:
109   DicomRT_StructureSet();
110   ~DicomRT_StructureSet();
111 };
112 //--------------------------------------------------------------------
113
114 } // end namespace clitk
115 #endif // CLITKDICOMRT_STRUCTURESET_H
116