comparison Core/DicomNetworking/DicomStoreUserConnection.cpp @ 3958:596912ebab5f c-get

integration mainline->c-get
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 May 2020 17:03:24 +0200
parents 5fe8c6d3212e
children
comparison
equal deleted inserted replaced
3955:66879215cbf3 3958:596912ebab5f
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 497
498 // a reference to "*dicom", if the DCMTK transcoder was used 498 const std::string sourceUid = IDicomTranscoder::GetSopInstanceUid(source.GetParsed());
499 499
500 if (transcoded.get() == NULL || 500 IDicomTranscoder::DicomImage transcoded;
501 transcoded->GetDicom().getDataset() == NULL) 501 if (transcoder.Transcode(transcoded, source, uncompressedSyntaxes, false))
502 { 502 {
503 throw OrthancException( 503 if (sourceUid != IDicomTranscoder::GetSopInstanceUid(transcoded.GetParsed()))
504 ErrorCode_NotImplemented,
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 { 504 {
522 throw OrthancException(ErrorCode_InternalError); 505 throw OrthancException(ErrorCode_Plugin, "The transcoder has changed the SOP "
506 "instance UID while transcoding to an uncompressed transfer syntax");
523 } 507 }
524 else 508 else
525 { 509 {
526 Store(sopClassUid, sopInstanceUid, transcoded->GetDicom(), 510 DicomTransferSyntax transcodedSyntax;
527 hasMoveOriginator, moveOriginatorAET, moveOriginatorID); 511
512 // Sanity check
513 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(transcodedSyntax, transcoded.GetParsed()) ||
514 accepted.find(transcodedSyntax) == accepted.end())
515 {
516 throw OrthancException(ErrorCode_InternalError);
517 }
518 else
519 {
520 Store(sopClassUid, sopInstanceUid, transcoded.GetParsed(),
521 hasMoveOriginator, moveOriginatorAET, moveOriginatorID);
522 }
528 } 523 }
529 } 524 }
530 } 525 }
531 } 526 }
532 } 527 }