changeset 3881:f23ab7829a8d transcoding

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 05 May 2020 10:35:39 +0200
parents cdd0cb5ec4e4
children 904575738462
files Core/DicomNetworking/DicomStoreUserConnection.cpp Core/DicomNetworking/DicomStoreUserConnection.h Core/DicomParsing/FromDcmtkBridge.cpp Core/DicomParsing/FromDcmtkBridge.h Core/DicomParsing/ParsedDicomFile.cpp
diffstat 5 files changed, 49 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomNetworking/DicomStoreUserConnection.cpp	Mon May 04 22:10:55 2020 +0200
+++ b/Core/DicomNetworking/DicomStoreUserConnection.cpp	Tue May 05 10:35:39 2020 +0200
@@ -178,7 +178,6 @@
 
   void DicomStoreUserConnection::LookupParameters(std::string& sopClassUid,
                                                   std::string& sopInstanceUid,
-                                                  DicomTransferSyntax& transferSyntax,
                                                   DcmDataset& dataset)
   {
     OFString a, b;
@@ -192,13 +191,6 @@
 
     sopClassUid.assign(a.c_str());
     sopInstanceUid.assign(b.c_str());
-
-    if (!FromDcmtkBridge::LookupOrthancTransferSyntax(
-          transferSyntax, dataset.getOriginalXfer()))
-    {
-      throw OrthancException(ErrorCode_InternalError,
-                             "Unknown transfer syntax from DCMTK");
-    }
   }
   
 
@@ -314,14 +306,20 @@
   }
 
 
-  void DicomStoreUserConnection::StoreInternal(std::string& sopClassUid,
-                                               std::string& sopInstanceUid,
-                                               DcmDataset& dataset,
-                                               const std::string& moveOriginatorAET,
-                                               uint16_t moveOriginatorID)
+  void DicomStoreUserConnection::Store(std::string& sopClassUid,
+                                       std::string& sopInstanceUid,
+                                       DcmDataset& dataset,
+                                       const std::string& moveOriginatorAET,
+                                       uint16_t moveOriginatorID)
   {
+    LookupParameters(sopClassUid, sopInstanceUid, dataset);
+
     DicomTransferSyntax transferSyntax;
-    LookupParameters(sopClassUid, sopInstanceUid, transferSyntax, dataset);
+    if (!FromDcmtkBridge::LookupOrthancTransferSyntax(transferSyntax, dataset))
+    {
+      throw OrthancException(ErrorCode_InternalError,
+                             "Unknown transfer syntax from DCMTK");
+    }
 
     uint8_t presID;
     if (!NegotiatePresentationContext(presID, sopClassUid, transferSyntax))
@@ -405,8 +403,8 @@
       throw OrthancException(ErrorCode_InternalError);
     }
     
-    StoreInternal(sopClassUid, sopInstanceUid, *dicom->getDataset(),
-                  moveOriginatorAET, moveOriginatorID);
+    Store(sopClassUid, sopInstanceUid, *dicom->getDataset(),
+          moveOriginatorAET, moveOriginatorID);
   }
 
 
--- a/Core/DicomNetworking/DicomStoreUserConnection.h	Mon May 04 22:10:55 2020 +0200
+++ b/Core/DicomNetworking/DicomStoreUserConnection.h	Tue May 05 10:35:39 2020 +0200
@@ -88,7 +88,6 @@
 
     void LookupParameters(std::string& sopClassUid,
                           std::string& sopInstanceUid,
-                          DicomTransferSyntax& transferSyntax,
                           DcmDataset& dataset);
 
     bool LookupPresentationContext(uint8_t& presentationContextId,
@@ -99,12 +98,6 @@
                                       const std::string& sopClassUid,
                                       DicomTransferSyntax transferSyntax);
 
-    void StoreInternal(std::string& sopClassUid,
-                       std::string& sopInstanceUid,
-                       DcmDataset& dataset,
-                       const std::string& moveOriginatorAET,
-                       uint16_t moveOriginatorID);
-
   public:
     DicomStoreUserConnection(const DicomAssociationParameters& params);
     
@@ -148,6 +141,12 @@
 
     void Store(std::string& sopClassUid,
                std::string& sopInstanceUid,
+               DcmDataset& dataset,
+               const std::string& moveOriginatorAET,
+               uint16_t moveOriginatorID);
+
+    void Store(std::string& sopClassUid,
+               std::string& sopInstanceUid,
                const void* buffer,
                size_t size,
                const std::string& moveOriginatorAET,
@@ -155,6 +154,13 @@
 
     void Store(std::string& sopClassUid,
                std::string& sopInstanceUid,
+               DcmDataset& dataset)
+    {
+      Store(sopClassUid, sopInstanceUid, dataset, "", 0);  // Not a C-Move
+    }
+
+    void Store(std::string& sopClassUid,
+               std::string& sopInstanceUid,
                const void* buffer,
                size_t size)
     {
--- a/Core/DicomParsing/FromDcmtkBridge.cpp	Mon May 04 22:10:55 2020 +0200
+++ b/Core/DicomParsing/FromDcmtkBridge.cpp	Tue May 05 10:35:39 2020 +0200
@@ -2061,25 +2061,6 @@
   }
 
 
-  bool FromDcmtkBridge::LookupTransferSyntax(std::string& result,
-                                             DcmFileFormat& dicom)
-  {
-    const char* value = NULL;
-
-    if (dicom.getMetaInfo() != NULL &&
-        dicom.getMetaInfo()->findAndGetString(DCM_TransferSyntaxUID, value).good() &&
-        value != NULL)
-    {
-      result.assign(value);
-      return true;
-    }
-    else
-    {
-      return false;
-    }
-  }
-
-
 #if ORTHANC_ENABLE_LUA == 1
   void FromDcmtkBridge::ExecuteToDicom(DicomMap& target,
                                        LuaFunctionCall& call)
--- a/Core/DicomParsing/FromDcmtkBridge.h	Mon May 04 22:10:55 2020 +0200
+++ b/Core/DicomParsing/FromDcmtkBridge.h	Tue May 05 10:35:39 2020 +0200
@@ -251,9 +251,6 @@
     static void FromJson(DicomMap& values,
                          const Json::Value& result);
 
-    static bool LookupTransferSyntax(std::string& result,
-                                     DcmFileFormat& dicom);
-
 #if ORTHANC_ENABLE_LUA == 1
     static void ExecuteToDicom(DicomMap& target,
                                LuaFunctionCall& call);
@@ -287,5 +284,11 @@
 
     static bool LookupOrthancTransferSyntax(DicomTransferSyntax& target,
                                             E_TransferSyntax source);
+
+    static bool LookupOrthancTransferSyntax(DicomTransferSyntax& target,
+                                            const DcmDataset& dataset)
+    {
+      return LookupOrthancTransferSyntax(target, dataset.getOriginalXfer());
+    }
   };
 }
--- a/Core/DicomParsing/ParsedDicomFile.cpp	Mon May 04 22:10:55 2020 +0200
+++ b/Core/DicomParsing/ParsedDicomFile.cpp	Tue May 05 10:35:39 2020 +0200
@@ -1625,7 +1625,22 @@
 
   bool ParsedDicomFile::LookupTransferSyntax(std::string& result)
   {
-    return FromDcmtkBridge::LookupTransferSyntax(result, *pimpl_->file_);
+    // TODO - Shouldn't "dataset.getOriginalXfer()" be used instead of
+    // using the meta header?
+    const char* value = NULL;
+
+    assert(pimpl_->file_ != NULL);
+    if (pimpl_->file_->getMetaInfo() != NULL &&
+        pimpl_->file_->getMetaInfo()->findAndGetString(DCM_TransferSyntaxUID, value).good() &&
+        value != NULL)
+    {
+      result.assign(value);
+      return true;
+    }
+    else
+    {
+      return false;
+    }
   }