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() {
29 mColor[0] = mColor[1] = mColor[2] = 0;
30 mMeshIsUpToDate = false;
32 //--------------------------------------------------------------------
35 //--------------------------------------------------------------------
36 clitk::DicomRT_ROI::~DicomRT_ROI() {
39 //--------------------------------------------------------------------
42 //--------------------------------------------------------------------
43 void clitk::DicomRT_ROI::SetDisplayColor(double r, double v, double b) {
49 //--------------------------------------------------------------------
52 //--------------------------------------------------------------------
53 int clitk::DicomRT_ROI::GetROINumber() const {
56 //--------------------------------------------------------------------
59 //--------------------------------------------------------------------
60 const std::string & clitk::DicomRT_ROI::GetName() const {
63 //--------------------------------------------------------------------
66 //--------------------------------------------------------------------
67 const std::vector<double> & clitk::DicomRT_ROI::GetDisplayColor() const {
70 //--------------------------------------------------------------------
74 //--------------------------------------------------------------------
75 void clitk::DicomRT_ROI::Print(std::ostream & os) const {
76 os << "ROI " << mNumber << "\t" << mName
77 << "\t(" << mColor[0] << " " << mColor[1] << " " << mColor[2] << ")"
78 << "\t Contours = " << mListOfContours.size() << std::endl;
80 //--------------------------------------------------------------------
83 //--------------------------------------------------------------------
84 void clitk::DicomRT_ROI::Read(std::map<int, std::string> & rois, gdcm::SQItem * item) {
86 // Change number if needed
90 // ROI number [Referenced ROI Number]
91 mNumber = atoi(item->GetEntryValue(0x3006,0x0084).c_str());
94 mName = rois[mNumber];
96 // ROI Color [ROI Display Color]
97 mColor = clitk::parse_string<double>(item->GetEntryValue(0x3006,0x002a),'\\');
99 // Read contours [Contour Sequence]
100 gdcm::SeqEntry * contours=item->GetSeqEntry(0x3006,0x0040);
101 for(gdcm::SQItem* j=contours->GetFirstSQItem();j!=0;j=contours->GetNextSQItem()) {
102 DicomRT_Contour * c = new DicomRT_Contour;
104 if (b) mListOfContours.push_back(c);
107 //--------------------------------------------------------------------
110 //--------------------------------------------------------------------
111 vtkPolyData * clitk::DicomRT_ROI::GetMesh() {
112 if (!mMeshIsUpToDate) {
117 //--------------------------------------------------------------------
120 //--------------------------------------------------------------------
121 void clitk::DicomRT_ROI::ComputeMesh() {
122 vtkAppendPolyData * append = vtkAppendPolyData::New();
123 for(unsigned int i=0; i<mListOfContours.size(); i++) {
124 append->AddInput(mListOfContours[i]->GetMesh());
127 mMesh = append->GetOutput();
128 mMeshIsUpToDate = true;
130 //--------------------------------------------------------------------
133 //--------------------------------------------------------------------
134 void clitk::DicomRT_ROI::SetFromBinaryImage(vvImage::Pointer image, int n,
136 std::vector<double> color) {
138 // ROI number [Referenced ROI Number]
144 // ROI Color [ROI Display Color]
147 // No contours [Contour Sequence]
148 mListOfContours.clear();
153 //--------------------------------------------------------------------
156 //--------------------------------------------------------------------
157 const vvImage::Pointer clitk::DicomRT_ROI::GetImage() const {
160 //--------------------------------------------------------------------