]> Creatis software - clitk.git/blob - tools/clitkDicomRT_ROI.cxx
[BUG] Change to signed distance.
[clitk.git] / tools / clitkDicomRT_ROI.cxx
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://oncora1.lyon.fnclcc.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 #include "clitkDicomRT_ROI.h" 
21 #include <vtkSmartPointer.h>
22 #include <vtkAppendPolyData.h>
23
24 //--------------------------------------------------------------------
25 clitk::DicomRT_ROI::DicomRT_ROI() {
26   mName = "NoName";
27   mNumber = -1;
28   mColor.resize(3);
29   mColor[0] = mColor[1] = mColor[2] = 0;
30   mMeshIsUpToDate = false;
31 }
32 //--------------------------------------------------------------------
33
34
35 //--------------------------------------------------------------------
36 clitk::DicomRT_ROI::~DicomRT_ROI() {
37   
38 }
39 //--------------------------------------------------------------------
40
41
42 //--------------------------------------------------------------------
43 int clitk::DicomRT_ROI::GetROINumber() const {
44   return mNumber;
45 }
46 //--------------------------------------------------------------------
47
48
49 //--------------------------------------------------------------------
50 const std::string & clitk::DicomRT_ROI::GetName() const {
51   return mName;
52 }
53 //--------------------------------------------------------------------
54
55
56 //--------------------------------------------------------------------
57 const std::vector<double> & clitk::DicomRT_ROI::GetDisplayColor() const {
58   return mColor;
59 }
60 //--------------------------------------------------------------------
61
62
63  
64 //--------------------------------------------------------------------
65 void clitk::DicomRT_ROI::Print(std::ostream & os) const {
66   os << "ROI " << mNumber << "\t" << mName 
67      << "\t(" << mColor[0] << " " << mColor[1] << " " << mColor[2] << ")"
68      << "\t Contours = " << mListOfContours.size() << std::endl;
69 }
70 //--------------------------------------------------------------------
71
72
73 //--------------------------------------------------------------------
74 void clitk::DicomRT_ROI::Read(std::map<int, std::string> & rois, gdcm::SQItem * item) {
75   
76   // ROI number [Referenced ROI Number]
77   mNumber = atoi(item->GetEntryValue(0x3006,0x0084).c_str());
78   
79   // Retrieve ROI Name
80   mName = rois[mNumber];
81
82   // ROI Color [ROI Display Color]
83   mColor = clitk::parse_string<double>(item->GetEntryValue(0x3006,0x002a),'\\');
84
85   // Read contours [Contour Sequence]
86   gdcm::SeqEntry * contours=item->GetSeqEntry(0x3006,0x0040);
87   for(gdcm::SQItem* j=contours->GetFirstSQItem();j!=0;j=contours->GetNextSQItem()) {
88     DicomRT_Contour * c = new DicomRT_Contour;    
89     bool b = c->Read(j);
90     if (b) mListOfContours.push_back(c);
91   }
92 }
93 //--------------------------------------------------------------------
94
95
96 //--------------------------------------------------------------------
97 vtkPolyData * clitk::DicomRT_ROI::GetMesh() {
98   if (!mMeshIsUpToDate) {
99     ComputeMesh();
100   }
101   return mMesh;
102 }
103 //--------------------------------------------------------------------
104
105
106 //--------------------------------------------------------------------
107 void clitk::DicomRT_ROI::ComputeMesh() {
108   vtkAppendPolyData * append = vtkAppendPolyData::New();
109   for(unsigned int i=0; i<mListOfContours.size(); i++) {
110     append->AddInput(mListOfContours[i]->GetMesh());
111   }
112   append->Update();
113   mMesh = append->GetOutput();
114   mMeshIsUpToDate = true;
115 }
116 //--------------------------------------------------------------------
117