comparison OrthancFramework/Sources/DicomFormat/DicomPath.cpp @ 4683:7182f5732480

use of DicomPath in ParsedDicomFile
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 08 Jun 2021 12:37:48 +0200
parents d38a7040474a
children 693f049729ba
comparison
equal deleted inserted replaced
4682:d38a7040474a 4683:7182f5732480
136 finalTag_(tag) 136 finalTag_(tag)
137 { 137 {
138 AddIndexedTagToPrefix(sequence1, index1); 138 AddIndexedTagToPrefix(sequence1, index1);
139 AddIndexedTagToPrefix(sequence2, index2); 139 AddIndexedTagToPrefix(sequence2, index2);
140 AddIndexedTagToPrefix(sequence3, index3); 140 AddIndexedTagToPrefix(sequence3, index3);
141 }
142
143
144 DicomPath::DicomPath(const std::vector<Orthanc::DicomTag>& parentTags,
145 const std::vector<size_t> parentIndexes,
146 const Orthanc::DicomTag& finalTag) :
147 finalTag_(finalTag)
148 {
149 if (parentTags.size() != parentIndexes.size())
150 {
151 throw OrthancException(ErrorCode_ParameterOutOfRange);
152 }
153 else
154 {
155 prefix_.reserve(parentTags.size());
156
157 for (size_t i = 0; i < prefix_.size(); i++)
158 {
159 prefix_.push_back(PrefixItem::CreateIndexed(parentTags[i], parentIndexes[i]));
160 }
161 }
141 } 162 }
142 163
143 164
144 void DicomPath::AddIndexedTagToPrefix(const Orthanc::DicomTag& tag, 165 void DicomPath::AddIndexedTagToPrefix(const Orthanc::DicomTag& tag,
145 size_t index) 166 size_t index)
257 } 278 }
258 } 279 }
259 280
260 return path; 281 return path;
261 } 282 }
283
284
285 bool DicomPath::IsMatch(const DicomPath& pattern,
286 const DicomPath& path)
287 {
288 if (path.HasUniversal())
289 {
290 throw OrthancException(ErrorCode_BadParameterType);
291 }
292 else if (path.GetPrefixLength() < pattern.GetPrefixLength())
293 {
294 return false;
295 }
296 else
297 {
298 for (size_t i = 0; i < pattern.GetPrefixLength(); i++)
299 {
300 if (path.GetPrefixTag(i) != pattern.GetPrefixTag(i) ||
301 (!pattern.IsPrefixUniversal(i) &&
302 path.GetPrefixIndex(i) != pattern.GetPrefixIndex(i)))
303 {
304 return false;
305 }
306 }
307
308 if (path.GetPrefixLength() == pattern.GetPrefixLength())
309 {
310 return (path.GetFinalTag() == pattern.GetFinalTag());
311 }
312 else
313 {
314 return (path.GetPrefixTag(pattern.GetPrefixLength()) == pattern.GetFinalTag());
315 }
316 }
317 }
262 } 318 }