Mercurial > hg > orthanc
changeset 3909:6762a97deabc transcoding
removed useless abstraction IDicomTranscoder::TranscodeToBuffer()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 08 May 2020 11:40:12 +0200 |
parents | 89ebb37cee6a |
children | 1f71c2f20e16 |
files | Core/DicomParsing/DcmtkTranscoder.cpp Core/DicomParsing/DcmtkTranscoder.h Core/DicomParsing/IDicomTranscoder.h Core/DicomParsing/MemoryBufferTranscoder.cpp Core/DicomParsing/MemoryBufferTranscoder.h UnitTestsSources/FromDcmtkTests.cpp |
diffstat | 6 files changed, 6 insertions(+), 81 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/DicomParsing/DcmtkTranscoder.cpp Fri May 08 11:30:32 2020 +0200 +++ b/Core/DicomParsing/DcmtkTranscoder.cpp Fri May 08 11:40:12 2020 +0200 @@ -290,39 +290,6 @@ } - bool DcmtkTranscoder::TranscodeToBuffer(std::string& target, - bool& hasSopInstanceUidChanged /* out */, - const void* buffer, - size_t size, - const std::set<DicomTransferSyntax>& allowedSyntaxes, - bool allowNewSopInstanceUid) - { - std::unique_ptr<DcmFileFormat> dicom(FromDcmtkBridge::LoadFromMemoryBuffer(buffer, size)); - if (dicom.get() == NULL) - { - throw OrthancException(ErrorCode_BadFileFormat); - } - - std::unique_ptr<TranscodedDicom> transcoded( - TranscodeToParsed(*dicom, buffer, size, allowedSyntaxes, allowNewSopInstanceUid)); - - if (transcoded.get() == NULL) - { - return false; - } - else - { - if (transcoded->GetDicom().getDataset() == NULL) - { - throw OrthancException(ErrorCode_InternalError); - } - - FromDcmtkBridge::SaveToMemoryBuffer(target, *transcoded->GetDicom().getDataset()); - return true; - } - } - - bool DcmtkTranscoder::IsSupported(DicomTransferSyntax syntax) { if (syntax == DicomTransferSyntax_LittleEndianImplicit ||
--- a/Core/DicomParsing/DcmtkTranscoder.h Fri May 08 11:30:32 2020 +0200 +++ b/Core/DicomParsing/DcmtkTranscoder.h Fri May 08 11:40:12 2020 +0200 @@ -68,16 +68,8 @@ const std::set<DicomTransferSyntax>& allowedSyntaxes, bool allowNewSopInstanceUid); - virtual bool TranscodeToBuffer(std::string& target, - bool& hasSopInstanceUidChanged /* out */, - const void* buffer, - size_t size, - const std::set<DicomTransferSyntax>& allowedSyntaxes, - bool allowNewSopInstanceUid) ORTHANC_OVERRIDE; - static bool IsSupported(DicomTransferSyntax syntax); - virtual bool TranscodeParsedToBuffer(std::string& target /* out */, DicomTransferSyntax& sourceSyntax /* out */, DicomTransferSyntax& targetSyntax /* out */,
--- a/Core/DicomParsing/IDicomTranscoder.h Fri May 08 11:30:32 2020 +0200 +++ b/Core/DicomParsing/IDicomTranscoder.h Fri May 08 11:40:12 2020 +0200 @@ -55,13 +55,6 @@ { } - virtual bool TranscodeToBuffer(std::string& target, - bool& hasSopInstanceUidChanged /* out */, - const void* buffer, - size_t size, - const std::set<DicomTransferSyntax>& allowedSyntaxes, - bool allowNewSopInstanceUid) = 0; - virtual bool TranscodeParsedToBuffer(std::string& target /* out */, DicomTransferSyntax& sourceSyntax /* out */, DicomTransferSyntax& targetSyntax /* out */,
--- a/Core/DicomParsing/MemoryBufferTranscoder.cpp Fri May 08 11:30:32 2020 +0200 +++ b/Core/DicomParsing/MemoryBufferTranscoder.cpp Fri May 08 11:40:12 2020 +0200 @@ -63,30 +63,6 @@ } - bool MemoryBufferTranscoder::TranscodeToBuffer(std::string& target, - bool& hasSopInstanceUidChanged, - const void* buffer, - size_t size, - const std::set<DicomTransferSyntax>& allowedSyntaxes, - bool allowNewSopInstanceUid) - { -#if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 - if (useDcmtk_) - { - if (dcmtk_.TranscodeToBuffer(target, hasSopInstanceUidChanged, buffer, - size, allowedSyntaxes, allowNewSopInstanceUid)) - { - return true; - } - } -#endif - - DicomTransferSyntax sourceSyntax, targetSyntax; - return Transcode(target, sourceSyntax, targetSyntax, hasSopInstanceUidChanged, buffer, size, - allowedSyntaxes, allowNewSopInstanceUid); - } - - bool MemoryBufferTranscoder::TranscodeParsedToBuffer( std::string& target /* out */, DicomTransferSyntax& sourceSyntax /* out */,
--- a/Core/DicomParsing/MemoryBufferTranscoder.h Fri May 08 11:30:32 2020 +0200 +++ b/Core/DicomParsing/MemoryBufferTranscoder.h Fri May 08 11:40:12 2020 +0200 @@ -77,13 +77,6 @@ return useDcmtk_; } - virtual bool TranscodeToBuffer(std::string& target, - bool& hasSopInstanceUidChanged /* out */, - const void* buffer, - size_t size, - const std::set<DicomTransferSyntax>& allowedSyntaxes, - bool allowNewSopInstanceUid) ORTHANC_OVERRIDE; - virtual bool TranscodeParsedToBuffer(std::string& target /* out */, DicomTransferSyntax& sourceSyntax /* out */, DicomTransferSyntax& targetSyntax /* out */,
--- a/UnitTestsSources/FromDcmtkTests.cpp Fri May 08 11:30:32 2020 +0200 +++ b/UnitTestsSources/FromDcmtkTests.cpp Fri May 08 11:40:12 2020 +0200 @@ -1993,14 +1993,18 @@ std::string t; bool hasSopInstanceUidChanged; - - if (!transcoder.TranscodeToBuffer(t, hasSopInstanceUidChanged, source.c_str(), source.size(), s, true)) + DicomTransferSyntax sourceSyntax2, targetSyntax; + + std::unique_ptr<DcmFileFormat> cloned(dynamic_cast<DcmFileFormat*>(toto->clone())); + if (!transcoder.TranscodeParsedToBuffer(t, sourceSyntax2, targetSyntax, hasSopInstanceUidChanged, *cloned, s, true)) { printf("**************** CANNOT: [%s] => [%s]\n", GetTransferSyntaxUid(sourceSyntax), GetTransferSyntaxUid(a)); } else { + ASSERT_EQ(targetSyntax, a); + ASSERT_EQ(sourceSyntax, sourceSyntax2); bool lossy = (a == DicomTransferSyntax_JPEGProcess1 || a == DicomTransferSyntax_JPEGProcess2_4 || a == DicomTransferSyntax_JPEGLSLossy);