comparison OrthancStone/Sources/Toolbox/SortedFrames.cpp @ 1600:b253b79906fa

clarifying variable names: frameIndex vs numberIndex
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 28 Oct 2020 15:23:26 +0100
parents 73cd85d7da6a
children b2941196cabf
comparison
equal deleted inserted replaced
1599:73cd85d7da6a 1600:b253b79906fa
91 } 91 }
92 } 92 }
93 93
94 94
95 SortedFrames::Frame::Frame(const Instance& instance, 95 SortedFrames::Frame::Frame(const Instance& instance,
96 unsigned int frameIndex) : 96 unsigned int frameNumber) :
97 instance_(&instance), 97 instance_(&instance),
98 frameIndex_(frameIndex) 98 frameNumber_(frameNumber)
99 { 99 {
100 if (frameIndex >= instance.GetNumberOfFrames()) 100 if (frameNumber >= instance.GetNumberOfFrames())
101 { 101 {
102 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 102 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
103 } 103 }
104 } 104 }
105 105
106 106
107 const SortedFrames::Instance& SortedFrames::GetInstance(size_t index) const 107 const SortedFrames::Instance& SortedFrames::GetInstance(size_t instanceIndex) const
108 { 108 {
109 if (index >= instances_.size()) 109 if (instanceIndex >= instances_.size())
110 { 110 {
111 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 111 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
112 } 112 }
113 else 113 else
114 { 114 {
115 assert(instances_[index] != NULL); 115 assert(instances_[instanceIndex] != NULL);
116 return *instances_[index]; 116 return *instances_[instanceIndex];
117 } 117 }
118 } 118 }
119 119
120 120
121 const SortedFrames::Frame& SortedFrames::GetFrame(size_t index) const 121 const SortedFrames::Frame& SortedFrames::GetFrame(size_t frameIndex) const
122 { 122 {
123 if (!sorted_) 123 if (!sorted_)
124 { 124 {
125 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls, 125 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls,
126 "Sort() has not been called"); 126 "Sort() has not been called");
127 } 127 }
128 if (index >= frames_.size()) 128 if (frameIndex >= frames_.size())
129 { 129 {
130 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 130 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
131 } 131 }
132 else 132 else
133 { 133 {
134 return frames_[index]; 134 return frames_[frameIndex];
135 } 135 }
136 } 136 }
137 137
138 138
139 void SortedFrames::Clear() 139 void SortedFrames::Clear()
209 } 209 }
210 } 210 }
211 211
212 212
213 void SortedFrames::AddFramesOfInstance(std::set<size_t>& remainingInstances, 213 void SortedFrames::AddFramesOfInstance(std::set<size_t>& remainingInstances,
214 size_t index) 214 size_t instanceIndex)
215 { 215 {
216 assert(instances_[index] != NULL); 216 assert(instances_[instanceIndex] != NULL);
217 const Instance& instance = *instances_[index]; 217 const Instance& instance = *instances_[instanceIndex];
218 218
219 for (unsigned int i = 0; i < instance.GetNumberOfFrames(); i++) 219 for (unsigned int i = 0; i < instance.GetNumberOfFrames(); i++)
220 { 220 {
221 frames_.push_back(Frame(instance, i)); 221 frames_.push_back(Frame(instance, i));
222 } 222 }
223 223
224 assert(remainingInstances.find(index) != remainingInstances.end()); 224 assert(remainingInstances.find(instanceIndex) != remainingInstances.end());
225 remainingInstances.erase(index); 225 remainingInstances.erase(instanceIndex);
226 } 226 }
227 227
228 228
229 namespace 229 namespace
230 { 230 {
231 template<typename T> 231 template<typename T>
232 class SortableItem 232 class SortableItem
233 { 233 {
234 private: 234 private:
235 T value_; 235 T value_;
236 size_t instance_; 236 size_t instanceIndex_;
237 std::string sopInstanceUid_; 237 std::string sopInstanceUid_;
238 238
239 public: 239 public:
240 SortableItem(const T& value, 240 SortableItem(const T& value,
241 size_t instance, 241 size_t instanceIndex,
242 const std::string& sopInstanceUid) : 242 const std::string& sopInstanceUid) :
243 value_(value), 243 value_(value),
244 instance_(instance), 244 instanceIndex_(instanceIndex),
245 sopInstanceUid_(sopInstanceUid) 245 sopInstanceUid_(sopInstanceUid)
246 { 246 {
247 } 247 }
248 248
249 size_t GetInstanceIndex() const 249 size_t GetInstanceIndex() const
250 { 250 {
251 return instance_; 251 return instanceIndex_;
252 } 252 }
253 253
254 bool operator< (const SortableItem& other) const 254 bool operator< (const SortableItem& other) const
255 { 255 {
256 return (value_ < other.value_ || 256 return (value_ < other.value_ ||