comparison OrthancFramework/Sources/DicomFormat/DicomMap.cpp @ 5323:138e9d0c08c1

added DicomMap::GuessPixelDataValueRepresentation()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 25 Jun 2023 12:29:39 +0200
parents 0ea402b4d901
children 48b8dae6dc77
comparison
equal deleted inserted replaced
5322:a904a4caf5b7 5323:138e9d0c08c1
32 #include "../Endianness.h" 32 #include "../Endianness.h"
33 #include "../Logging.h" 33 #include "../Logging.h"
34 #include "../OrthancException.h" 34 #include "../OrthancException.h"
35 #include "../Toolbox.h" 35 #include "../Toolbox.h"
36 #include "DicomArray.h" 36 #include "DicomArray.h"
37 #include "DicomImageInformation.h"
37 38
38 #if ORTHANC_ENABLE_DCMTK == 1 39 #if ORTHANC_ENABLE_DCMTK == 1
39 #include "../DicomParsing/FromDcmtkBridge.h" 40 #include "../DicomParsing/FromDcmtkBridge.h"
40 #endif 41 #endif
41 42
416 void DicomMap::SetValue(uint16_t group, uint16_t element, const std::string &str, bool isBinary) 417 void DicomMap::SetValue(uint16_t group, uint16_t element, const std::string &str, bool isBinary)
417 { 418 {
418 SetValueInternal(group, element, new DicomValue(str, isBinary)); 419 SetValueInternal(group, element, new DicomValue(str, isBinary));
419 } 420 }
420 421
421 void DicomMap::SetValue(const DicomTag& tag, const Json::Value& value) 422 void DicomMap::SetSequenceValue(const DicomTag& tag, const Json::Value& value)
422 { 423 {
423 SetValueInternal(tag.GetGroup(), tag.GetElement(), new DicomValue(value)); 424 SetValueInternal(tag.GetGroup(), tag.GetElement(), new DicomValue(value));
424 } 425 }
425 426
426 bool DicomMap::HasTag(uint16_t group, uint16_t element) const 427 bool DicomMap::HasTag(uint16_t group, uint16_t element) const
1454 { 1455 {
1455 throw OrthancException(ErrorCode_CorruptedFile); 1456 throw OrthancException(ErrorCode_CorruptedFile);
1456 } 1457 }
1457 else 1458 else
1458 { 1459 {
1459 SetValue(tag, value["Value"]); 1460 SetSequenceValue(tag, value["Value"]);
1460 } 1461 }
1461 } 1462 }
1462 } 1463 }
1463 } 1464 }
1464 1465
1528 1529
1529 for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it) 1530 for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it)
1530 { 1531 {
1531 if (it->second->IsSequence()) 1532 if (it->second->IsSequence())
1532 { 1533 {
1533 result.SetValue(it->first, it->second->GetSequenceContent()); 1534 result.SetSequenceValue(it->first, it->second->GetSequenceContent());
1534 } 1535 }
1535 } 1536 }
1536 } 1537 }
1537 1538
1538 void DicomMap::Serialize(Json::Value& target) const 1539 void DicomMap::Serialize(Json::Value& target) const
1806 } 1807 }
1807 } 1808 }
1808 } 1809 }
1809 1810
1810 1811
1812 ValueRepresentation DicomMap::GuessPixelDataValueRepresentation(DicomTransferSyntax transferSyntax) const
1813 {
1814 const DicomValue* value = TestAndGetValue(DICOM_TAG_BITS_ALLOCATED);
1815
1816 uint32_t bitsAllocated;
1817 if (value == NULL ||
1818 !value->ParseUnsignedInteger32(bitsAllocated))
1819 {
1820 bitsAllocated = 8;
1821 }
1822
1823 return DicomImageInformation::GuessPixelDataValueRepresentation(transferSyntax, bitsAllocated);
1824 }
1811 1825
1812 1826
1813 void DicomMap::Print(FILE* fp) const 1827 void DicomMap::Print(FILE* fp) const
1814 { 1828 {
1815 DicomArray a(*this); 1829 DicomArray a(*this);