changeset 3885:e23026566536 transcoding

removed unused functions
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 05 May 2020 14:52:47 +0200
parents 83061cdc7703
children b808958dff2a
files Core/DicomParsing/FromDcmtkBridge.cpp Core/DicomParsing/FromDcmtkBridge.h Resources/Graveyard/TestTranscoding.cpp UnitTestsSources/FromDcmtkTests.cpp
diffstat 4 files changed, 56 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomParsing/FromDcmtkBridge.cpp	Tue May 05 14:37:29 2020 +0200
+++ b/Core/DicomParsing/FromDcmtkBridge.cpp	Tue May 05 14:52:47 2020 +0200
@@ -1254,27 +1254,6 @@
   
 
   bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer,
-                                           DcmFileFormat& dicom,
-                                           DicomTransferSyntax syntax)
-  {
-    E_TransferSyntax xfer;
-    if (!LookupDcmtkTransferSyntax(xfer, syntax))
-    {
-      return false;
-    }
-    else if (!dicom.validateMetaInfo(xfer).good())
-    {
-      throw OrthancException(ErrorCode_InternalError,
-                             "Cannot setup the transfer syntax to write a DICOM instance");
-    }
-    else
-    {
-      return SaveToMemoryBufferInternal(buffer, dicom, xfer);
-    }
-  }
-
-
-  bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer,
                                            DcmDataset& dataSet)
   {
     // Determine the transfer syntax which shall be used to write the
@@ -1307,27 +1286,6 @@
   }
 
 
-  bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer,
-                                           DcmFileFormat& dicom)
-  {
-    E_TransferSyntax xfer = dicom.getDataset()->getCurrentXfer();
-    if (xfer == EXS_Unknown)
-    {
-      throw OrthancException(ErrorCode_InternalError,
-                             "Cannot write a DICOM instance with unknown transfer syntax");
-    }
-    else if (!dicom.validateMetaInfo(xfer).good())
-    {
-      throw OrthancException(ErrorCode_InternalError,
-                             "Cannot setup the transfer syntax to write a DICOM instance");
-    }
-    else
-    {
-      return SaveToMemoryBufferInternal(buffer, dicom, xfer);
-    }
-  }
-
-
   bool FromDcmtkBridge::Transcode(DcmFileFormat& dicom,
                                   DicomTransferSyntax syntax,
                                   const DcmRepresentationParameter* representation)
@@ -1338,7 +1296,10 @@
       throw OrthancException(ErrorCode_InternalError);
     }
     else
-    {     
+    {
+      DicomTransferSyntax sourceSyntax;
+      bool known = LookupOrthancTransferSyntax(sourceSyntax, dicom);
+
       if (!dicom.getDataset()->chooseRepresentation(xfer, representation).good() ||
           !dicom.getDataset()->canWriteXfer(xfer) ||
           !dicom.validateMetaInfo(xfer, EWM_updateMeta).good())
@@ -1349,8 +1310,7 @@
       {
         dicom.removeInvalidGroups();
 
-        DicomTransferSyntax sourceSyntax;
-        if (LookupOrthancTransferSyntax(sourceSyntax, dicom))
+        if (known)
         {
           LOG(INFO) << "Transcoded an image from transfer syntax "
                     << GetTransferSyntaxUid(sourceSyntax) << " to "
--- a/Core/DicomParsing/FromDcmtkBridge.h	Tue May 05 14:37:29 2020 +0200
+++ b/Core/DicomParsing/FromDcmtkBridge.h	Tue May 05 14:52:47 2020 +0200
@@ -203,15 +203,8 @@
     static std::string GenerateUniqueIdentifier(ResourceType level);
 
     static bool SaveToMemoryBuffer(std::string& buffer,
-                                   DcmFileFormat& dicom,
-                                   DicomTransferSyntax xfer);
-    
-    static bool SaveToMemoryBuffer(std::string& buffer,
                                    DcmDataset& dataSet);
 
-    static bool SaveToMemoryBuffer(std::string& buffer,
-                                   DcmFileFormat& dicom);
-
     static bool Transcode(DcmFileFormat& dicom,
                           DicomTransferSyntax syntax,
                           const DcmRepresentationParameter* representation);
--- a/Resources/Graveyard/TestTranscoding.cpp	Tue May 05 14:37:29 2020 +0200
+++ b/Resources/Graveyard/TestTranscoding.cpp	Tue May 05 14:52:47 2020 +0200
@@ -1,3 +1,48 @@
+  bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer,
+                                           DcmFileFormat& dicom,
+                                           DicomTransferSyntax syntax)
+  {
+    E_TransferSyntax xfer;
+    if (!LookupDcmtkTransferSyntax(xfer, syntax))
+    {
+      return false;
+    }
+    else if (!dicom.validateMetaInfo(xfer).good())
+    {
+      throw OrthancException(ErrorCode_InternalError,
+                             "Cannot setup the transfer syntax to write a DICOM instance");
+    }
+    else
+    {
+      return SaveToMemoryBufferInternal(buffer, dicom, xfer);
+    }
+  }
+
+
+  bool FromDcmtkBridge::SaveToMemoryBuffer(std::string& buffer,
+                                           DcmFileFormat& dicom)
+  {
+    E_TransferSyntax xfer = dicom.getDataset()->getCurrentXfer();
+    if (xfer == EXS_Unknown)
+    {
+      throw OrthancException(ErrorCode_InternalError,
+                             "Cannot write a DICOM instance with unknown transfer syntax");
+    }
+    else if (!dicom.validateMetaInfo(xfer).good())
+    {
+      throw OrthancException(ErrorCode_InternalError,
+                             "Cannot setup the transfer syntax to write a DICOM instance");
+    }
+    else
+    {
+      return SaveToMemoryBufferInternal(buffer, dicom, xfer);
+    }
+  }
+
+
+
+
+
 #include <dcmtk/dcmdata/dcostrmb.h>
 #include <dcmtk/dcmdata/dcpixel.h>
 #include <dcmtk/dcmdata/dcpxitem.h>
--- a/UnitTestsSources/FromDcmtkTests.cpp	Tue May 05 14:37:29 2020 +0200
+++ b/UnitTestsSources/FromDcmtkTests.cpp	Tue May 05 14:52:47 2020 +0200
@@ -2227,8 +2227,13 @@
   DicomAssociationParameters p;
   p.SetRemotePort(2000);
 
+  DicomStoreUserConnection scu(p);
+  scu.SetCommonClassesProposed(false);
+  scu.SetRetiredBigEndianProposed(true);
+
   DcmtkTranscoder transcoder;
-  
+
+  for (int j = 0; j < 2; j++)
   for (int i = 0; i <= DicomTransferSyntax_XML; i++)
   {
     DicomTransferSyntax a = (DicomTransferSyntax) i;
@@ -2242,10 +2247,6 @@
       std::string source;
       Orthanc::SystemToolbox::ReadFile(source, path);
 
-      DicomStoreUserConnection scu(p);
-      scu.SetCommonClassesProposed(false);
-      scu.SetRetiredBigEndianProposed(true);
-
       std::string c, i;
       try
       {