comparison Core/DicomNetworking/DicomStoreUserConnection.cpp @ 3945:0b3256c3ee14 transcoding

simplified IDicomTranscoder
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 19 May 2020 11:24:00 +0200
parents 1555feda39e2
children 5fe8c6d3212e
comparison
equal deleted inserted replaced
3944:aae045f802f4 3945:0b3256c3ee14
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<IDicomTranscoder::TranscodedDicom> transcoded( 494 IDicomTranscoder::DicomImage source;
495 transcoder.TranscodeToParsed(*dicom, buffer, size, uncompressedSyntaxes, false)); 495 source.AcquireParsed(dicom.release());
496 496 source.SetExternalBuffer(buffer, size);
497 // WARNING: Below this point, "transcoded->GetDicom()" is possibly
498 // a reference to "*dicom", if the DCMTK transcoder was used
499 497
500 if (transcoded.get() == NULL || 498 IDicomTranscoder::DicomImage transcoded;
501 transcoded->GetDicom().getDataset() == NULL) 499 bool hasSopInstanceUidChanged;
502 { 500 if (transcoder.Transcode(transcoded, hasSopInstanceUidChanged, source, uncompressedSyntaxes, false))
503 throw OrthancException( 501 {
504 ErrorCode_NotImplemented, 502 if (hasSopInstanceUidChanged)
505 "Cannot transcode from \"" + std::string(GetTransferSyntaxUid(inputSyntax)) +
506 "\" to an uncompressed syntax for modality: " +
507 GetParameters().GetRemoteModality().GetApplicationEntityTitle());
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 }
514 else
515 {
516 DicomTransferSyntax transcodedSyntax;
517
518 // Sanity check
519 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(transcodedSyntax, transcoded->GetDicom()) ||
520 accepted.find(transcodedSyntax) == accepted.end())
521 { 503 {
522 throw OrthancException(ErrorCode_InternalError); 504 throw OrthancException(ErrorCode_Plugin, "The transcoder has changed the SOP "
505 "instance UID while transcoding to an uncompressed transfer syntax");
523 } 506 }
524 else 507 else
525 { 508 {
526 Store(sopClassUid, sopInstanceUid, transcoded->GetDicom(), 509 DicomTransferSyntax transcodedSyntax;
527 hasMoveOriginator, moveOriginatorAET, moveOriginatorID); 510
511 // Sanity check
512 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(transcodedSyntax, transcoded.GetParsed()) ||
513 accepted.find(transcodedSyntax) == accepted.end())
514 {
515 throw OrthancException(ErrorCode_InternalError);
516 }
517 else
518 {
519 Store(sopClassUid, sopInstanceUid, transcoded.GetParsed(),
520 hasMoveOriginator, moveOriginatorAET, moveOriginatorID);
521 }
528 } 522 }
529 } 523 }
530 } 524 }
531 } 525 }
532 } 526 }