]> Creatis software - gdcm.git/blobdiff - src/gdcmElValSet.cxx
* src/gdcmHeader.cxx: the constructor no longer exits when an
[gdcm.git] / src / gdcmElValSet.cxx
index d0f02984265484567960526d6bae1f62c836031d..70fd2a7a949702654f759191a2900cc89851038b 100644 (file)
@@ -82,8 +82,17 @@ int gdcmElValSet::SetElValueByNumber(string content,
        TagKey key = gdcmDictEntry::TranslateToKey(group, element);
        if ( ! tagHt.count(key))
                return 0;
-       tagHt[key]->SetValue(content);
-       tagHt[key]->SetLength(content.length());         
+       tagHt[key]->SetValue(content);  
+       string vr = tagHt[key]->GetVR();
+       guint32 lgr;
+
+       if( (vr == "US") || (vr == "SS") ) 
+          lgr = 2;
+       else if( (vr == "UL") || (vr == "SL") )
+          lgr = 4;
+       else
+          lgr = content.length();         
+       tagHt[key]->SetLength(lgr); 
        return 1;
 }
 
@@ -91,7 +100,21 @@ int gdcmElValSet::SetElValueByName(string content, string TagName) {
        if ( ! NameHt.count(TagName))
                return 0;
        NameHt[TagName]->SetValue(content);
-       NameHt[TagName]->SetLength(content.length());
+       string vr = NameHt[TagName]->GetVR();
+       guint32 lgr;
+
+       if( (vr == "US") || (vr == "SS") ) 
+          lgr = 2;
+       else if( (vr == "UL") || (vr == "SL") )
+          lgr = 4;        
+       else 
+          lgr = content.length();
+          
+// TODO : WARNING: le cas de l'element des pixels (7fe0,0010) n'est pas traite
+// par SetElValueByName
+// il faudra utiliser SetElValueByNumber
+          
+       NameHt[TagName]->SetLength(lgr);
        return 1;               
 }