changeset 6932:5e9dfa326055

enable support for OD, OL, UC, and UR in ToDcmtkBridge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 05 Jun 2026 17:25:30 +0200
parents e160f5ff7ebe
children 715d89b30809
files OrthancFramework/Resources/CheckValueRepresentations.py OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp OrthancFramework/Sources/DicomParsing/ToDcmtkBridge.cpp
diffstat 3 files changed, 48 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Resources/CheckValueRepresentations.py	Fri Jun 05 17:10:48 2026 +0200
+++ b/OrthancFramework/Resources/CheckValueRepresentations.py	Fri Jun 05 17:25:30 2026 +0200
@@ -110,7 +110,7 @@
 
     print('\nChecking EnumerationToString()')
 
-    func = re.search(r'EnumerationToString\(ValueRepresentation.*?ErrorCode_ParameterOutOfRange', content, re.DOTALL).group(0)
+    func = re.search(r'EnumerationToString\(ValueRepresentation.*?default', content, re.DOTALL).group(0)
     for name in names:
         if not ('case %s' % name) in func:
             print('  - Value representation not handled:', name)
@@ -122,7 +122,7 @@
 
     print('\nChecking StringToValueRepresentation()')
 
-    func = re.search(r'StringToValueRepresentation\(.*?ErrorCode_ParameterOutOfRange', content, re.DOTALL).group(0)
+    func = re.search(r'StringToValueRepresentation\(.*?throw OrthancException', content, re.DOTALL).group(0)
     for name in names:
         if not ('return %s' % name) in func:
             print('  - Value representation not handled:', name)
@@ -134,7 +134,7 @@
 
     print('\nChecking IsBinaryValueRepresentation()')
 
-    func = re.search(r'IsBinaryValueRepresentation\(.*?ErrorCode_ParameterOutOfRange', content, re.DOTALL).group(0)
+    func = re.search(r'IsBinaryValueRepresentation\(.*?default', content, re.DOTALL).group(0)
     for name in names:
         if not ('case %s' % name) in func:
             print('  - Value representation not handled:', name)
@@ -146,19 +146,35 @@
 
     print('\nChecking DicomMap::ValidateTag()')
 
-    func = re.search(r'ValidateTag\(.*?RemoveTagPadding', content, re.DOTALL).group(0)
+    func = re.search(r'ValidateTag\(.*?default', content, re.DOTALL).group(0)
     for name in names:
         if not ('case %s' % name) in func:
             print('  - Value representation not handled:', name)
 
 
 
+with open(os.path.join(BASE, 'OrthancFramework', 'Sources', 'DicomParsing', 'FromDcmtkBridge.cpp'), 'r') as f:
+    content = f.read()
+
+    print('\nChecking FromDcmtkBridge::Convert()')
+
+    func = re.search(r'ValueRepresentation FromDcmtkBridge::Convert.*?default', content, re.DOTALL).group(0)
+    for name in names:
+        if not ('return %s' % name) in func:
+            print('  - Value representation not handled:', name)
+
+    for vr in vrs:
+        if not ('case EVR_%s' % vr) in func:
+            print('  - Value representation not handled:', vr)
+
+
+
 with open(os.path.join(BASE, 'OrthancFramework', 'Sources', 'DicomParsing', 'ToDcmtkBridge.cpp'), 'r') as f:
     content = f.read()
 
     print('\nChecking ToDcmtkBridge::Convert()')
 
-    func = re.search(r'ToDcmtkBridge::Convert\(ValueRepresentation.*?ErrorCode_ParameterOutOfRange', content, re.DOTALL).group(0)
+    func = re.search(r'ToDcmtkBridge::Convert\(ValueRepresentation.*?default', content, re.DOTALL).group(0)
     for name in names:
         if not ('case %s' % name) in func:
             print('  - Value representation not handled:', name)
@@ -174,7 +190,7 @@
 
     print('\nChecking ConvertToDcmtkBridge::Convert(ValueRepresentation)')
 
-    func = re.search(r'OrthancPluginValueRepresentation Convert\(ValueRepresentation.*?ErrorCode_ParameterOutOfRange', content, re.DOTALL).group(0)
+    func = re.search(r'OrthancPluginValueRepresentation Convert\(ValueRepresentation.*?default', content, re.DOTALL).group(0)
     for name in names:
         if not ('case %s' % name) in func:
             print('  - Value representation not handled:', name)
@@ -186,7 +202,7 @@
 
     print('\nChecking ConvertToDcmtkBridge::Convert(OrthancPluginValueRepresentation)')
 
-    func = re.search(r'ValueRepresentation Convert\(OrthancPluginValueRepresentation.*?ErrorCode_ParameterOutOfRange', content, re.DOTALL).group(0)
+    func = re.search(r'ValueRepresentation Convert\(OrthancPluginValueRepresentation.*?default', content, re.DOTALL).group(0)
     for name in names:
         if not ('return %s' % name) in func:
             print('  - Value representation not handled:', name)
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Fri Jun 05 17:10:48 2026 +0200
+++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Fri Jun 05 17:25:30 2026 +0200
@@ -2028,7 +2028,7 @@
       case EVR_OF:
         return ValueRepresentation_OtherFloat;
 
-#if DCMTK_VERSION_NUMBER >= 362
+#if DCMTK_VERSION_NUMBER >= 361
       case EVR_OL:
         return ValueRepresentation_OtherLong;
 #endif
--- a/OrthancFramework/Sources/DicomParsing/ToDcmtkBridge.cpp	Fri Jun 05 17:10:48 2026 +0200
+++ b/OrthancFramework/Sources/DicomParsing/ToDcmtkBridge.cpp	Fri Jun 05 17:25:30 2026 +0200
@@ -75,16 +75,22 @@
       case ValueRepresentation_OtherByte:
         return EVR_OB;
 
-        // Not supported as of DCMTK 3.6.0
-        /*case ValueRepresentation_OtherDouble:
-          return EVR_OD;*/
+      case ValueRepresentation_OtherDouble:
+ #if DCMTK_VERSION_NUMBER >= 361
+        return EVR_OD;
+#else
+        throw OrthancException(ErrorCode_ParameterOutOfRange, "OD value representation is not supported, as using DCMTK <= 3.6.0");
+#endif
 
       case ValueRepresentation_OtherFloat:
         return EVR_OF;
 
-        // Not supported as of DCMTK 3.6.0
-        /*case ValueRepresentation_OtherLong:
-          return EVR_OL;*/
+      case ValueRepresentation_OtherLong:
+#if DCMTK_VERSION_NUMBER >= 361
+        return EVR_OL;
+#else
+        throw OrthancException(ErrorCode_ParameterOutOfRange, "OL value representation is not supported, as using DCMTK <= 3.6.0");
+#endif
 
       case ValueRepresentation_OtherWord:
         return EVR_OW;
@@ -110,9 +116,12 @@
       case ValueRepresentation_Time:
         return EVR_TM;
 
-        // Not supported as of DCMTK 3.6.0
-        /*case ValueRepresentation_UnlimitedCharacters:
-          return EVR_UC;*/
+      case ValueRepresentation_UnlimitedCharacters:
+#if DCMTK_VERSION_NUMBER >= 361
+        return EVR_UC;
+#else
+        throw OrthancException(ErrorCode_ParameterOutOfRange, "UC value representation is not supported, as using DCMTK <= 3.6.0");
+#endif
 
       case ValueRepresentation_UniqueIdentifier:
         return EVR_UI;
@@ -123,9 +132,12 @@
       case ValueRepresentation_Unknown:
         return EVR_UN;
 
-        // Not supported as of DCMTK 3.6.0
-        /*case ValueRepresentation_UniversalResource:
-          return EVR_UR;*/
+      case ValueRepresentation_UniversalResource:
+#if DCMTK_VERSION_NUMBER >= 361
+        return EVR_UR;
+#else
+        throw OrthancException(ErrorCode_ParameterOutOfRange, "UR value representation is not supported, as using DCMTK <= 3.6.0");
+#endif
 
       case ValueRepresentation_UnsignedShort:
         return EVR_US;