comparison Core/DicomParsing/ParsedDicomFile.cpp @ 3276:9b0e67161600

More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 21 Feb 2019 10:21:12 +0100
parents cf8cbeb35f33
children 63f59ad9381a
comparison
equal deleted inserted replaced
3275:5cd4c672d63c 3276:9b0e67161600
954 } 954 }
955 } 955 }
956 956
957 957
958 void ParsedDicomFile::CreateFromDicomMap(const DicomMap& source, 958 void ParsedDicomFile::CreateFromDicomMap(const DicomMap& source,
959 Encoding defaultEncoding) 959 Encoding defaultEncoding,
960 bool permissive)
960 { 961 {
961 pimpl_->file_.reset(new DcmFileFormat); 962 pimpl_->file_.reset(new DcmFileFormat);
962 963
963 const DicomValue* tmp = source.TestAndGetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET); 964 const DicomValue* tmp = source.TestAndGetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET);
964 965
996 it = source.map_.begin(); it != source.map_.end(); ++it) 997 it = source.map_.begin(); it != source.map_.end(); ++it)
997 { 998 {
998 if (it->first != DICOM_TAG_SPECIFIC_CHARACTER_SET && 999 if (it->first != DICOM_TAG_SPECIFIC_CHARACTER_SET &&
999 !it->second->IsNull()) 1000 !it->second->IsNull())
1000 { 1001 {
1001 ReplacePlainString(it->first, it->second->GetContent()); 1002 try
1003 {
1004 ReplacePlainString(it->first, it->second->GetContent());
1005 }
1006 catch (OrthancException&)
1007 {
1008 if (!permissive)
1009 {
1010 throw;
1011 }
1012 }
1002 } 1013 }
1003 } 1014 }
1004 } 1015 }
1005 1016
1006 1017
1007 ParsedDicomFile::ParsedDicomFile(const DicomMap& map, 1018 ParsedDicomFile::ParsedDicomFile(const DicomMap& map,
1008 Encoding defaultEncoding) : 1019 Encoding defaultEncoding,
1020 bool permissive) :
1009 pimpl_(new PImpl) 1021 pimpl_(new PImpl)
1010 { 1022 {
1011 CreateFromDicomMap(map, defaultEncoding); 1023 CreateFromDicomMap(map, defaultEncoding, permissive);
1012 } 1024 }
1013 1025
1014 1026
1015 ParsedDicomFile::ParsedDicomFile(const DicomMap& map) : 1027 ParsedDicomFile::ParsedDicomFile(const DicomMap& map) :
1016 pimpl_(new PImpl) 1028 pimpl_(new PImpl)
1017 { 1029 {
1018 CreateFromDicomMap(map, GetDefaultDicomEncoding()); 1030 CreateFromDicomMap(map, GetDefaultDicomEncoding(), false /* be strict by default */);
1019 } 1031 }
1020 1032
1021 1033
1022 ParsedDicomFile::ParsedDicomFile(const void* content, 1034 ParsedDicomFile::ParsedDicomFile(const void* content,
1023 size_t size) : pimpl_(new PImpl) 1035 size_t size) : pimpl_(new PImpl)