changeset 1928:84c7eaeb5244

Configuration::GetDefaultEncoding
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 21 Mar 2016 14:12:31 +0100
parents b60f27664b8f
children cda5b0ab4ce5
files OrthancServer/DicomInstanceToStore.cpp OrthancServer/DicomProtocol/DicomUserConnection.cpp OrthancServer/FromDcmtkBridge.cpp OrthancServer/FromDcmtkBridge.h OrthancServer/Internals/DicomFrameIndex.cpp OrthancServer/Internals/DicomImageDecoder.cpp OrthancServer/Internals/FindScp.cpp OrthancServer/Internals/MoveScp.cpp OrthancServer/Internals/StoreScp.cpp OrthancServer/OrthancInitialization.cpp OrthancServer/OrthancInitialization.h OrthancServer/ParsedDicomFile.cpp
diffstat 12 files changed, 63 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/DicomInstanceToStore.cpp	Mon Mar 21 13:31:56 2016 +0100
+++ b/OrthancServer/DicomInstanceToStore.cpp	Mon Mar 21 14:12:31 2016 +0100
@@ -34,6 +34,7 @@
 #include "DicomInstanceToStore.h"
 
 #include "FromDcmtkBridge.h"
+#include "OrthancInitialization.h"
 #include "../Core/Logging.h"
 
 #include <dcmtk/dcmdata/dcfilefo.h>
@@ -104,7 +105,8 @@
     {
       summary_.Allocate();
       FromDcmtkBridge::Convert(summary_.GetContent(), 
-                               *parsed_.GetContent().GetDcmtkObject().getDataset());
+                               *parsed_.GetContent().GetDcmtkObject().getDataset(),
+                               Configuration::GetDefaultEncoding());
     }
     
     if (!json_.HasContent())
@@ -114,7 +116,8 @@
                               *parsed_.GetContent().GetDcmtkObject().getDataset(),
                               DicomToJsonFormat_Full, 
                               DicomToJsonFlags_Default,
-                              ORTHANC_MAXIMUM_TAG_LENGTH);
+                              ORTHANC_MAXIMUM_TAG_LENGTH,
+                              Configuration::GetDefaultEncoding());
     }
   }
 
--- a/OrthancServer/DicomProtocol/DicomUserConnection.cpp	Mon Mar 21 13:31:56 2016 +0100
+++ b/OrthancServer/DicomProtocol/DicomUserConnection.cpp	Mon Mar 21 14:12:31 2016 +0100
@@ -86,6 +86,7 @@
 #include "../../Core/OrthancException.h"
 #include "../FromDcmtkBridge.h"
 #include "../ToDcmtkBridge.h"
+#include "../OrthancInitialization.h"
 
 #include <dcmtk/dcmdata/dcistrmb.h>
 #include <dcmtk/dcmdata/dcistrmf.h>
@@ -394,7 +395,8 @@
       else
       {
         DicomMap m;
-        FromDcmtkBridge::Convert(m, *responseIdentifiers);
+        FromDcmtkBridge::Convert(m, *responseIdentifiers, 
+                                 Configuration::GetDefaultEncoding());
 
         if (!m.HasTag(DICOM_TAG_QUERY_RETRIEVE_LEVEL))
         {
--- a/OrthancServer/FromDcmtkBridge.cpp	Mon Mar 21 13:31:56 2016 +0100
+++ b/OrthancServer/FromDcmtkBridge.cpp	Mon Mar 21 14:12:31 2016 +0100
@@ -37,9 +37,9 @@
 #endif
 
 #include "FromDcmtkBridge.h"
-#include "OrthancInitialization.h"
 #include "../Core/Logging.h"
 #include "../Core/Toolbox.h"
+#include "../Core/Uuid.h"
 #include "../Core/OrthancException.h"
 
 #include <list>
@@ -270,11 +270,10 @@
   }
 
 
-  Encoding FromDcmtkBridge::DetectEncoding(DcmDataset& dataset)
+  Encoding FromDcmtkBridge::DetectEncoding(DcmDataset& dataset,
+                                           Encoding defaultEncoding)
   {
-    // By default, Latin1 encoding is assumed
-    std::string s = Configuration::GetGlobalStringParameter("DefaultEncoding", "Latin1");
-    Encoding encoding = s.empty() ? Encoding_Latin1 : StringToEncoding(s.c_str());
+    Encoding encoding = defaultEncoding;
 
     OFString tmp;
     if (dataset.findAndGetOFString(DCM_SpecificCharacterSet, tmp).good())
@@ -305,9 +304,11 @@
   }
 
 
-  void FromDcmtkBridge::Convert(DicomMap& target, DcmDataset& dataset)
+  void FromDcmtkBridge::Convert(DicomMap& target, 
+                                DcmDataset& dataset,
+                                Encoding defaultEncoding)
   {
-    Encoding encoding = DetectEncoding(dataset);
+    Encoding encoding = DetectEncoding(dataset, defaultEncoding);
 
     target.Clear();
     for (unsigned long i = 0; i < dataset.card(); i++)
@@ -786,10 +787,11 @@
                                DcmDataset& dataset,
                                DicomToJsonFormat format,
                                DicomToJsonFlags flags,
-                               unsigned int maxStringLength)
+                               unsigned int maxStringLength,
+                               Encoding defaultEncoding)
   {
     target = Json::objectValue;
-    DatasetToJson(target, dataset, format, flags, maxStringLength, DetectEncoding(dataset));
+    DatasetToJson(target, dataset, format, flags, maxStringLength, DetectEncoding(dataset, defaultEncoding));
   }
 
 
--- a/OrthancServer/FromDcmtkBridge.h	Mon Mar 21 13:31:56 2016 +0100
+++ b/OrthancServer/FromDcmtkBridge.h	Mon Mar 21 14:12:31 2016 +0100
@@ -54,9 +54,12 @@
                                       unsigned int minMultiplicity,
                                       unsigned int maxMultiplicity);
 
-    static Encoding DetectEncoding(DcmDataset& dataset);
+    static Encoding DetectEncoding(DcmDataset& dataset,
+                                   Encoding defaultEncoding);
 
-    static void Convert(DicomMap& target, DcmDataset& dataset);
+    static void Convert(DicomMap& target, 
+                        DcmDataset& dataset,
+                        Encoding defaultEncoding);
 
     static DicomTag Convert(const DcmTag& tag);
 
@@ -79,7 +82,8 @@
                        DcmDataset& dataset,
                        DicomToJsonFormat format,
                        DicomToJsonFlags flags,
-                       unsigned int maxStringLength);
+                       unsigned int maxStringLength,
+                       Encoding defaultEncoding);
 
     static void ToJson(Json::Value& target, 
                        DcmMetaInfo& header,
--- a/OrthancServer/Internals/DicomFrameIndex.cpp	Mon Mar 21 13:31:56 2016 +0100
+++ b/OrthancServer/Internals/DicomFrameIndex.cpp	Mon Mar 21 14:12:31 2016 +0100
@@ -36,6 +36,7 @@
 #include "../../Core/OrthancException.h"
 #include "../../Core/DicomFormat/DicomImageInformation.h"
 #include "../FromDcmtkBridge.h"
+#include "../OrthancInitialization.h"
 #include "DicomImageDecoder.h"
 
 #include <boost/lexical_cast.hpp>
@@ -376,7 +377,8 @@
 
     // Extract information about the image structure
     DicomMap tags;
-    FromDcmtkBridge::Convert(tags, dataset);
+    FromDcmtkBridge::Convert(tags, dataset,
+                             Configuration::GetDefaultEncoding());
 
     DicomImageInformation information(tags);
 
--- a/OrthancServer/Internals/DicomImageDecoder.cpp	Mon Mar 21 13:31:56 2016 +0100
+++ b/OrthancServer/Internals/DicomImageDecoder.cpp	Mon Mar 21 14:12:31 2016 +0100
@@ -76,10 +76,6 @@
   =========================================================================*/
 
 
-
-#include "../PrecompiledHeadersServer.h"
-#include "DicomImageDecoder.h"
-
 #include "../../Core/Logging.h"
 #include "../../Core/OrthancException.h"
 #include "../../Core/Images/Image.h"
@@ -90,6 +86,7 @@
 #include "../ToDcmtkBridge.h"
 #include "../FromDcmtkBridge.h"
 #include "../ParsedDicomFile.h"
+#include "../OrthancInitialization.h"
 
 #include <boost/lexical_cast.hpp>
 
@@ -245,7 +242,8 @@
       // See also: http://support.dcmtk.org/wiki/dcmtk/howto/accessing-compressed-data
 
       DicomMap m;
-      FromDcmtkBridge::Convert(m, dataset);
+      FromDcmtkBridge::Convert(m, dataset,
+                               Configuration::GetDefaultEncoding());
 
       /**
        * Create an accessor to the raw values of the DICOM image.
@@ -317,7 +315,8 @@
                                                 bool ignorePhotometricInterpretation)
   {
     DicomMap m;
-    FromDcmtkBridge::Convert(m, dataset);
+    FromDcmtkBridge::Convert(m, dataset,
+                             Configuration::GetDefaultEncoding());
 
     DicomImageInformation info(m);
     PixelFormat format;
--- a/OrthancServer/Internals/FindScp.cpp	Mon Mar 21 13:31:56 2016 +0100
+++ b/OrthancServer/Internals/FindScp.cpp	Mon Mar 21 14:12:31 2016 +0100
@@ -86,6 +86,7 @@
 #include "../ToDcmtkBridge.h"
 #include "../../Core/Logging.h"
 #include "../../Core/OrthancException.h"
+#include "../OrthancInitialization.h"
 
 #include <dcmtk/dcmdata/dcfilefo.h>
 
@@ -170,7 +171,8 @@
               }
 
               DicomMap input;
-              FromDcmtkBridge::Convert(input, *requestIdentifiers);
+              FromDcmtkBridge::Convert(input, *requestIdentifiers,
+                                       Configuration::GetDefaultEncoding());
               data.findHandler_->Handle(data.answers_, input, sequencesToReturn,
                                         *data.remoteIp_, *data.remoteAet_,
                                         *data.calledAet_);
--- a/OrthancServer/Internals/MoveScp.cpp	Mon Mar 21 13:31:56 2016 +0100
+++ b/OrthancServer/Internals/MoveScp.cpp	Mon Mar 21 14:12:31 2016 +0100
@@ -86,6 +86,7 @@
 
 #include "../FromDcmtkBridge.h"
 #include "../ToDcmtkBridge.h"
+#include "../OrthancInitialization.h"
 #include "../../Core/Logging.h"
 #include "../../Core/OrthancException.h"
 
@@ -129,7 +130,8 @@
       if (data.lastRequest_ == NULL)
       {
         DicomMap input;
-        FromDcmtkBridge::Convert(input, *requestIdentifiers);
+        FromDcmtkBridge::Convert(input, *requestIdentifiers,
+                                 Configuration::GetDefaultEncoding());
 
         try
         {
--- a/OrthancServer/Internals/StoreScp.cpp	Mon Mar 21 13:31:56 2016 +0100
+++ b/OrthancServer/Internals/StoreScp.cpp	Mon Mar 21 14:12:31 2016 +0100
@@ -85,6 +85,7 @@
 #include "../FromDcmtkBridge.h"
 #include "../ServerToolbox.h"
 #include "../ToDcmtkBridge.h"
+#include "../OrthancInitialization.h"
 #include "../../Core/OrthancException.h"
 #include "../../Core/Logging.h"
 
@@ -167,11 +168,13 @@
 
           try
           {
-            FromDcmtkBridge::Convert(summary, **imageDataSet);
+            FromDcmtkBridge::Convert(summary, **imageDataSet,
+                                     Configuration::GetDefaultEncoding());
             FromDcmtkBridge::ToJson(dicomJson, **imageDataSet,
                                     DicomToJsonFormat_Full, 
                                     DicomToJsonFlags_Default, 
-                                    ORTHANC_MAXIMUM_TAG_LENGTH);
+                                    ORTHANC_MAXIMUM_TAG_LENGTH,
+                                    Configuration::GetDefaultEncoding());
 
             if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, **imageDataSet))
             {
--- a/OrthancServer/OrthancInitialization.cpp	Mon Mar 21 13:31:56 2016 +0100
+++ b/OrthancServer/OrthancInitialization.cpp	Mon Mar 21 14:12:31 2016 +0100
@@ -1031,4 +1031,13 @@
   {
     return fontRegistry_;
   }
+
+
+  Encoding Configuration::GetDefaultEncoding()
+  {
+    std::string s = GetGlobalStringParameter("DefaultEncoding", "Latin1");
+
+    // By default, Latin1 encoding is assumed
+    return s.empty() ? Encoding_Latin1 : StringToEncoding(s.c_str());
+  }
 }
--- a/OrthancServer/OrthancInitialization.h	Mon Mar 21 13:31:56 2016 +0100
+++ b/OrthancServer/OrthancInitialization.h	Mon Mar 21 14:12:31 2016 +0100
@@ -115,5 +115,7 @@
     static void FormatConfiguration(std::string& result);
 
     static const FontRegistry& GetFontRegistry();
+
+    static Encoding GetDefaultEncoding();
   };
 }
--- a/OrthancServer/ParsedDicomFile.cpp	Mon Mar 21 13:31:56 2016 +0100
+++ b/OrthancServer/ParsedDicomFile.cpp	Mon Mar 21 14:12:31 2016 +0100
@@ -1059,7 +1059,8 @@
   
   Encoding ParsedDicomFile::GetEncoding() const
   {
-    return FromDcmtkBridge::DetectEncoding(*pimpl_->file_->getDataset());
+    return FromDcmtkBridge::DetectEncoding(*pimpl_->file_->getDataset(),
+                                           Configuration::GetDefaultEncoding());
   }
 
 
@@ -1081,7 +1082,9 @@
                                DicomToJsonFlags flags,
                                unsigned int maxStringLength)
   {
-    FromDcmtkBridge::ToJson(target, *pimpl_->file_->getDataset(), format, flags, maxStringLength);
+    FromDcmtkBridge::ToJson(target, *pimpl_->file_->getDataset(),
+                            format, flags, maxStringLength,
+                            Configuration::GetDefaultEncoding());
   }
 
 
@@ -1184,7 +1187,8 @@
 
   void ParsedDicomFile::Convert(DicomMap& tags)
   {
-    FromDcmtkBridge::Convert(tags, *pimpl_->file_->getDataset());
+    FromDcmtkBridge::Convert(tags, *pimpl_->file_->getDataset(),
+                             Configuration::GetDefaultEncoding());
   }