Mercurial > hg > orthanc
comparison Core/DicomNetworking/DicomStoreUserConnection.cpp @ 3906:f0dd5ded8927 transcoding
refactoring using IDicomTranscoder::TranscodedDicom
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 08 May 2020 11:16:16 +0200 |
parents | c62f84c7eda9 |
children | 1555feda39e2 |
comparison
equal
deleted
inserted
replaced
3905:061f3d031b5d | 3906:f0dd5ded8927 |
---|---|
489 if (accepted.find(DicomTransferSyntax_BigEndianExplicit) != accepted.end()) | 489 if (accepted.find(DicomTransferSyntax_BigEndianExplicit) != accepted.end()) |
490 { | 490 { |
491 uncompressedSyntaxes.insert(DicomTransferSyntax_BigEndianExplicit); | 491 uncompressedSyntaxes.insert(DicomTransferSyntax_BigEndianExplicit); |
492 } | 492 } |
493 | 493 |
494 std::unique_ptr<DcmFileFormat> transcoded; | 494 std::unique_ptr<IDicomTranscoder::TranscodedDicom> transcoded( |
495 | 495 transcoder.TranscodeToParsed2(*dicom, buffer, size, uncompressedSyntaxes, false)); |
496 bool hasSopInstanceUidChanged; | 496 |
497 // WARNING: Below this point, "transcoded->GetDicom()" is possibly | |
498 // a reference to "*dicom", if the DCMTK transcoder was used | |
497 | 499 |
498 if (transcoder.HasInplaceTranscode(inputSyntax, uncompressedSyntaxes)) | 500 if (transcoded.get() == NULL || |
499 { | 501 transcoded->GetDicom().getDataset() == NULL) |
500 if (transcoder.InplaceTranscode(hasSopInstanceUidChanged, *dicom, uncompressedSyntaxes, false)) | |
501 { | |
502 // In-place transcoding is supported and has succeeded | |
503 transcoded.reset(dicom.release()); | |
504 } | |
505 } | |
506 else | |
507 { | |
508 transcoded.reset(transcoder.TranscodeToParsed(hasSopInstanceUidChanged, buffer, size, uncompressedSyntaxes, false)); | |
509 } | |
510 | |
511 if (hasSopInstanceUidChanged) | |
512 { | |
513 throw OrthancException(ErrorCode_Plugin, "The transcoder has changed the SOP " | |
514 "instance UID while transcoding to an uncompressed transfer syntax"); | |
515 } | |
516 | |
517 // WARNING: The "dicom" variable must not be used below this | |
518 // point. The "sopInstanceUid" might also have changed (if | |
519 // using lossy compression). | |
520 | |
521 if (transcoded == NULL || | |
522 transcoded->getDataset() == NULL) | |
523 { | 502 { |
524 throw OrthancException( | 503 throw OrthancException( |
525 ErrorCode_NotImplemented, | 504 ErrorCode_NotImplemented, |
526 "Cannot transcode from \"" + std::string(GetTransferSyntaxUid(inputSyntax)) + | 505 "Cannot transcode from \"" + std::string(GetTransferSyntaxUid(inputSyntax)) + |
527 "\" to an uncompressed syntax for modality: " + | 506 "\" to an uncompressed syntax for modality: " + |
528 GetParameters().GetRemoteModality().GetApplicationEntityTitle()); | 507 GetParameters().GetRemoteModality().GetApplicationEntityTitle()); |
529 } | 508 } |
509 else if (transcoded->HasSopInstanceUidChanged()) | |
510 { | |
511 throw OrthancException(ErrorCode_Plugin, "The transcoder has changed the SOP " | |
512 "instance UID while transcoding to an uncompressed transfer syntax"); | |
513 } | |
530 else | 514 else |
531 { | 515 { |
532 DicomTransferSyntax transcodedSyntax; | 516 DicomTransferSyntax transcodedSyntax; |
533 | 517 |
534 // Sanity check | 518 // Sanity check |
535 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(transcodedSyntax, *transcoded) || | 519 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(transcodedSyntax, transcoded->GetDicom()) || |
536 accepted.find(transcodedSyntax) == accepted.end()) | 520 accepted.find(transcodedSyntax) == accepted.end()) |
537 { | 521 { |
538 throw OrthancException(ErrorCode_InternalError); | 522 throw OrthancException(ErrorCode_InternalError); |
539 } | 523 } |
540 else | 524 else |
541 { | 525 { |
542 Store(sopClassUid, sopInstanceUid, *transcoded, | 526 Store(sopClassUid, sopInstanceUid, transcoded->GetDicom(), |
543 hasMoveOriginator, moveOriginatorAET, moveOriginatorID); | 527 hasMoveOriginator, moveOriginatorAET, moveOriginatorID); |
544 } | 528 } |
545 } | 529 } |
546 } | 530 } |
547 } | 531 } |