changeset 20:d5cd40f12c86

fix VR extraction
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 May 2015 12:56:32 +0200
parents 6a29dfe563b3
children 8d103f6d08bd
files Core/Dicom.cpp
diffstat 1 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Dicom.cpp	Wed May 20 12:09:38 2015 +0200
+++ b/Core/Dicom.cpp	Wed May 20 12:56:32 2015 +0200
@@ -177,11 +177,33 @@
     {
       const gdcm::DictEntry &entry = dictionary.GetDictEntry(element.GetTag());
       vr = entry.GetVR();
+
+      if (vr == gdcm::VR::OB_OW)
+      {
+        vr = gdcm::VR::OB;
+      }
     }
 
     isSequence = (vr == gdcm::VR::SQ);
 
-    return gdcm::VR::GetVRString(vr);
+    const char* str = gdcm::VR::GetVRString(vr);
+    if (isSequence)
+    {
+      return str;
+    }
+
+    if (str == NULL ||
+        strlen(str) != 2 ||
+        !(str[0] >= 'A' && str[0] <= 'Z') ||
+        !(str[1] >= 'A' && str[1] <= 'Z'))
+    {
+      printf("[%s]\n", str);
+      return "UN";
+    }
+    else
+    {
+      return str;
+    }
   }