Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
4736:bf852fd773b7 | 4737:979ae3ea3381 |
---|---|
2413 evr == EVR_UNKNOWN2B) // used internally for elements with unknown VR with 2-byte length field in explicit VR | 2413 evr == EVR_UNKNOWN2B) // used internally for elements with unknown VR with 2-byte length field in explicit VR |
2414 { | 2414 { |
2415 evr = EVR_UN; | 2415 evr = EVR_UN; |
2416 } | 2416 } |
2417 | 2417 |
2418 if (evr == EVR_UN) | |
2419 { | |
2420 // New in Orthanc 1.9.5 | |
2421 DictionaryLocker locker; | |
2422 | |
2423 const DcmDictEntry* entry = locker->findEntry(element.getTag().getXTag(), | |
2424 element.getTag().getPrivateCreator()); | |
2425 | |
2426 if (entry != NULL) | |
2427 { | |
2428 evr = entry->getEVR(); | |
2429 } | |
2430 } | |
2431 | |
2418 const ValueRepresentation vr = FromDcmtkBridge::Convert(evr); | 2432 const ValueRepresentation vr = FromDcmtkBridge::Convert(evr); |
2419 | 2433 |
2420 | 2434 |
2421 /** | 2435 /** |
2422 * Deal with binary data (including PixelData). | 2436 * Deal with binary data (including PixelData). |
2844 // "All subclasses of DcmElement except for DcmSequenceOfItems | 2858 // "All subclasses of DcmElement except for DcmSequenceOfItems |
2845 // are leaf nodes, while DcmSequenceOfItems, DcmItem, DcmDataset | 2859 // are leaf nodes, while DcmSequenceOfItems, DcmItem, DcmDataset |
2846 // etc. are not." The following dynamic_cast is thus OK. | 2860 // etc. are not." The following dynamic_cast is thus OK. |
2847 DcmSequenceOfItems& sequence = dynamic_cast<DcmSequenceOfItems&>(element); | 2861 DcmSequenceOfItems& sequence = dynamic_cast<DcmSequenceOfItems&>(element); |
2848 | 2862 |
2849 if (sequence.card() == 0) | 2863 ITagVisitor::Action action = visitor.VisitSequence(parentTags, parentIndexes, tag, sequence.card()); |
2850 { | 2864 |
2851 ITagVisitor::Action action = visitor.VisitEmptySequence(parentTags, parentIndexes, tag); | 2865 switch (action) |
2852 | 2866 { |
2853 switch (action) | 2867 case ITagVisitor::Action_None: |
2854 { | 2868 if (sequence.card() != 0) // Minor optimization to avoid creating "tags" and "indexes" if not needed |
2855 case ITagVisitor::Action_None: | 2869 { |
2856 return true; | 2870 std::vector<DicomTag> tags = parentTags; |
2857 | 2871 std::vector<size_t> indexes = parentIndexes; |
2858 case ITagVisitor::Action_Remove: | 2872 tags.push_back(tag); |
2859 return false; | 2873 indexes.push_back(0); |
2860 | 2874 |
2861 case ITagVisitor::Action_Replace: | 2875 for (unsigned long i = 0; i < sequence.card(); i++) |
2862 throw OrthancException(ErrorCode_NotImplemented, "Iterator cannot replace sequences"); | 2876 { |
2863 | 2877 indexes.back() = static_cast<size_t>(i); |
2864 default: | 2878 DcmItem* child = sequence.getItem(i); |
2865 throw OrthancException(ErrorCode_ParameterOutOfRange); | 2879 ApplyVisitorToDataset(*child, visitor, tags, indexes, encoding, hasCodeExtensions); |
2866 } | 2880 } |
2867 } | 2881 } |
2868 else | 2882 |
2869 { | 2883 return true; // Keep |
2870 std::vector<DicomTag> tags = parentTags; | 2884 |
2871 std::vector<size_t> indexes = parentIndexes; | 2885 case ITagVisitor::Action_Remove: |
2872 tags.push_back(tag); | 2886 return false; |
2873 indexes.push_back(0); | 2887 |
2874 | 2888 case ITagVisitor::Action_Replace: |
2875 for (unsigned long i = 0; i < sequence.card(); i++) | 2889 throw OrthancException(ErrorCode_NotImplemented, "Iterator cannot replace sequences"); |
2876 { | 2890 |
2877 indexes.back() = static_cast<size_t>(i); | 2891 default: |
2878 DcmItem* child = sequence.getItem(i); | 2892 throw OrthancException(ErrorCode_ParameterOutOfRange); |
2879 ApplyVisitorToDataset(*child, visitor, tags, indexes, encoding, hasCodeExtensions); | 2893 } |
2880 } | 2894 |
2881 | |
2882 return true; // Keep | |
2883 } | |
2884 } | 2895 } |
2885 } | 2896 } |
2886 | 2897 |
2887 | 2898 |
2888 void FromDcmtkBridge::Apply(DcmItem& dataset, | 2899 void FromDcmtkBridge::Apply(DcmItem& dataset, |