From da626417557034a6838c613ed1ccb1acc6864e9a Mon Sep 17 00:00:00 2001 From: jpr Date: Thu, 26 Jun 2003 13:07:01 +0000 Subject: [PATCH] Adding : std::string TranslateToKey(guint16 group, guint16 element); (because a tag key may not be associated to a dictionary) int gdcmHeader::CheckIfExistByNumber(guint16 Group, guint16 Elem); (we need to know if we want to build a kosher Dicom Header) int gdcmElValSet::CheckIfExistByNumber(guint16 Group, guint16 Elem); Well .... private fields *do* exist in C++ --- src/gdcmElValSet.cxx | 13 +++++++++++++ src/gdcmElValSet.h | 3 ++- src/gdcmException.h | 2 +- src/gdcmHeader.cxx | 18 +++++++++++++++--- src/gdcmHeader.h | 3 ++- src/gdcmUtil.cxx | 19 ++++++++++++++++++- src/gdcmUtil.h | 4 +++- 7 files changed, 54 insertions(+), 8 deletions(-) diff --git a/src/gdcmElValSet.cxx b/src/gdcmElValSet.cxx index 2d15a179..db65110c 100644 --- a/src/gdcmElValSet.cxx +++ b/src/gdcmElValSet.cxx @@ -34,6 +34,19 @@ void gdcmElValSet::Add(gdcmElValue * newElValue) { NameHt[newElValue->GetName()] = newElValue; } + +/** + * \ingroup gdcmElValSet + * \brief Checks if a given Dicom element exists + * \ within a ElValSet + * @param + * @return + */ +int gdcmElValSet::CheckIfExistByNumber(guint16 Group, guint16 Elem ) { + string key = TranslateToKey(Group, Elem ); + return (tagHt.count(key)); +} + /** * \ingroup gdcmElValSet * \brief diff --git a/src/gdcmElValSet.h b/src/gdcmElValSet.h index aa5be34e..37283f13 100644 --- a/src/gdcmElValSet.h +++ b/src/gdcmElValSet.h @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/Attic/gdcmElValSet.h,v 1.14 2003/06/17 17:44:48 jpr Exp $ +// $Header: /cvs/public/gdcm/src/Attic/gdcmElValSet.h,v 1.15 2003/06/26 13:07:01 jpr Exp $ #ifndef GDCMELVALSET_H #define GDCMELVALSET_H @@ -42,6 +42,7 @@ public: int SetElValueLengthByName (guint32 l, std::string TagName); guint32 GenerateFreeTagKeyInGroup(guint16 group); + int CheckIfExistByNumber(guint16 Group, guint16 Elem ); private: void UpdateGroupLength(bool SkipSequence = false, FileType type = ImplicitVR); diff --git a/src/gdcmException.h b/src/gdcmException.h index 250fb605..73710ae0 100644 --- a/src/gdcmException.h +++ b/src/gdcmException.h @@ -1,4 +1,4 @@ -// gdcm.h +// gdcmExeption.h // gdcmlib Intro: // * gdcmlib is a library dedicated to reading and writing dicom files. diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 06186911..3e874633 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.cxx,v 1.70 2003/06/20 14:17:47 jpr Exp $ +// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.cxx,v 1.71 2003/06/26 13:07:01 jpr Exp $ #include #include @@ -647,7 +647,7 @@ void gdcmHeader::FixFoundLength(gdcmElValue * ElVal, guint32 FoundLength) { guint16 length16; if( (element == 0x0010) && (group == 0x7fe0) ) {// JPR - dbg.SetDebug(1); + dbg.SetDebug(10); dbg.Verbose(2, "gdcmHeader::FindLength: ", // JPR "on est sur 7fe0 0010"); } @@ -1063,7 +1063,19 @@ int gdcmHeader::ReplaceOrCreateByNumber(char* Value, guint16 Group, guint16 Elem string v = Value; PubElValSet.SetElValueByNumber(v, Group, Elem); return(1); -} +} + +/** + * \ingroup gdcmHeader + * \brief TODO + * @param + */ + + int gdcmHeader::CheckIfExistByNumber(guint16 Group, guint16 Elem ) { + return (PubElValSet.CheckIfExistByNumber(Group, Elem)); + } + + /** * \ingroup gdcmHeader * \brief Build a new Element Value from all the low level arguments. diff --git a/src/gdcmHeader.h b/src/gdcmHeader.h index 2ad78057..7d0249c2 100644 --- a/src/gdcmHeader.h +++ b/src/gdcmHeader.h @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.h,v 1.28 2003/06/20 14:17:47 jpr Exp $ +// $Header: /cvs/public/gdcm/src/Attic/gdcmHeader.h,v 1.29 2003/06/26 13:07:01 jpr Exp $ #ifndef GDCMHEADER_H #define GDCMHEADER_H @@ -105,6 +105,7 @@ protected: FileType filetype; gdcmElValue * GetElValueByNumber(guint16 group, guint16 element); + int CheckIfExistByNumber(guint16 Group, guint16 Elem ); guint16 SwapShort(guint16); // needed by gdcmFile guint32 SwapLong(guint32); // for JPEG Files :-( diff --git a/src/gdcmUtil.cxx b/src/gdcmUtil.cxx index bc1d3bda..f8d5144f 100644 --- a/src/gdcmUtil.cxx +++ b/src/gdcmUtil.cxx @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/gdcmUtil.cxx,v 1.12 2003/06/17 17:44:48 jpr Exp $ +// $Header: /cvs/public/gdcm/src/gdcmUtil.cxx,v 1.13 2003/06/26 13:07:01 jpr Exp $ #include #include // For isspace @@ -152,3 +152,20 @@ char * _CreateCleanString(string s) { return d; } +/////////////////////////////////////////////////////////////////////////// +// +// because it may not be associated to a dictionary ... + +std::string TranslateToKey(guint16 group, guint16 element) { + char trash[10]; + string key; + // CLEAN ME: better call the iostream<< with the hex manipulator on. + // This requires some reading of the stdlibC++ sources to make the + // proper call (or copy). + sprintf(trash, "%04x|%04x", group , element); + key = trash; // Convertion through assignement + return key; +} + + + diff --git a/src/gdcmUtil.h b/src/gdcmUtil.h index 2b6febaa..d50b1e41 100644 --- a/src/gdcmUtil.h +++ b/src/gdcmUtil.h @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/gdcmUtil.h,v 1.11 2003/06/17 17:44:48 jpr Exp $ +// $Header: /cvs/public/gdcm/src/gdcmUtil.h,v 1.12 2003/06/26 13:07:01 jpr Exp $ #ifndef GDCMUTIL_H #define GDCMUTIL_H @@ -48,5 +48,7 @@ extern gdcmDebug dbg; char * _cleanString(char *v); char * _CreateCleanString(string s); +std::string TranslateToKey(guint16 group, guint16 element); + #endif -- 2.45.1