Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Toolbox/SortedFrames.cpp @ 1599:73cd85d7da6a
SortedFrames::LookupSopInstanceUid()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 28 Oct 2020 10:55:45 +0100 |
parents | 8563ea5d8ae4 |
children | b253b79906fa |
comparison
equal
deleted
inserted
replaced
1598:8563ea5d8ae4 | 1599:73cd85d7da6a |
---|---|
142 { | 142 { |
143 assert(instances_[i] != NULL); | 143 assert(instances_[i] != NULL); |
144 delete instances_[i]; | 144 delete instances_[i]; |
145 } | 145 } |
146 | 146 |
147 instancesIndex_.clear(); | |
147 studyInstanceUid_.clear(); | 148 studyInstanceUid_.clear(); |
148 seriesInstanceUid_.clear(); | 149 seriesInstanceUid_.clear(); |
149 frames_.clear(); | 150 frames_.clear(); |
150 sorted_ = true; | 151 sorted_ = true; |
151 } | 152 } |
153 | 154 |
154 void SortedFrames::AddInstance(const Orthanc::DicomMap& tags) | 155 void SortedFrames::AddInstance(const Orthanc::DicomMap& tags) |
155 { | 156 { |
156 std::unique_ptr<Instance> instance(new Instance(tags)); | 157 std::unique_ptr<Instance> instance(new Instance(tags)); |
157 | 158 |
158 std::string studyInstanceUid, seriesInstanceUid; | 159 std::string studyInstanceUid, seriesInstanceUid, sopInstanceUid; |
159 if (!tags.LookupStringValue(studyInstanceUid, Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, false) || | 160 if (!tags.LookupStringValue(studyInstanceUid, Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, false) || |
160 !tags.LookupStringValue(seriesInstanceUid, Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, false)) | 161 !tags.LookupStringValue(seriesInstanceUid, Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, false) || |
162 !tags.LookupStringValue(sopInstanceUid, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false)) | |
161 { | 163 { |
162 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | 164 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
163 } | 165 } |
164 | 166 |
165 if (instances_.empty()) | 167 if (instances_.empty()) |
174 { | 176 { |
175 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, | 177 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, |
176 "Mixing instances from different series"); | 178 "Mixing instances from different series"); |
177 } | 179 } |
178 } | 180 } |
181 | |
182 if (instancesIndex_.find(sopInstanceUid) != instancesIndex_.end()) | |
183 { | |
184 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, | |
185 "Cannot register twice the same SOP Instance UID"); | |
186 } | |
187 | |
188 instancesIndex_[sopInstanceUid] = instances_.size(); | |
179 | 189 |
180 instances_.push_back(instance.release()); | 190 instances_.push_back(instance.release()); |
181 sorted_ = false; | 191 sorted_ = false; |
182 frames_.clear(); | 192 frames_.clear(); |
183 } | 193 } |
184 | 194 |
185 | 195 |
196 bool SortedFrames::LookupSopInstanceUid(size_t& instanceIndex, | |
197 const std::string& sopInstanceUid) const | |
198 { | |
199 InstancesIndex::const_iterator found = instancesIndex_.find(sopInstanceUid); | |
200 | |
201 if (found == instancesIndex_.end()) | |
202 { | |
203 return false; | |
204 } | |
205 else | |
206 { | |
207 instanceIndex = found->second; | |
208 return true; | |
209 } | |
210 } | |
211 | |
212 | |
186 void SortedFrames::AddFramesOfInstance(std::set<size_t>& remainingInstances, | 213 void SortedFrames::AddFramesOfInstance(std::set<size_t>& remainingInstances, |
187 size_t index) | 214 size_t index) |
188 { | 215 { |
189 assert(instances_[index] != NULL); | 216 assert(instances_[index] != NULL); |
190 const Instance& instance = *instances_[index]; | 217 const Instance& instance = *instances_[index]; |