1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
3 Main authors : XX XX XX
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
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.
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
18 =========================================================================*/
20 #include "clitkDicomRT_ROI.h"
21 #include <vtkSmartPointer.h>
22 #include <vtkAppendPolyData.h>
24 //--------------------------------------------------------------------
25 clitk::DicomRT_ROI::DicomRT_ROI()
30 mColor[0] = mColor[1] = mColor[2] = 0;
31 mMeshIsUpToDate = false;
33 //--------------------------------------------------------------------
36 //--------------------------------------------------------------------
37 clitk::DicomRT_ROI::~DicomRT_ROI()
41 //--------------------------------------------------------------------
44 //--------------------------------------------------------------------
45 void clitk::DicomRT_ROI::SetDisplayColor(double r, double v, double b)
52 //--------------------------------------------------------------------
55 //--------------------------------------------------------------------
56 int clitk::DicomRT_ROI::GetROINumber() const
60 //--------------------------------------------------------------------
63 //--------------------------------------------------------------------
64 const std::string & clitk::DicomRT_ROI::GetName() const
68 //--------------------------------------------------------------------
71 //--------------------------------------------------------------------
72 const std::string & clitk::DicomRT_ROI::GetFilename() const
76 //--------------------------------------------------------------------
79 //--------------------------------------------------------------------
80 const std::vector<double> & clitk::DicomRT_ROI::GetDisplayColor() const
84 //--------------------------------------------------------------------
87 //--------------------------------------------------------------------
88 void clitk::DicomRT_ROI::Print(std::ostream & os) const
90 os << "ROI " << mNumber << "\t" << mName
91 << "\t(" << mColor[0] << " " << mColor[1] << " " << mColor[2] << ")"
92 << "\t Contours = " << mListOfContours.size() << std::endl;
94 //--------------------------------------------------------------------
97 //--------------------------------------------------------------------
98 void clitk::DicomRT_ROI::SetBackgroundValueLabelImage(double bg)
100 mBackgroundValue = bg;
102 //--------------------------------------------------------------------
105 //--------------------------------------------------------------------
106 double clitk::DicomRT_ROI::GetBackgroundValueLabelImage() const
108 return mBackgroundValue;
110 //--------------------------------------------------------------------
113 //--------------------------------------------------------------------
114 void clitk::DicomRT_ROI::Read(std::map<int, std::string> & rois, gdcm::SQItem * item)
117 // Change number if needed
121 // ROI number [Referenced ROI Number]
122 mNumber = atoi(item->GetEntryValue(0x3006,0x0084).c_str());
125 mName = rois[mNumber];
127 // ROI Color [ROI Display Color]
128 mColor = clitk::parse_string<double>(item->GetEntryValue(0x3006,0x002a),'\\');
130 // Read contours [Contour Sequence]
131 gdcm::SeqEntry * contours=item->GetSeqEntry(0x3006,0x0040);
132 for(gdcm::SQItem* j=contours->GetFirstSQItem(); j!=0; j=contours->GetNextSQItem()) {
133 DicomRT_Contour * c = new DicomRT_Contour;
135 if (b) mListOfContours.push_back(c);
138 //--------------------------------------------------------------------
141 //--------------------------------------------------------------------
142 void clitk::DicomRT_ROI::SetImage(vvImage * image)
146 //--------------------------------------------------------------------
149 //--------------------------------------------------------------------
150 vtkPolyData * clitk::DicomRT_ROI::GetMesh()
152 if (!mMeshIsUpToDate) {
157 //--------------------------------------------------------------------
160 //--------------------------------------------------------------------
161 void clitk::DicomRT_ROI::ComputeMesh()
163 vtkAppendPolyData * append = vtkAppendPolyData::New();
164 for(unsigned int i=0; i<mListOfContours.size(); i++) {
165 append->AddInput(mListOfContours[i]->GetMesh());
168 mMesh = append->GetOutput();
169 mMeshIsUpToDate = true;
171 //--------------------------------------------------------------------
174 //--------------------------------------------------------------------
175 void clitk::DicomRT_ROI::SetFromBinaryImage(vvImage::Pointer image, int n,
177 std::vector<double> color,
178 std::string filename)
181 // ROI number [Referenced ROI Number]
186 mFilename = filename;
188 // ROI Color [ROI Display Color]
191 // No contours [Contour Sequence]
192 mListOfContours.clear();
197 //--------------------------------------------------------------------
200 //--------------------------------------------------------------------
201 const vvImage::Pointer clitk::DicomRT_ROI::GetImage() const
205 //--------------------------------------------------------------------