From 822a234a022899ba97ad11831df13ff009eaacd0 Mon Sep 17 00:00:00 2001 From: jpr Date: Wed, 12 Nov 2003 15:35:18 +0000 Subject: [PATCH] *ENH gdcmHeader constructor has one more parameter (default value : false) that allows the user to 'go inside' the SeQuences only if he wants to. gdcmElValSet:Print takes it into account --- ChangeLog | 11 +++++++++++ src/gdcmElValSet.cxx | 16 +++++++++------- src/gdcmHeader.cxx | 19 ++++++++++++++----- src/gdcmHeader.h | 28 +++++++++++++++++----------- 4 files changed, 51 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index b7666699..2a356594 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2003-11-12 Jean-Pierre Roux + *ENH gdcmHeader constructor has one more parameter (default value : false) + that allows the user to 'go inside' the SeQuences only + if he wants to. + gdcmElValSet:Print takes it into account + +2003-11-12 Mathieu Malaterre + *ENH: Update gdcmPython/CMakeLists + *FIX: (gdcmHeaderHelper) GetRescale and GetSlope + *FIX: (gdcmElValSet) char 'tag' was overiding private members (VC++) + 2003-11-10 Jean-Pierre Roux *FIX : gdcmHeader::LoadElements is now based on the ListTag listElem member, diff --git a/src/gdcmElValSet.cxx b/src/gdcmElValSet.cxx index 90860fae..4d5a8713 100644 --- a/src/gdcmElValSet.cxx +++ b/src/gdcmElValSet.cxx @@ -101,23 +101,25 @@ void gdcmElValSet::Print(std::ostream & os) { } std::cout << "------------ using listElem -----------------" << std::endl; - - //for (ListTag::iterator i = listElem.begin(); - + + guint32 lgth; char greltag[9]; //group element tag for (std::list::iterator i = listElem.begin(); i != listElem.end(); ++i){ - sprintf(greltag,"%04x|%04x",(*i)->GetGroup(),(*i)->GetElement()); g = (*i)->GetGroup(); e = (*i)->GetElement(); + sprintf(greltag,"%04x|%04x",g,e); v = (*i)->GetValue(); o = (*i)->GetOffset(); d2 = _CreateCleanString(v); // replace non printable characters by '.' - //os << std::hex <GetReadLength(); + os << greltag << ": lgth : "; + lgth = (*i)->GetReadLength(); + if ( lgth == 0xffffffff) + os << std::hex << lgth << std::dec ; + else + os << lgth; os << ", Offset : " << o; os << " x(" << std::hex << o << std::dec << ") "; os << "\t[" << (*i)->GetVR() << "]"; diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 50af0722..ddfe7557 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.cxx,v 1.114 2003/11/12 14:06:34 malaterre Exp $ +// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.cxx,v 1.115 2003/11/12 15:35:19 jpr Exp $ #include "gdcmHeader.h" @@ -38,7 +38,14 @@ void gdcmHeader::Initialise(void) { * @param InFilename * @param exception_on_error */ -gdcmHeader::gdcmHeader(const char *InFilename, bool exception_on_error) { +gdcmHeader::gdcmHeader(const char *InFilename, + bool exception_on_error, + bool enable_sequences ) { + if (enable_sequences) + enableSequences = 1; + else + enableSequences = 0; + SetMaxSizeLoadElementValue(_MaxSizeLoadElementValue_); filename = InFilename; Initialise(); @@ -629,9 +636,10 @@ bool gdcmHeader::IsDicomV3(void) { void gdcmHeader::FixFoundLength(gdcmElValue * ElVal, guint32 FoundLength) { ElVal->SetReadLength(FoundLength); // will be updated only if a bug is found - - if ( FoundLength == 0xffffffff) + + if ( FoundLength == 0xffffffff) { FoundLength = 0; + } // Sorry for the patch! // XMedCom did the trick to read some nasty GE images ... @@ -655,8 +663,9 @@ void gdcmHeader::FixFoundLength(gdcmElValue * ElVal, guint32 FoundLength) { } // end of fix - // to try to 'go inside' SeQuences (with length), and not to ship them + // to try to 'go inside' SeQuences (with length), and not to skip them else if ( ElVal->GetVR() == "SQ") { + if (enableSequences) // only if the user does want to ! FoundLength =0; } diff --git a/src/gdcmHeader.h b/src/gdcmHeader.h index 98ff1ab1..9a88dd53 100644 --- a/src/gdcmHeader.h +++ b/src/gdcmHeader.h @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.h,v 1.42 2003/11/10 09:21:40 jpr Exp $ +// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.h,v 1.43 2003/11/12 15:35:19 jpr Exp $ #ifndef GDCMHEADER_H #define GDCMHEADER_H @@ -56,7 +56,9 @@ private: gdcmElValSet ShaElValSet; /// Refering underlying filename. std::string filename; - + + int enableSequences; + // FIXME sw should be an enum e.g. //enum EndianType { //LittleEndian, @@ -85,20 +87,20 @@ private: void SetMaxSizeLoadElementValue(long); gdcmDictEntry * GetDictEntryByNumber(guint16, guint16); - gdcmDictEntry * GetDictEntryByName(std::string Name); + gdcmDictEntry * GetDictEntryByName (std::string Name); // ElValue related utilities gdcmElValue * ReadNextElement(void); gdcmElValue * NewElValueByNumber(guint16 group, guint16 element); - gdcmElValue * NewElValueByName(std::string Name); + gdcmElValue * NewElValueByName (std::string Name); - void FindLength(gdcmElValue *); - void FindVR(gdcmElValue *); - void LoadElementValue(gdcmElValue *); + void FindLength (gdcmElValue *); + void FindVR (gdcmElValue *); + void LoadElementValue (gdcmElValue *); void LoadElementValueSafe(gdcmElValue *); - void SkipElementValue(gdcmElValue *); - void FixFoundLength(gdcmElValue*, guint32); - bool IsAnInteger(gdcmElValue *); + void SkipElementValue (gdcmElValue *); + void FixFoundLength (gdcmElValue*, guint32); + bool IsAnInteger (gdcmElValue *); void LoadElements(void); protected: @@ -132,8 +134,12 @@ public: virtual void ParseHeader(bool exception_on_error = false) throw(gdcmFormatError); - gdcmHeader(const char *filename, bool exception_on_error = false); + gdcmHeader( bool exception_on_error = false); + gdcmHeader(const char *filename, + bool exception_on_error = false, + bool enable_sequences = false); + virtual ~gdcmHeader(); std::string GetFileName(void) {return filename;} -- 2.45.1