From ebdb621996f41ad4ad6261525f1f38d779dde939 Mon Sep 17 00:00:00 2001 From: frog Date: Wed, 27 Nov 2002 22:28:43 +0000 Subject: [PATCH] * python/demo/*.py load.py extracted from test.py. Added explore.py that only displays required tags and testAll.py that parses all the files of the testsuite without using unittest. * python/testSuite.py other additional test on new files added. * Data/* new test files added accordingly to the testSuite. * src/gdcmHeader.cxx avoid overwriting of the dictionary when the vr in the file differs from the one of the dictionary. --- Frog --- ChangeLog | 9 +++++++++ src/gdcm.h | 2 +- src/gdcmHeader.cxx | 29 ++++++++++++++++++++++++----- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 36525709..89c9142d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2002-11-27 Eric Boix + * python/demo/*.py load.py extracted from test.py. Added explore.py + that only displays required tags and testAll.py that parses all + the files of the testsuite without using unittest. + * python/testSuite.py other additional test on new files added. + * Data/* new test files added accordingly to the testSuite. + * src/gdcmHeader.cxx avoid overwriting of the dictionary when + the vr in the file differs from the one of the dictionary. + 2002-11-20 Eric Boix * src/gdcm.h and gdcmHeader.cxx gdcm no longer loads all the elements values, but limits itself to values which are below a user specified diff --git a/src/gdcm.h b/src/gdcm.h index 22f3eb9e..c5ae0c6f 100644 --- a/src/gdcm.h +++ b/src/gdcm.h @@ -186,7 +186,7 @@ typedef map TagElValueHT; typedef map TagElValueNameHT; // Container for a set of succefully parsed ElValues. class GDCM_EXPORT ElValSet { - // We need both accesses with a TagKey and the Dicentry.Name + // We need both accesses with a TagKey and the Dictentry.Name TagElValueHT tagHt; TagElValueNameHT NameHt; public: diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index a2bece51..7922a455 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -226,7 +226,8 @@ void gdcmHeader::CheckSwap() } void gdcmHeader::SwitchSwapToBigEndian(void) { - dbg.Verbose(1, "gdcmHeader::FindLength", "Switching to BigEndian mode."); + dbg.Verbose(1, "gdcmHeader::SwitchSwapToBigEndian", + "Switching to BigEndian mode."); if ( sw == 0 ) { sw = 4321; return; @@ -283,6 +284,9 @@ void gdcmHeader::SwitchSwapToBigEndian(void) { */ void gdcmHeader::FindVR( ElValue *ElVal) { + if (filetype != ExplicitVR) + return; + char VR[3]; string vr; int lgrLue; @@ -296,9 +300,6 @@ void gdcmHeader::FindVR( ElValue *ElVal) { // the case. bool RealExplicit = true; - if (filetype != ExplicitVR) - return; - lgrLue=fread (&VR, (size_t)2,(size_t)1, fp); VR[2]=0; vr = string(VR); @@ -321,8 +322,26 @@ void gdcmHeader::FindVR( ElValue *ElVal) { RealExplicit = false; if ( RealExplicit ) { - if ( ElVal->IsVrUnknown() ) + if ( ElVal->IsVrUnknown() ) { + // When not a dictionary entry, we can safely overwrite the vr. ElVal->SetVR(vr); + return; + } + if ( ElVal->GetVR() == vr ) { + // The vr we just read and the dictionary agree. Nothing to do. + return; + } + // The vr present in the file and the dictionary disagree. We assume + // the file writer knew best and use the vr of the file. Since it would + // be unwise to overwrite the vr of a dictionary (since it would + // compromise it's next user), we need to clone the actual DictEntry + // and change the vr for the read one. + gdcmDictEntry* NewTag = new gdcmDictEntry(ElVal->GetGroup(), + ElVal->GetElement(), + vr, + "FIXME", + ElVal->GetName()); + ElVal->SetDictEntry(NewTag); return; } -- 2.48.1