Mercurial > hg > orthanc
comparison Core/DicomParsing/ParsedDicomFile.cpp @ 3944:aae045f802f4 transcoding
preparing simplified interface for IDicomTranscoder
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 19 May 2020 10:17:06 +0200 |
parents | 7610af1532c3 |
children | 3d2fc1b5cc8c |
comparison
equal
deleted
inserted
replaced
3943:b26d25d3c1c7 | 3944:aae045f802f4 |
---|---|
453 | 453 |
454 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1 | 454 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1 |
455 void ParsedDicomFile::SendPathValue(RestApiOutput& output, | 455 void ParsedDicomFile::SendPathValue(RestApiOutput& output, |
456 const UriComponents& uri) | 456 const UriComponents& uri) |
457 { | 457 { |
458 DcmItem* dicom = pimpl_->file_->getDataset(); | 458 DcmItem* dicom = GetDcmtkObject().getDataset(); |
459 E_TransferSyntax transferSyntax = pimpl_->file_->getDataset()->getCurrentXfer(); | 459 E_TransferSyntax transferSyntax = GetDcmtkObject().getDataset()->getCurrentXfer(); |
460 | 460 |
461 // Special case: Accessing the pixel data | 461 // Special case: Accessing the pixel data |
462 if (uri.size() == 1 || | 462 if (uri.size() == 1 || |
463 uri.size() == 2) | 463 uri.size() == 2) |
464 { | 464 { |
514 void ParsedDicomFile::Remove(const DicomTag& tag) | 514 void ParsedDicomFile::Remove(const DicomTag& tag) |
515 { | 515 { |
516 InvalidateCache(); | 516 InvalidateCache(); |
517 | 517 |
518 DcmTagKey key(tag.GetGroup(), tag.GetElement()); | 518 DcmTagKey key(tag.GetGroup(), tag.GetElement()); |
519 DcmElement* element = pimpl_->file_->getDataset()->remove(key); | 519 DcmElement* element = GetDcmtkObject().getDataset()->remove(key); |
520 if (element != NULL) | 520 if (element != NULL) |
521 { | 521 { |
522 delete element; | 522 delete element; |
523 } | 523 } |
524 } | 524 } |
534 return; | 534 return; |
535 } | 535 } |
536 | 536 |
537 InvalidateCache(); | 537 InvalidateCache(); |
538 | 538 |
539 DcmItem* dicom = pimpl_->file_->getDataset(); | 539 DcmItem* dicom = GetDcmtkObject().getDataset(); |
540 DcmTagKey key(tag.GetGroup(), tag.GetElement()); | 540 DcmTagKey key(tag.GetGroup(), tag.GetElement()); |
541 | 541 |
542 if (onlyIfExists && | 542 if (onlyIfExists && |
543 !dicom->tagExists(key)) | 543 !dicom->tagExists(key)) |
544 { | 544 { |
556 | 556 |
557 void ParsedDicomFile::RemovePrivateTagsInternal(const std::set<DicomTag>* toKeep) | 557 void ParsedDicomFile::RemovePrivateTagsInternal(const std::set<DicomTag>* toKeep) |
558 { | 558 { |
559 InvalidateCache(); | 559 InvalidateCache(); |
560 | 560 |
561 DcmDataset& dataset = *pimpl_->file_->getDataset(); | 561 DcmDataset& dataset = *GetDcmtkObject().getDataset(); |
562 | 562 |
563 // Loop over the dataset to detect its private tags | 563 // Loop over the dataset to detect its private tags |
564 typedef std::list<DcmElement*> Tags; | 564 typedef std::list<DcmElement*> Tags; |
565 Tags privateTags; | 565 Tags privateTags; |
566 | 566 |
627 // Prevent manually modifying generic group length tags: This is | 627 // Prevent manually modifying generic group length tags: This is |
628 // handled by DCMTK serialization | 628 // handled by DCMTK serialization |
629 return; | 629 return; |
630 } | 630 } |
631 | 631 |
632 if (pimpl_->file_->getDataset()->tagExists(ToDcmtkBridge::Convert(tag))) | 632 if (GetDcmtkObject().getDataset()->tagExists(ToDcmtkBridge::Convert(tag))) |
633 { | 633 { |
634 throw OrthancException(ErrorCode_AlreadyExistingTag); | 634 throw OrthancException(ErrorCode_AlreadyExistingTag); |
635 } | 635 } |
636 | 636 |
637 if (decodeDataUriScheme && | 637 if (decodeDataUriScheme && |
648 InvalidateCache(); | 648 InvalidateCache(); |
649 | 649 |
650 bool hasCodeExtensions; | 650 bool hasCodeExtensions; |
651 Encoding encoding = DetectEncoding(hasCodeExtensions); | 651 Encoding encoding = DetectEncoding(hasCodeExtensions); |
652 std::unique_ptr<DcmElement> element(FromDcmtkBridge::FromJson(tag, value, decodeDataUriScheme, encoding, privateCreator)); | 652 std::unique_ptr<DcmElement> element(FromDcmtkBridge::FromJson(tag, value, decodeDataUriScheme, encoding, privateCreator)); |
653 InsertInternal(*pimpl_->file_->getDataset(), element.release()); | 653 InsertInternal(*GetDcmtkObject().getDataset(), element.release()); |
654 } | 654 } |
655 | 655 |
656 | 656 |
657 void ParsedDicomFile::ReplacePlainString(const DicomTag& tag, | 657 void ParsedDicomFile::ReplacePlainString(const DicomTag& tag, |
658 const std::string& utf8Value) | 658 const std::string& utf8Value) |
780 return; | 780 return; |
781 } | 781 } |
782 | 782 |
783 InvalidateCache(); | 783 InvalidateCache(); |
784 | 784 |
785 DcmDataset& dicom = *pimpl_->file_->getDataset(); | 785 DcmDataset& dicom = *GetDcmtkObject().getDataset(); |
786 if (CanReplaceProceed(dicom, ToDcmtkBridge::Convert(tag), mode)) | 786 if (CanReplaceProceed(dicom, ToDcmtkBridge::Convert(tag), mode)) |
787 { | 787 { |
788 // Either the tag was previously existing (and now removed), or | 788 // Either the tag was previously existing (and now removed), or |
789 // the replace mode was set to "InsertIfAbsent" | 789 // the replace mode was set to "InsertIfAbsent" |
790 | 790 |
826 return; | 826 return; |
827 } | 827 } |
828 | 828 |
829 InvalidateCache(); | 829 InvalidateCache(); |
830 | 830 |
831 DcmDataset& dicom = *pimpl_->file_->getDataset(); | 831 DcmDataset& dicom = *GetDcmtkObject().getDataset(); |
832 if (CanReplaceProceed(dicom, ToDcmtkBridge::Convert(tag), mode)) | 832 if (CanReplaceProceed(dicom, ToDcmtkBridge::Convert(tag), mode)) |
833 { | 833 { |
834 // Either the tag was previously existing (and now removed), or | 834 // Either the tag was previously existing (and now removed), or |
835 // the replace mode was set to "InsertIfAbsent" | 835 // the replace mode was set to "InsertIfAbsent" |
836 | 836 |
865 | 865 |
866 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1 | 866 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1 |
867 void ParsedDicomFile::Answer(RestApiOutput& output) | 867 void ParsedDicomFile::Answer(RestApiOutput& output) |
868 { | 868 { |
869 std::string serialized; | 869 std::string serialized; |
870 if (FromDcmtkBridge::SaveToMemoryBuffer(serialized, *pimpl_->file_->getDataset())) | 870 if (FromDcmtkBridge::SaveToMemoryBuffer(serialized, *GetDcmtkObject().getDataset())) |
871 { | 871 { |
872 output.AnswerBuffer(serialized, MimeType_Dicom); | 872 output.AnswerBuffer(serialized, MimeType_Dicom); |
873 } | 873 } |
874 } | 874 } |
875 #endif | 875 #endif |
877 | 877 |
878 bool ParsedDicomFile::GetTagValue(std::string& value, | 878 bool ParsedDicomFile::GetTagValue(std::string& value, |
879 const DicomTag& tag) | 879 const DicomTag& tag) |
880 { | 880 { |
881 DcmTagKey k(tag.GetGroup(), tag.GetElement()); | 881 DcmTagKey k(tag.GetGroup(), tag.GetElement()); |
882 DcmDataset& dataset = *pimpl_->file_->getDataset(); | 882 DcmDataset& dataset = *GetDcmtkObject().getDataset(); |
883 | 883 |
884 if (tag.IsPrivate() || | 884 if (tag.IsPrivate() || |
885 FromDcmtkBridge::IsUnknownTag(tag) || | 885 FromDcmtkBridge::IsUnknownTag(tag) || |
886 tag == DICOM_TAG_PIXEL_DATA || | 886 tag == DICOM_TAG_PIXEL_DATA || |
887 tag == DICOM_TAG_ENCAPSULATED_DOCUMENT) | 887 tag == DICOM_TAG_ENCAPSULATED_DOCUMENT) |
968 } | 968 } |
969 | 969 |
970 | 970 |
971 void ParsedDicomFile::SaveToMemoryBuffer(std::string& buffer) | 971 void ParsedDicomFile::SaveToMemoryBuffer(std::string& buffer) |
972 { | 972 { |
973 FromDcmtkBridge::SaveToMemoryBuffer(buffer, *pimpl_->file_->getDataset()); | 973 FromDcmtkBridge::SaveToMemoryBuffer(buffer, *GetDcmtkObject().getDataset()); |
974 } | 974 } |
975 | 975 |
976 | 976 |
977 #if ORTHANC_SANDBOXED == 0 | 977 #if ORTHANC_SANDBOXED == 0 |
978 void ParsedDicomFile::SaveToFile(const std::string& path) | 978 void ParsedDicomFile::SaveToFile(const std::string& path) |
1002 void ParsedDicomFile::CreateFromDicomMap(const DicomMap& source, | 1002 void ParsedDicomFile::CreateFromDicomMap(const DicomMap& source, |
1003 Encoding defaultEncoding, | 1003 Encoding defaultEncoding, |
1004 bool permissive) | 1004 bool permissive) |
1005 { | 1005 { |
1006 pimpl_->file_.reset(new DcmFileFormat); | 1006 pimpl_->file_.reset(new DcmFileFormat); |
1007 pimpl_->frameIndex_.reset(NULL); | |
1007 | 1008 |
1008 const DicomValue* tmp = source.TestAndGetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET); | 1009 const DicomValue* tmp = source.TestAndGetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET); |
1009 | 1010 |
1010 if (tmp == NULL) | 1011 if (tmp == NULL) |
1011 { | 1012 { |
1089 | 1090 |
1090 ParsedDicomFile::ParsedDicomFile(ParsedDicomFile& other, | 1091 ParsedDicomFile::ParsedDicomFile(ParsedDicomFile& other, |
1091 bool keepSopInstanceUid) : | 1092 bool keepSopInstanceUid) : |
1092 pimpl_(new PImpl) | 1093 pimpl_(new PImpl) |
1093 { | 1094 { |
1094 pimpl_->file_.reset(dynamic_cast<DcmFileFormat*>(other.pimpl_->file_->clone())); | 1095 pimpl_->file_.reset(dynamic_cast<DcmFileFormat*>(other.GetDcmtkObject().clone())); |
1095 | 1096 |
1096 if (!keepSopInstanceUid) | 1097 if (!keepSopInstanceUid) |
1097 { | 1098 { |
1098 // Create a new instance-level identifier | 1099 // Create a new instance-level identifier |
1099 ReplacePlainString(DICOM_TAG_SOP_INSTANCE_UID, FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Instance)); | 1100 ReplacePlainString(DICOM_TAG_SOP_INSTANCE_UID, FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Instance)); |
1119 } | 1120 } |
1120 | 1121 |
1121 | 1122 |
1122 DcmFileFormat& ParsedDicomFile::GetDcmtkObject() const | 1123 DcmFileFormat& ParsedDicomFile::GetDcmtkObject() const |
1123 { | 1124 { |
1124 return *pimpl_->file_.get(); | 1125 if (pimpl_->file_.get() == NULL) |
1126 { | |
1127 throw OrthancException(ErrorCode_BadSequenceOfCalls, | |
1128 "ReleaseDcmtkObject() was called"); | |
1129 } | |
1130 else | |
1131 { | |
1132 return *pimpl_->file_; | |
1133 } | |
1134 } | |
1135 | |
1136 | |
1137 DcmFileFormat* ParsedDicomFile::ReleaseDcmtkObject() | |
1138 { | |
1139 if (pimpl_->file_.get() == NULL) | |
1140 { | |
1141 throw OrthancException(ErrorCode_BadSequenceOfCalls, | |
1142 "ReleaseDcmtkObject() was called"); | |
1143 } | |
1144 else | |
1145 { | |
1146 pimpl_->frameIndex_.reset(NULL); | |
1147 return pimpl_->file_.release(); | |
1148 } | |
1125 } | 1149 } |
1126 | 1150 |
1127 | 1151 |
1128 ParsedDicomFile* ParsedDicomFile::Clone(bool keepSopInstanceUid) | 1152 ParsedDicomFile* ParsedDicomFile::Clone(bool keepSopInstanceUid) |
1129 { | 1153 { |
1352 default: | 1376 default: |
1353 throw OrthancException(ErrorCode_NotImplemented); | 1377 throw OrthancException(ErrorCode_NotImplemented); |
1354 } | 1378 } |
1355 } | 1379 } |
1356 | 1380 |
1357 if (!pimpl_->file_->getDataset()->insert(pixels.release(), false, false).good()) | 1381 if (!GetDcmtkObject().getDataset()->insert(pixels.release(), false, false).good()) |
1358 { | 1382 { |
1359 throw OrthancException(ErrorCode_InternalError); | 1383 throw OrthancException(ErrorCode_InternalError); |
1360 } | 1384 } |
1361 } | 1385 } |
1362 | 1386 |
1363 | 1387 |
1364 Encoding ParsedDicomFile::DetectEncoding(bool& hasCodeExtensions) const | 1388 Encoding ParsedDicomFile::DetectEncoding(bool& hasCodeExtensions) const |
1365 { | 1389 { |
1366 return FromDcmtkBridge::DetectEncoding(hasCodeExtensions, | 1390 return FromDcmtkBridge::DetectEncoding(hasCodeExtensions, |
1367 *pimpl_->file_->getDataset(), | 1391 *GetDcmtkObject().getDataset(), |
1368 GetDefaultDicomEncoding()); | 1392 GetDefaultDicomEncoding()); |
1369 } | 1393 } |
1370 | 1394 |
1371 | 1395 |
1372 void ParsedDicomFile::SetEncoding(Encoding encoding) | 1396 void ParsedDicomFile::SetEncoding(Encoding encoding) |
1386 DicomToJsonFormat format, | 1410 DicomToJsonFormat format, |
1387 DicomToJsonFlags flags, | 1411 DicomToJsonFlags flags, |
1388 unsigned int maxStringLength) | 1412 unsigned int maxStringLength) |
1389 { | 1413 { |
1390 std::set<DicomTag> ignoreTagLength; | 1414 std::set<DicomTag> ignoreTagLength; |
1391 FromDcmtkBridge::ExtractDicomAsJson(target, *pimpl_->file_->getDataset(), | 1415 FromDcmtkBridge::ExtractDicomAsJson(target, *GetDcmtkObject().getDataset(), |
1392 format, flags, maxStringLength, | 1416 format, flags, maxStringLength, |
1393 GetDefaultDicomEncoding(), ignoreTagLength); | 1417 GetDefaultDicomEncoding(), ignoreTagLength); |
1394 } | 1418 } |
1395 | 1419 |
1396 | 1420 |
1398 DicomToJsonFormat format, | 1422 DicomToJsonFormat format, |
1399 DicomToJsonFlags flags, | 1423 DicomToJsonFlags flags, |
1400 unsigned int maxStringLength, | 1424 unsigned int maxStringLength, |
1401 const std::set<DicomTag>& ignoreTagLength) | 1425 const std::set<DicomTag>& ignoreTagLength) |
1402 { | 1426 { |
1403 FromDcmtkBridge::ExtractDicomAsJson(target, *pimpl_->file_->getDataset(), | 1427 FromDcmtkBridge::ExtractDicomAsJson(target, *GetDcmtkObject().getDataset(), |
1404 format, flags, maxStringLength, | 1428 format, flags, maxStringLength, |
1405 GetDefaultDicomEncoding(), ignoreTagLength); | 1429 GetDefaultDicomEncoding(), ignoreTagLength); |
1406 } | 1430 } |
1407 | 1431 |
1408 | 1432 |
1409 void ParsedDicomFile::DatasetToJson(Json::Value& target, | 1433 void ParsedDicomFile::DatasetToJson(Json::Value& target, |
1410 const std::set<DicomTag>& ignoreTagLength) | 1434 const std::set<DicomTag>& ignoreTagLength) |
1411 { | 1435 { |
1412 FromDcmtkBridge::ExtractDicomAsJson(target, *pimpl_->file_->getDataset(), ignoreTagLength); | 1436 FromDcmtkBridge::ExtractDicomAsJson(target, *GetDcmtkObject().getDataset(), ignoreTagLength); |
1413 } | 1437 } |
1414 | 1438 |
1415 | 1439 |
1416 void ParsedDicomFile::DatasetToJson(Json::Value& target) | 1440 void ParsedDicomFile::DatasetToJson(Json::Value& target) |
1417 { | 1441 { |
1418 const std::set<DicomTag> ignoreTagLength; | 1442 const std::set<DicomTag> ignoreTagLength; |
1419 FromDcmtkBridge::ExtractDicomAsJson(target, *pimpl_->file_->getDataset(), ignoreTagLength); | 1443 FromDcmtkBridge::ExtractDicomAsJson(target, *GetDcmtkObject().getDataset(), ignoreTagLength); |
1420 } | 1444 } |
1421 | 1445 |
1422 | 1446 |
1423 void ParsedDicomFile::HeaderToJson(Json::Value& target, | 1447 void ParsedDicomFile::HeaderToJson(Json::Value& target, |
1424 DicomToJsonFormat format) | 1448 DicomToJsonFormat format) |
1425 { | 1449 { |
1426 FromDcmtkBridge::ExtractHeaderAsJson(target, *pimpl_->file_->getMetaInfo(), format, DicomToJsonFlags_None, 0); | 1450 FromDcmtkBridge::ExtractHeaderAsJson(target, *GetDcmtkObject().getMetaInfo(), format, DicomToJsonFlags_None, 0); |
1427 } | 1451 } |
1428 | 1452 |
1429 | 1453 |
1430 bool ParsedDicomFile::HasTag(const DicomTag& tag) const | 1454 bool ParsedDicomFile::HasTag(const DicomTag& tag) const |
1431 { | 1455 { |
1432 DcmTag key(tag.GetGroup(), tag.GetElement()); | 1456 DcmTag key(tag.GetGroup(), tag.GetElement()); |
1433 return pimpl_->file_->getDataset()->tagExists(key); | 1457 return GetDcmtkObject().getDataset()->tagExists(key); |
1434 } | 1458 } |
1435 | 1459 |
1436 | 1460 |
1437 void ParsedDicomFile::EmbedPdf(const std::string& pdf) | 1461 void ParsedDicomFile::EmbedPdf(const std::string& pdf) |
1438 { | 1462 { |
1470 bytes[s - 1] = 0; | 1494 bytes[s - 1] = 0; |
1471 | 1495 |
1472 memcpy(bytes, pdf.c_str(), pdf.size()); | 1496 memcpy(bytes, pdf.c_str(), pdf.size()); |
1473 | 1497 |
1474 DcmPolymorphOBOW* obj = element.release(); | 1498 DcmPolymorphOBOW* obj = element.release(); |
1475 result = pimpl_->file_->getDataset()->insert(obj); | 1499 result = GetDcmtkObject().getDataset()->insert(obj); |
1476 | 1500 |
1477 if (!result.good()) | 1501 if (!result.good()) |
1478 { | 1502 { |
1479 delete obj; | 1503 delete obj; |
1480 throw OrthancException(ErrorCode_NotEnoughMemory); | 1504 throw OrthancException(ErrorCode_NotEnoughMemory); |
1562 unsigned int frameId) | 1586 unsigned int frameId) |
1563 { | 1587 { |
1564 if (pimpl_->frameIndex_.get() == NULL) | 1588 if (pimpl_->frameIndex_.get() == NULL) |
1565 { | 1589 { |
1566 assert(pimpl_->file_ != NULL && | 1590 assert(pimpl_->file_ != NULL && |
1567 pimpl_->file_->getDataset() != NULL); | 1591 GetDcmtkObject().getDataset() != NULL); |
1568 pimpl_->frameIndex_.reset(new DicomFrameIndex(*pimpl_->file_->getDataset())); | 1592 pimpl_->frameIndex_.reset(new DicomFrameIndex(*GetDcmtkObject().getDataset())); |
1569 } | 1593 } |
1570 | 1594 |
1571 pimpl_->frameIndex_->GetRawFrame(target, frameId); | 1595 pimpl_->frameIndex_->GetRawFrame(target, frameId); |
1572 | 1596 |
1573 E_TransferSyntax transferSyntax = pimpl_->file_->getDataset()->getCurrentXfer(); | 1597 E_TransferSyntax transferSyntax = GetDcmtkObject().getDataset()->getCurrentXfer(); |
1574 switch (transferSyntax) | 1598 switch (transferSyntax) |
1575 { | 1599 { |
1576 case EXS_JPEGProcess1: | 1600 case EXS_JPEGProcess1: |
1577 mime = MimeType_Jpeg; | 1601 mime = MimeType_Jpeg; |
1578 break; | 1602 break; |
1596 | 1620 |
1597 | 1621 |
1598 unsigned int ParsedDicomFile::GetFramesCount() const | 1622 unsigned int ParsedDicomFile::GetFramesCount() const |
1599 { | 1623 { |
1600 assert(pimpl_->file_ != NULL && | 1624 assert(pimpl_->file_ != NULL && |
1601 pimpl_->file_->getDataset() != NULL); | 1625 GetDcmtkObject().getDataset() != NULL); |
1602 return DicomFrameIndex::GetFramesCount(*pimpl_->file_->getDataset()); | 1626 return DicomFrameIndex::GetFramesCount(*GetDcmtkObject().getDataset()); |
1603 } | 1627 } |
1604 | 1628 |
1605 | 1629 |
1606 void ParsedDicomFile::ChangeEncoding(Encoding target) | 1630 void ParsedDicomFile::ChangeEncoding(Encoding target) |
1607 { | 1631 { |
1609 Encoding source = DetectEncoding(hasCodeExtensions); | 1633 Encoding source = DetectEncoding(hasCodeExtensions); |
1610 | 1634 |
1611 if (source != target) // Avoid unnecessary conversion | 1635 if (source != target) // Avoid unnecessary conversion |
1612 { | 1636 { |
1613 ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, GetDicomSpecificCharacterSet(target)); | 1637 ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, GetDicomSpecificCharacterSet(target)); |
1614 FromDcmtkBridge::ChangeStringEncoding(*pimpl_->file_->getDataset(), source, hasCodeExtensions, target); | 1638 FromDcmtkBridge::ChangeStringEncoding(*GetDcmtkObject().getDataset(), source, hasCodeExtensions, target); |
1615 } | 1639 } |
1616 } | 1640 } |
1617 | 1641 |
1618 | 1642 |
1619 void ParsedDicomFile::ExtractDicomSummary(DicomMap& target) const | 1643 void ParsedDicomFile::ExtractDicomSummary(DicomMap& target) const |
1620 { | 1644 { |
1621 FromDcmtkBridge::ExtractDicomSummary(target, *pimpl_->file_->getDataset()); | 1645 FromDcmtkBridge::ExtractDicomSummary(target, *GetDcmtkObject().getDataset()); |
1622 } | 1646 } |
1623 | 1647 |
1624 | 1648 |
1625 void ParsedDicomFile::ExtractDicomSummary(DicomMap& target, | 1649 void ParsedDicomFile::ExtractDicomSummary(DicomMap& target, |
1626 const std::set<DicomTag>& ignoreTagLength) const | 1650 const std::set<DicomTag>& ignoreTagLength) const |
1627 { | 1651 { |
1628 FromDcmtkBridge::ExtractDicomSummary(target, *pimpl_->file_->getDataset(), ignoreTagLength); | 1652 FromDcmtkBridge::ExtractDicomSummary(target, *GetDcmtkObject().getDataset(), ignoreTagLength); |
1629 } | 1653 } |
1630 | 1654 |
1631 | 1655 |
1632 bool ParsedDicomFile::LookupTransferSyntax(std::string& result) | 1656 bool ParsedDicomFile::LookupTransferSyntax(std::string& result) |
1633 { | 1657 { |
1634 // TODO - Shouldn't "dataset.getCurrentXfer()" be used instead of | 1658 // TODO - Shouldn't "dataset.getCurrentXfer()" be used instead of |
1635 // using the meta header? | 1659 // using the meta header? |
1636 const char* value = NULL; | 1660 const char* value = NULL; |
1637 | 1661 |
1638 assert(pimpl_->file_ != NULL); | 1662 if (GetDcmtkObject().getMetaInfo() != NULL && |
1639 if (pimpl_->file_->getMetaInfo() != NULL && | 1663 GetDcmtkObject().getMetaInfo()->findAndGetString(DCM_TransferSyntaxUID, value).good() && |
1640 pimpl_->file_->getMetaInfo()->findAndGetString(DCM_TransferSyntaxUID, value).good() && | |
1641 value != NULL) | 1664 value != NULL) |
1642 { | 1665 { |
1643 result.assign(value); | 1666 result.assign(value); |
1644 return true; | 1667 return true; |
1645 } | 1668 } |
1653 bool ParsedDicomFile::LookupPhotometricInterpretation(PhotometricInterpretation& result) const | 1676 bool ParsedDicomFile::LookupPhotometricInterpretation(PhotometricInterpretation& result) const |
1654 { | 1677 { |
1655 DcmTagKey k(DICOM_TAG_PHOTOMETRIC_INTERPRETATION.GetGroup(), | 1678 DcmTagKey k(DICOM_TAG_PHOTOMETRIC_INTERPRETATION.GetGroup(), |
1656 DICOM_TAG_PHOTOMETRIC_INTERPRETATION.GetElement()); | 1679 DICOM_TAG_PHOTOMETRIC_INTERPRETATION.GetElement()); |
1657 | 1680 |
1658 DcmDataset& dataset = *pimpl_->file_->getDataset(); | 1681 DcmDataset& dataset = *GetDcmtkObject().getDataset(); |
1659 | 1682 |
1660 const char *c = NULL; | 1683 const char *c = NULL; |
1661 if (dataset.findAndGetString(k, c).good() && | 1684 if (dataset.findAndGetString(k, c).good() && |
1662 c != NULL) | 1685 c != NULL) |
1663 { | 1686 { |
1671 } | 1694 } |
1672 | 1695 |
1673 | 1696 |
1674 void ParsedDicomFile::Apply(ITagVisitor& visitor) | 1697 void ParsedDicomFile::Apply(ITagVisitor& visitor) |
1675 { | 1698 { |
1676 FromDcmtkBridge::Apply(*pimpl_->file_->getDataset(), visitor, GetDefaultDicomEncoding()); | 1699 FromDcmtkBridge::Apply(*GetDcmtkObject().getDataset(), visitor, GetDefaultDicomEncoding()); |
1677 } | 1700 } |
1678 } | 1701 } |