Mercurial > hg > orthanc
diff OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp @ 4737:979ae3ea3381
DANGEROUS commit: Anonymization is now also applied to nested sequences
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 06 Jul 2021 08:12:26 +0200 |
parents | b51c08bd5c38 |
children | 248408d2b336 |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Mon Jul 05 17:50:58 2021 +0200 +++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Tue Jul 06 08:12:26 2021 +0200 @@ -2415,6 +2415,20 @@ evr = EVR_UN; } + if (evr == EVR_UN) + { + // New in Orthanc 1.9.5 + DictionaryLocker locker; + + const DcmDictEntry* entry = locker->findEntry(element.getTag().getXTag(), + element.getTag().getPrivateCreator()); + + if (entry != NULL) + { + evr = entry->getEVR(); + } + } + const ValueRepresentation vr = FromDcmtkBridge::Convert(evr); @@ -2846,41 +2860,38 @@ // etc. are not." The following dynamic_cast is thus OK. DcmSequenceOfItems& sequence = dynamic_cast<DcmSequenceOfItems&>(element); - if (sequence.card() == 0) + ITagVisitor::Action action = visitor.VisitSequence(parentTags, parentIndexes, tag, sequence.card()); + + switch (action) { - ITagVisitor::Action action = visitor.VisitEmptySequence(parentTags, parentIndexes, tag); - - switch (action) - { - case ITagVisitor::Action_None: - return true; - - case ITagVisitor::Action_Remove: - return false; - - case ITagVisitor::Action_Replace: - throw OrthancException(ErrorCode_NotImplemented, "Iterator cannot replace sequences"); - - default: - throw OrthancException(ErrorCode_ParameterOutOfRange); - } + case ITagVisitor::Action_None: + if (sequence.card() != 0) // Minor optimization to avoid creating "tags" and "indexes" if not needed + { + std::vector<DicomTag> tags = parentTags; + std::vector<size_t> indexes = parentIndexes; + tags.push_back(tag); + indexes.push_back(0); + + for (unsigned long i = 0; i < sequence.card(); i++) + { + indexes.back() = static_cast<size_t>(i); + DcmItem* child = sequence.getItem(i); + ApplyVisitorToDataset(*child, visitor, tags, indexes, encoding, hasCodeExtensions); + } + } + + return true; // Keep + + case ITagVisitor::Action_Remove: + return false; + + case ITagVisitor::Action_Replace: + throw OrthancException(ErrorCode_NotImplemented, "Iterator cannot replace sequences"); + + default: + throw OrthancException(ErrorCode_ParameterOutOfRange); } - else - { - std::vector<DicomTag> tags = parentTags; - std::vector<size_t> indexes = parentIndexes; - tags.push_back(tag); - indexes.push_back(0); - - for (unsigned long i = 0; i < sequence.card(); i++) - { - indexes.back() = static_cast<size_t>(i); - DcmItem* child = sequence.getItem(i); - ApplyVisitorToDataset(*child, visitor, tags, indexes, encoding, hasCodeExtensions); - } - - return true; // Keep - } + } }