annotate OrthancStone/Sources/Scene2D/MacroSceneLayer.cpp @ 1802:757987cb5a68

recycling of layers in MacroSceneLayer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 20 May 2021 13:58:26 +0200
parents 013dec434a84
children 3889ae96d2e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1739
9ac2a65d4172 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Lesser General Public License for more details.
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * License along with this program. If not, see
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * <http://www.gnu.org/licenses/>.
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "MacroSceneLayer.h"
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include <OrthancException.h>
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
27 #include <cassert>
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
28
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 namespace OrthancStone
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
31 void MacroSceneLayer::CheckInvariant() const
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
32 {
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
33 #if !defined(NDEBUG)
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
34 // Only run the sanity check in debug mode
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
35 size_t countRecycled = 0;
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
36
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
37 for (size_t i = 0; i < layers_.size(); i++)
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
38 {
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
39 if (layers_[i] == NULL)
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
40 {
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
41 assert(recycledLayers_.find(i) != recycledLayers_.end());
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
42 countRecycled++;
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
43 }
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
44 else
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
45 {
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
46 assert(recycledLayers_.find(i) == recycledLayers_.end());
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
47 }
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
48 }
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
49
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
50 assert(countRecycled == recycledLayers_.size());
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
51 #endif
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
52 }
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
53
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
54
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 void MacroSceneLayer::Clear()
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
57 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
58
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 for (size_t i = 0; i < layers_.size(); i++)
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
61 if (layers_[i] != NULL)
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
62 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
63 delete layers_[i];
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
64 }
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 layers_.clear();
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
68 recycledLayers_.clear();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
69
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 BumpRevision();
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
1793
c5e6379b9cd0 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
74 size_t MacroSceneLayer::AddLayer(ISceneLayer* layer)
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
76 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
77
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 if (layer == NULL)
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 {
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 else
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
84 size_t index;
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
85
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
86 if (recycledLayers_.empty())
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
87 {
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
88 index = layers_.size();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
89 layers_.push_back(layer);
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
90 }
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
91 else
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
92 {
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
93 index = *recycledLayers_.begin();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
94 assert(layers_[index] == NULL);
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
95 layers_[index] = layer;
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
96 recycledLayers_.erase(index);
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
97 }
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
98
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 BumpRevision();
1793
c5e6379b9cd0 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
100 return index;
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
1796
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
105 void MacroSceneLayer::UpdateLayer(size_t index,
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
106 ISceneLayer* layer)
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
107 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
108 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
109
1796
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
110 if (layer == NULL)
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
111 {
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
112 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
113 }
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
114 else if (index >= layers_.size())
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
115 {
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
116 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
117 }
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
118 else
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
119 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
120 if (layers_[index] == NULL)
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
121 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
122 assert(recycledLayers_.find(index) != recycledLayers_.end());
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
123 recycledLayers_.erase(index);
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
124 }
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
125 else
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
126 {
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
127 assert(recycledLayers_.find(index) == recycledLayers_.end());
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
128 delete layers_[index];
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
129 }
1796
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
130
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
131 layers_[index] = layer;
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
132 BumpRevision();
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
133 }
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
134 }
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
135
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
136
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
137 bool MacroSceneLayer::HasLayer(size_t index) const
1611
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
138 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
139 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
140
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
141 if (index >= layers_.size())
1611
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
142 {
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
143 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
144 }
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
145 else
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
146 {
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
147 return (layers_[index] != NULL);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
148 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
149 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
150
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
151
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
152 void MacroSceneLayer::DeleteLayer(size_t index)
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
153 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
154 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
155
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
156 if (index >= layers_.size())
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
157 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
158 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
159 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
160 else if (layers_[index] == NULL)
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
161 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
162 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentItem);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
163 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
164 else
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
165 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
166 delete layers_[index];
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
167 layers_[index] = NULL;
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
168
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
169 assert(recycledLayers_.find(index) == recycledLayers_.end());
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
170 recycledLayers_.insert(index);
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
171 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
172 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
173
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
174
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
175 const ISceneLayer& MacroSceneLayer::GetLayer(size_t index) const
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
176 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
177 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
178
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
179 if (index >= layers_.size())
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
180 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
181 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
182 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
183 else if (layers_[index] == NULL)
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
184 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
185 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentItem);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
186 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
187 else
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
188 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
189 return *layers_[index];
1611
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
190 }
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
191 }
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
192
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
193
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 ISceneLayer* MacroSceneLayer::Clone() const
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
196 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
197
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 std::unique_ptr<MacroSceneLayer> copy(new MacroSceneLayer);
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 for (size_t i = 0; i < layers_.size(); i++)
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 {
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
202 if (layers_[i] == NULL)
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
203 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
204 copy->layers_.push_back(NULL);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
205 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
206 else
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
207 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
208 copy->layers_.push_back(layers_[i]->Clone());
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
209 }
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
212 copy->recycledLayers_ = recycledLayers_;
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
213
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 return copy.release();
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217
1610
b7630b1a0253 ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
218 void MacroSceneLayer::GetBoundingBox(Extent2D& target) const
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
220 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
221
1610
b7630b1a0253 ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
222 target.Clear();
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 for (size_t i = 0; i < layers_.size(); i++)
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 {
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
226 if (layers_[i] != NULL)
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
227 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
228 Extent2D subextent;
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
229 layers_[i]->GetBoundingBox(subextent);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
230 target.Union(subextent);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
231 }
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 }