changeset 202:e7f90aba3c97

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 26 Mar 2018 18:10:34 +0200
parents e9c7a78a3e77
children 431e991af593
files Resources/Orthanc/Core/DicomFormat/DicomTag.h Resources/Orthanc/Core/Enumerations.cpp Resources/Orthanc/Core/Enumerations.h Resources/Orthanc/Core/Logging.cpp Resources/Orthanc/Core/Logging.h Resources/Orthanc/Core/SystemToolbox.cpp Resources/Orthanc/NEWS
diffstat 7 files changed, 147 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/Orthanc/Core/DicomFormat/DicomTag.h	Fri Mar 23 11:59:22 2018 +0100
+++ b/Resources/Orthanc/Core/DicomFormat/DicomTag.h	Mon Mar 26 18:10:34 2018 +0200
@@ -193,4 +193,12 @@
   static const DicomTag DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES(0x0020, 0x1208);  
   static const DicomTag DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES(0x0020, 0x1209);  
   static const DicomTag DICOM_TAG_SOP_CLASSES_IN_STUDY(0x0008, 0x0062);  
+
+  // Tags to preserve relationships during anonymization
+  static const DicomTag DICOM_TAG_REFERENCED_IMAGE_SEQUENCE(0x0008, 0x1140);
+  static const DicomTag DICOM_TAG_REFERENCED_SOP_INSTANCE_UID(0x0008, 0x1155);
+  static const DicomTag DICOM_TAG_SOURCE_IMAGE_SEQUENCE(0x0008, 0x2112);
+  static const DicomTag DICOM_TAG_FRAME_OF_REFERENCE_UID(0x0020, 0x0052);
+  static const DicomTag DICOM_TAG_REFERENCED_FRAME_OF_REFERENCE_UID(0x3006, 0x0024);
+  static const DicomTag DICOM_TAG_RELATED_FRAME_OF_REFERENCE_UID(0x3006, 0x00c2);
 }
--- a/Resources/Orthanc/Core/Enumerations.cpp	Fri Mar 23 11:59:22 2018 +0100
+++ b/Resources/Orthanc/Core/Enumerations.cpp	Mon Mar 26 18:10:34 2018 +0200
@@ -878,6 +878,112 @@
   }
 
 
+  const char* EnumerationToString(ValueRepresentation vr)
+  {
+    switch (vr)
+    {
+      case ValueRepresentation_ApplicationEntity:     // AE
+        return "AE";
+
+      case ValueRepresentation_AgeString:             // AS
+        return "AS";
+
+      case ValueRepresentation_AttributeTag:          // AT (2 x uint16_t)
+        return "AT";
+
+      case ValueRepresentation_CodeString:            // CS
+        return "CS";
+
+      case ValueRepresentation_Date:                  // DA
+        return "DA";
+
+      case ValueRepresentation_DecimalString:         // DS
+        return "DS";
+
+      case ValueRepresentation_DateTime:              // DT
+        return "DT";
+
+      case ValueRepresentation_FloatingPointSingle:   // FL (float)
+        return "FL";
+
+      case ValueRepresentation_FloatingPointDouble:   // FD (double)
+        return "FD";
+
+      case ValueRepresentation_IntegerString:         // IS
+        return "IS";
+
+      case ValueRepresentation_LongString:            // LO
+        return "LO";
+
+      case ValueRepresentation_LongText:              // LT
+        return "LT";
+
+      case ValueRepresentation_OtherByte:             // OB
+        return "OB";
+
+      case ValueRepresentation_OtherDouble:           // OD
+        return "OD";
+
+      case ValueRepresentation_OtherFloat:            // OF
+        return "OF";
+
+      case ValueRepresentation_OtherLong:             // OL
+        return "OL";
+
+      case ValueRepresentation_OtherWord:             // OW
+        return "OW";
+
+      case ValueRepresentation_PersonName:            // PN
+        return "PN";
+
+      case ValueRepresentation_ShortString:           // SH
+        return "SH";
+
+      case ValueRepresentation_SignedLong:            // SL (int32_t)
+        return "SL";
+
+      case ValueRepresentation_Sequence:              // SQ
+        return "SQ";
+
+      case ValueRepresentation_SignedShort:           // SS (int16_t)
+        return "SS";
+
+      case ValueRepresentation_ShortText:             // ST
+        return "ST";
+
+      case ValueRepresentation_Time:                  // TM
+        return "TM";
+
+      case ValueRepresentation_UnlimitedCharacters:   // UC
+        return "UC";
+
+      case ValueRepresentation_UniqueIdentifier:      // UI (UID)
+        return "UI";
+
+      case ValueRepresentation_UnsignedLong:          // UL (uint32_t)
+        return "UL";
+
+      case ValueRepresentation_Unknown:               // UN
+        return "UN";
+
+      case ValueRepresentation_UniversalResource:     // UR (URI or URL)
+        return "UR";
+
+      case ValueRepresentation_UnsignedShort:         // US (uint16_t)
+        return "US";
+
+      case ValueRepresentation_UnlimitedText:         // UT
+        return "UT";
+
+      case ValueRepresentation_NotSupported:
+        return "Not supported";
+
+      default: 
+        throw OrthancException(ErrorCode_ParameterOutOfRange);
+    }
+  }
+
+
   Encoding StringToEncoding(const char* encoding)
   {
     std::string s(encoding);
--- a/Resources/Orthanc/Core/Enumerations.h	Fri Mar 23 11:59:22 2018 +0100
+++ b/Resources/Orthanc/Core/Enumerations.h	Mon Mar 26 18:10:34 2018 +0200
@@ -620,6 +620,8 @@
 
   const char* EnumerationToString(DicomVersion version);
 
+  const char* EnumerationToString(ValueRepresentation vr);
+
   Encoding StringToEncoding(const char* encoding);
 
   ResourceType StringToResourceType(const char* type);
--- a/Resources/Orthanc/Core/Logging.cpp	Fri Mar 23 11:59:22 2018 +0100
+++ b/Resources/Orthanc/Core/Logging.cpp	Mon Mar 26 18:10:34 2018 +0200
@@ -94,7 +94,7 @@
       context_ = context;
     }
 
-    InternalLogger::InternalLogger(Level level,
+    InternalLogger::InternalLogger(InternalLevel level,
                                    const char* file  /* ignored */,
                                    int line  /* ignored */) :
       level_(level)
@@ -107,19 +107,19 @@
       {
         switch (level_)
         {
-          case ERROR:
+          case InternalLevel_ERROR:
             OrthancPluginLogError(context_, message_.c_str());
             break;
 
-          case WARNING:
+          case InternalLevel_WARNING:
             OrthancPluginLogWarning(context_, message_.c_str());
             break;
 
-          case INFO:
+          case InternalLevel_INFO:
             OrthancPluginLogInfo(context_, message_.c_str());
             break;
 
-          case TRACE:
+          case InternalLevel_TRACE:
             // Not used by plugins
             break;
 
@@ -153,7 +153,7 @@
     static bool globalVerbose_ = false;
     static bool globalTrace_ = false;
     
-    InternalLogger::InternalLogger(Level level,
+    InternalLogger::InternalLogger(InternalLevel level,
                                    const char* file  /* ignored */,
                                    int line  /* ignored */) :
       level_(level)
@@ -164,22 +164,22 @@
     {
       switch (level_)
       {
-        case ERROR:
+        case InternalLevel_ERROR:
           fprintf(stderr, "E: %s\n", message_.c_str());
           break;
 
-        case WARNING:
+        case InternalLevel_WARNING:
           fprintf(stdout, "W: %s\n", message_.c_str());
           break;
 
-        case INFO:
+        case InternalLevel_INFO:
           if (globalVerbose_)
           {
             fprintf(stdout, "I: %s\n", message_.c_str());
           }
           break;
 
-        case TRACE:
+        case InternalLevel_TRACE:
           if (globalTrace_)
           {
             fprintf(stdout, "T: %s\n", message_.c_str());
--- a/Resources/Orthanc/Core/Logging.h	Fri Mar 23 11:59:22 2018 +0100
+++ b/Resources/Orthanc/Core/Logging.h	Mon Mar 26 18:10:34 2018 +0200
@@ -59,6 +59,8 @@
 #  include <orthanc/OrthancCPlugin.h>
 #endif
 
+#include <boost/lexical_cast.hpp>
+
 namespace Orthanc
 {
   namespace Logging
@@ -91,13 +93,8 @@
       {
       }
       
-      std::ostream& operator<< (const std::string& message)
-      {
-        return *this;
-      }
-
-      // This overload fixes build problems with Visual Studio 2015
-      std::ostream& operator<< (const char* message)
+      template <typename T>
+      std::ostream& operator<< (const T& message)
       {
         return *this;
       }
@@ -116,39 +113,38 @@
        ORTHANC_ENABLE_LOGGING_STDIO == 1)
 
 #  include <boost/noncopyable.hpp>
-#  include <boost/lexical_cast.hpp>
 #  define LOG(level)  ::Orthanc::Logging::InternalLogger \
-  (::Orthanc::Logging::level, __FILE__, __LINE__)
+  (::Orthanc::Logging::InternalLevel_ ## level, __FILE__, __LINE__)
 #  define VLOG(level) ::Orthanc::Logging::InternalLogger \
-  (::Orthanc::Logging::TRACE, __FILE__, __LINE__)
+  (::Orthanc::Logging::InternalLevel_TRACE, __FILE__, __LINE__)
 
 namespace Orthanc
 {
   namespace Logging
   {
-    enum Level
+    enum InternalLevel
     {
-      ERROR,
-      WARNING,
-      INFO,
-      TRACE
+      InternalLevel_ERROR,
+      InternalLevel_WARNING,
+      InternalLevel_INFO,
+      InternalLevel_TRACE
     };
     
     class InternalLogger : public boost::noncopyable
     {
     private:
-      Level       level_;
-      std::string message_;
+      InternalLevel  level_;
+      std::string    message_;
 
     public:
-      InternalLogger(Level level,
+      InternalLogger(InternalLevel level,
                      const char* file,
                      int line);
 
       ~InternalLogger();
       
       template <typename T>
-      InternalLogger& operator<< (T message)
+      InternalLogger& operator<< (const T& message)
       {
         message_ += boost::lexical_cast<std::string>(message);
         return *this;
@@ -186,15 +182,10 @@
 
       ~InternalLogger();
       
-      std::ostream& operator<< (const std::string& message)
+      template <typename T>
+      std::ostream& operator<< (const T& message)
       {
-        return (*stream_) << message;
-      }
-
-      // This overload fixes build problems with Visual Studio 2015
-      std::ostream& operator<< (const char* message)
-      {
-        return (*stream_) << message;
+        return (*stream_) << boost::lexical_cast<std::string>(message);
       }
     };
   }
--- a/Resources/Orthanc/Core/SystemToolbox.cpp	Fri Mar 23 11:59:22 2018 +0100
+++ b/Resources/Orthanc/Core/SystemToolbox.cpp	Mon Mar 26 18:10:34 2018 +0200
@@ -182,7 +182,7 @@
   {
     if (!IsRegularFile(path))
     {
-      LOG(ERROR) << std::string("The path does not point to a regular file: ") << path;
+      LOG(ERROR) << "The path does not point to a regular file: " << path;
       throw OrthancException(ErrorCode_RegularFileExpected);
     }
 
@@ -210,7 +210,7 @@
   {
     if (!IsRegularFile(path))
     {
-      LOG(ERROR) << std::string("The path does not point to a regular file: ") << path;
+      LOG(ERROR) << "The path does not point to a regular file: " << path;
       throw OrthancException(ErrorCode_RegularFileExpected);
     }
 
--- a/Resources/Orthanc/NEWS	Fri Mar 23 11:59:22 2018 +0100
+++ b/Resources/Orthanc/NEWS	Mon Mar 26 18:10:34 2018 +0200
@@ -11,6 +11,7 @@
 * Added "?expand" GET argument to "/peers" and "/modalities" routes
 * New URI: "/tools/create-media-extended" to generate a DICOMDIR
   archive from several resources, including additional type-3 tags
+* Preservation of UID relationships while anonymizing
 
 Lua
 ---