From: jpr Date: Mon, 10 Nov 2003 09:21:40 +0000 (+0000) Subject: *FIX : gdcmHeader::LoadElements is now based X-Git-Tag: Version0.3.1~44 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=f04b9ef9bad66e1847e8139db9cd4126e4340301;p=gdcm.git *FIX : gdcmHeader::LoadElements is now based on the ListTag listElem member, not longer on the TagElValueHT tagHt member *ENH : PrintPubElVal shows (temporarily) both results, with the tagHt member and the listElem member. (it's easier to 'see' the problems when using Printheader) --- diff --git a/src/gdcmElValSet.cxx b/src/gdcmElValSet.cxx index 91045a05..d9e8c39d 100644 --- a/src/gdcmElValSet.cxx +++ b/src/gdcmElValSet.cxx @@ -22,6 +22,11 @@ TagElValueHT & gdcmElValSet::GetTagHt(void) { return tagHt; } + +ListTag & gdcmElValSet::GetListElem(void) { + return listElem; +} + /** * \ingroup gdcmElValSet * \brief @@ -31,6 +36,11 @@ TagElValueHT & gdcmElValSet::GetTagHt(void) { void gdcmElValSet::Add(gdcmElValue * newElValue) { tagHt [newElValue->GetKey()] = newElValue; NameHt[newElValue->GetName()] = newElValue; + +// WARNING : push_bash in listElem ONLY during ParseHeader +// TODO : something to allow further Elements addition +// position to be taken care of ! + listElem.push_back(newElValue); } /** @@ -87,6 +97,45 @@ void gdcmElValSet::Print(std::ostream & os) { } os << std::endl; } + + std::cout << "----------------------------------------------" << std::endl; + + //for (ListTag::iterator i = listElem.begin(); + + char tag[9]; + + for (std::list::iterator i = listElem.begin(); + i != listElem.end(); + ++i){ + sprintf(tag,"%04x|%04x",(*i)->GetGroup(),(*i)->GetElement()); + g = (*i)->GetGroup(); + e = (*i)->GetElement(); + v = (*i)->GetValue(); + o = (*i)->GetOffset(); + d2 = _CreateCleanString(v); // replace non printable characters by '.' + //os << std::hex <GetLength(); + os << ", Offset : " << o; + os << " x(" << std::hex << o << std::dec << ") "; + os << "\t[" << (*i)->GetVR() << "]"; + os << "\t[" << (*i)->GetName() << "]"; + os << "\t[" << d2 << "]"; + + // Display the UID value (instead of displaying the rough code) + if (g == 0x0002) { // Any more to be displayed ? + if ( (e == 0x0010) || (e == 0x0002) ) + os << " ==>\t[" << ts->GetValue(v) << "]"; + } else { + if (g == 0x0008) { + if ( (e == 0x0016) || (e == 0x1150) ) + os << " ==>\t[" << ts->GetValue(v) << "]"; + } + } + os << std::endl; + + } + } /** diff --git a/src/gdcmElValSet.h b/src/gdcmElValSet.h index fe97e3c8..0d22c603 100644 --- a/src/gdcmElValSet.h +++ b/src/gdcmElValSet.h @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/Attic/gdcmElValSet.h,v 1.17 2003/10/02 11:26:15 malaterre Exp $ +// $Header: /cvs/public/gdcm/src/Attic/gdcmElValSet.h,v 1.18 2003/11/10 09:21:40 jpr Exp $ #ifndef GDCMELVALSET_H #define GDCMELVALSET_H @@ -8,19 +8,24 @@ #include // FIXME For FILE on GCC only #include +#include // for linking together *all* the Dicom Elements //////////////////////////////////////////////////////////////////////////// // Container for a set of successfully parsed ElValues. -typedef std::map TagElValueHT; +typedef std::map TagElValueHT; typedef std::map TagElValueNameHT; + +typedef std::string GroupKey; +typedef std::map GroupHT; + +typedef std::list ListTag; // for linking together the Elements class GDCM_EXPORT gdcmElValSet { TagElValueHT tagHt; // Both accesses with a TagKey or with a TagElValueNameHT NameHt; // the DictEntry.Name are required. - - typedef std::string GroupKey; - typedef std::map GroupHT; + ListTag listElem; + public: ~gdcmElValSet(); void Add(gdcmElValue*); @@ -35,6 +40,7 @@ public: std::string GetElValueByName (std::string); TagElValueHT & GetTagHt(void); + ListTag & GetListElem(void); int SetElValueByNumber(std::string content, guint16 group, guint16 element); int SetElValueByName (std::string content, std::string TagName); diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 6572f688..9cdc5beb 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.cxx,v 1.111 2003/11/07 14:34:50 jpr Exp $ +// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.cxx,v 1.112 2003/11/10 09:21:40 jpr Exp $ #include "gdcmHeader.h" @@ -923,16 +923,16 @@ void gdcmHeader::LoadElementValue(gdcmElValue * ElVal) { // qui pourrait ne pas etre generalisable // Well, I'm expecting your code !!! - // to try to 'go inside' the SeQuences + // the test was commented out to 'go inside' the SeQuences // we don't any longer skip them ! // if( vr == "SQ" ) // SkipLoad = true; - // A sequence "contains" a set of Elements. + // A SeQuence "contains" a set of Elements. // (fffe e000) tells us an Element is beginning // (fffe e00d) tells us an Element just ended - // (fffe e0dd) tells us the current SQuence just ended + // (fffe e0dd) tells us the current SeQuence just ended if( group == 0xfffe ) SkipLoad = true; @@ -957,6 +957,7 @@ void gdcmHeader::LoadElementValue(gdcmElValue * ElVal) { s << "gdcm::NotLoaded."; s << " Address:" << (long)ElVal->GetOffset(); s << " Length:" << ElVal->GetLength(); + s << " x(" << std::hex << ElVal->GetLength() << ")"; ElVal->SetValue(s.str()); return; } @@ -964,9 +965,9 @@ void gdcmHeader::LoadElementValue(gdcmElValue * ElVal) { // When an integer is expected, read and convert the following two or // four bytes properly i.e. as an integer as opposed to a string. - // pour les elements de Value Multiplicity > 1 - // on aura en fait une serie d'entiers - // on devrait pouvoir faire + compact (?) + // Actually, elements with Value Multiplicity > 1 + // contain a set of integers (not a single one) + // Any compacter code suggested (?) if ( IsAnInteger(ElVal) ) { guint32 NewInt; @@ -1133,7 +1134,6 @@ gdcmElValue* gdcmHeader::NewElValueByNumber(guint16 Group, guint16 Elem) { */ int gdcmHeader::ReplaceOrCreateByNumber(std::string Value, guint16 Group, guint16 Elem ) { - // TODO : FIXME JPRx // curieux, non ? // on (je) cree une Elvalue ne contenant pas de valeur @@ -1445,7 +1445,7 @@ std::string gdcmHeader::GetPubElValRepByNumber(guint16 group, guint16 element) { * \ingroup gdcmHeader * \brief Searches within the public dictionary for element value of * a given tag. - * @param TagName name of the researched element. + * @param TagName name of the searched element. * @return Corresponding element value when it exists, and the string * GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ @@ -1462,7 +1462,7 @@ std::string gdcmHeader::GetPubElValByName(std::string TagName) { * to convert the string typed content to caller's native type * (think of C++ vs Python). The VR is actually of a higher level * of semantics than just the native C++ type. - * @param TagName name of the researched element. + * @param TagName name of the searched element. * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ @@ -1477,8 +1477,8 @@ std::string gdcmHeader::GetPubElValRepByName(std::string TagName) { * \ingroup gdcmHeader * \brief Searches within elements parsed with the SHADOW dictionary * for the element value of a given tag. - * @param group Group of the researched tag. - * @param element Element of the researched tag. + * @param group Group of the searched tag. + * @param element Element of the searched tag. * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ @@ -1495,8 +1495,8 @@ std::string gdcmHeader::GetShaElValByNumber(guint16 group, guint16 element) { * to convert the string typed content to caller's native type * (think of C++ vs Python). The VR is actually of a higher level * of semantics than just the native C++ type. - * @param group Group of the researched tag. - * @param element Element of the researched tag. + * @param group Group of the searched tag. + * @param element Element of the searched tag. * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ @@ -1511,7 +1511,7 @@ std::string gdcmHeader::GetShaElValRepByNumber(guint16 group, guint16 element) { * \ingroup gdcmHeader * \brief Searches within the elements parsed with the shadow dictionary * for an element value of given tag. - * @param TagName name of the researched element. + * @param TagName name of the searched element. * @return Corresponding element value when it exists, and the string * GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ @@ -1528,7 +1528,7 @@ std::string gdcmHeader::GetShaElValByName(std::string TagName) { * to convert the string typed content to caller's native type * (think of C++ vs Python). The VR is actually of a higher level * of semantics than just the native C++ type. - * @param TagName name of the researched element. + * @param TagName name of the searched element. * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ @@ -1544,8 +1544,8 @@ std::string gdcmHeader::GetShaElValRepByName(std::string TagName) { * \brief Searches within elements parsed with the public dictionary * and then within the elements parsed with the shadow dictionary * for the element value of a given tag. - * @param group Group of the researched tag. - * @param element Element of the researched tag. + * @param group Group of the searched tag. + * @param element Element of the searched tag. * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ @@ -1566,8 +1566,8 @@ std::string gdcmHeader::GetElValByNumber(guint16 group, guint16 element) { * to convert the string typed content to caller's native type * (think of C++ vs Python). The VR is actually of a higher level * of semantics than just the native C++ type. - * @param group Group of the researched tag. - * @param element Element of the researched tag. + * @param group Group of the searched tag. + * @param element Element of the searched tag. * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ @@ -1583,7 +1583,7 @@ std::string gdcmHeader::GetElValRepByNumber(guint16 group, guint16 element) { * \brief Searches within elements parsed with the public dictionary * and then within the elements parsed with the shadow dictionary * for the element value of a given tag. - * @param TagName name of the researched element. + * @param TagName name of the searched element. * @return Corresponding element value when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ @@ -1604,7 +1604,7 @@ std::string gdcmHeader::GetElValByName(std::string TagName) { * to convert the string typed content to caller's native type * (think of C++ vs Python). The VR is actually of a higher level * of semantics than just the native C++ type. - * @param TagName name of the researched element. + * @param TagName name of the searched element. * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ @@ -1698,7 +1698,7 @@ void gdcmHeader::ParseHeader(bool exception_on_error) throw(gdcmFormatError) { rewind(fp); CheckSwap(); - while ( (newElValue = ReadNextElement()) ) { + while ( (newElValue = ReadNextElement()) ) { SkipElementValue(newElValue); PubElValSet.Add(newElValue); } @@ -1706,7 +1706,7 @@ void gdcmHeader::ParseHeader(bool exception_on_error) throw(gdcmFormatError) { /** * \ingroup gdcmHeader - * \brief This predicate, based on hopefully reasonnable heuristics, + * \brief This predicate, based on hopefully reasonable heuristics, * decides whether or not the current gdcmHeader was properly parsed * and contains the mandatory information for being considered as * a well formed and usable image. @@ -1765,11 +1765,22 @@ gdcmElValue* gdcmHeader::NewManualElValToPubDict(std::string NewTagName, * public tag based hash table. */ void gdcmHeader::LoadElements(void) { - rewind(fp); - TagElValueHT ht = PubElValSet.GetTagHt(); - for (TagElValueHT::iterator tag = ht.begin(); tag != ht.end(); ++tag) { - LoadElementValue(tag->second); - } + rewind(fp); + + // We don't use any longer the HashTable, since a lot a stuff is missing + // we SeQuences were encountered + // + //TagElValueHT ht = PubElValSet.GetTagHt(); + //for (TagElValueHT::iterator tag = ht.begin(); tag != ht.end(); ++tag) { + // LoadElementValue(tag->second); + //} + + for (std::list::iterator i = GetListElem().begin(); + i != GetListElem().end(); + ++i){ + LoadElementValue(*i); + } + rewind(fp); // Load 'non string' values @@ -1829,8 +1840,7 @@ void gdcmHeader::PrintPubDict(std::ostream & os) { */ int gdcmHeader::Write(FILE * fp, FileType type) { - - // TODO : move the following lines (and a lot of others) + // TODO : move the following lines (and a lot of others, to be written) // to a future function CheckAndCorrectHeader if (type == ImplicitVR) { diff --git a/src/gdcmHeader.h b/src/gdcmHeader.h index d383aea4..98ff1ab1 100644 --- a/src/gdcmHeader.h +++ b/src/gdcmHeader.h @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.h,v 1.41 2003/10/30 17:06:00 jpr Exp $ +// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.h,v 1.42 2003/11/10 09:21:40 jpr Exp $ #ifndef GDCMHEADER_H #define GDCMHEADER_H @@ -157,6 +157,8 @@ public: void * GetPubElValVoidAreaByNumber(guint16 Group, guint16 Elem); void * LoadElementVoidArea(guint16 Group, guint16 Element); + ListTag & GetListElem(void) { return PubElValSet.GetListElem(); }; + TagElValueHT & GetPubElVal(void) { return PubElValSet.GetTagHt(); }; void PrintPubElVal(std::ostream & os = std::cout); void PrintPubDict (std::ostream & os = std::cout);