]> Creatis software - clitk.git/blob - vv/vvStructureSetActor.cxx
Debug RTStruct conversion with empty struc
[clitk.git] / vv / vvStructureSetActor.cxx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18
19 #include "vvStructureSetActor.h"
20 #include "vvROIActor.h"
21
22 //------------------------------------------------------------------------------
23 vvStructureSetActor::vvStructureSetActor()
24 {
25
26 }
27 //------------------------------------------------------------------------------
28
29
30 //------------------------------------------------------------------------------
31 vvStructureSetActor::~vvStructureSetActor()
32 {
33
34 }
35 //------------------------------------------------------------------------------
36
37
38 //------------------------------------------------------------------------------
39 int vvStructureSetActor::GetNumberOfROIs() 
40
41   return mROIActors.size(); 
42 }
43 //------------------------------------------------------------------------------
44
45
46 //------------------------------------------------------------------------------
47 std::vector< QSharedPointer<vvROIActor> > & vvStructureSetActor::GetROIList() 
48
49   return mROIActors; 
50 }
51 //------------------------------------------------------------------------------
52
53
54 //------------------------------------------------------------------------------
55 void vvStructureSetActor::SetStructureSet(clitk::DicomRT_StructureSet * s)
56 {
57   mStructureSet = s;
58 }
59 //------------------------------------------------------------------------------
60
61
62 //------------------------------------------------------------------------------
63 void vvStructureSetActor::SetSlicerManager(vvSlicerManager * s)
64 {
65   mSlicerManager = s;
66 }
67 //------------------------------------------------------------------------------
68
69
70 //------------------------------------------------------------------------------
71 vvROIActor * vvStructureSetActor::GetROIActor(int n)
72 {
73   if (mMapROIIndex.find(n) == mMapROIIndex.end()) {
74     std::cerr << "No ROI number " << n << std::endl;
75     return NULL;
76   }
77   return mROIActors[mMapROIIndex[n]].data();
78 }
79 //------------------------------------------------------------------------------
80
81
82 //------------------------------------------------------------------------------
83 void vvStructureSetActor::CreateNewROIActor(int n, bool modeBG)
84 {
85   // Check
86   clitk::DicomRT_ROI * roi = mStructureSet->GetROIFromROINumber(n);
87   if (roi == NULL) {
88     std::cerr << "Error. No ROI number " << n << std::endl;
89     exit(0);
90   }
91
92   // If already exist : delete it
93   int old = -1;
94   if (mMapROIIndex.find(n) != mMapROIIndex.end())
95     old = mMapROIIndex[n];
96
97   // Add ROI Actors
98   QSharedPointer<vvROIActor> actor = QSharedPointer<vvROIActor>(new vvROIActor);
99   if (old == -1)
100     mROIActors.push_back(actor);
101   else
102     mROIActors[old] = actor;
103   actor->SetBGMode(modeBG);
104   actor->SetROI(roi);
105   actor->SetSlicerManager(mSlicerManager);
106   actor->Initialize(n+1); // depth is n+1 to start at 1
107   mMapROIIndex[n] = mROIActors.size()-1;
108 }
109 //------------------------------------------------------------------------------
110
111