From a4c5c2742a2db55720d4aedec1b2c51a94a19c60 Mon Sep 17 00:00:00 2001 From: jpr Date: Wed, 30 Apr 2003 15:52:09 +0000 Subject: [PATCH] gdcmElValSet::SetElValueByNumber and gdcmElValSet::SetElValueByName now write the accurate length when vr = {US, SS, UL, SL} --- src/gdcmElValSet.cxx | 26 +++++++++++++++++++++++--- src/gdcmHeader.cxx | 5 +++-- src/stamp-h.in | 1 - 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/gdcmElValSet.cxx b/src/gdcmElValSet.cxx index d0f02984..5d33ab64 100644 --- a/src/gdcmElValSet.cxx +++ b/src/gdcmElValSet.cxx @@ -82,8 +82,18 @@ 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 +101,17 @@ 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(); + + NameHt[TagName]->SetLength(lgr); return 1; } diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 10404615..52e340cb 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -968,10 +968,11 @@ bool gdcmHeader::IsAnInteger(gdcmElValue * ElVal) { if (length == 4) return true; else { - printf("Erroneous Group Length element length %d\n",length); + printf("Erroneous Group Length element length (%04x , %04x) : %d\n", + group, element,length); dbg.Error("gdcmHeader::IsAnInteger", - "Erroneous Group Length element length."); + "Erroneous Group Length element length."); } } diff --git a/src/stamp-h.in b/src/stamp-h.in index 9788f702..e69de29b 100644 --- a/src/stamp-h.in +++ b/src/stamp-h.in @@ -1 +0,0 @@ -timestamp -- 2.45.1