From: jpr Date: Thu, 9 Jan 2003 16:52:57 +0000 (+0000) Subject: Ajout fonctions X-Git-Tag: April2003~60 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=dc0c43e2f7912a4a0f70fc7f925c964823468f23;p=gdcm.git Ajout fonctions int gdcmHeader::SetPubElValByNumber(string content, guint16 group, guint16 element); int gdcmHeader::SetPubElValByName(string content, string TagName); int ElValSet::SetElValueByNumber(string content, guint32 group, guint32 element); int ElValSet::SetElValueByName(string content, string TagName); --- diff --git a/src/gdcm.h b/src/gdcm.h index 211afebe..20e75413 100644 --- a/src/gdcm.h +++ b/src/gdcm.h @@ -151,7 +151,7 @@ public: // combined with all software versions... typedef map TagHT; - // Table de Hachage (group,Elem) --> ligne du Dictionnaire Dicom + // Table de Hachage (group,Elem) --> pointeur vers une ligne du Dictionnaire Dicom typedef map TagHT; @@ -262,13 +262,13 @@ public: bool IsImplicitVr(void) { return ImplicitVr; }; void SetVR(string); string GetVR(void); - string GetValue(void) { return value; }; - guint32 GetLength(void) { return LgrElem; }; - size_t GetOffset(void) { return Offset; }; - guint16 GetGroup(void) { return entry->GetGroup(); }; + string GetValue(void) { return value; }; + guint32 GetLength(void) { return LgrElem; }; + size_t GetOffset(void) { return Offset; }; + guint16 GetGroup(void) { return entry->GetGroup(); }; guint16 GetElement(void) { return entry->GetElement(); }; - string GetKey(void) { return entry->GetKey(); }; - string GetName(void) { return entry->GetName();}; + string GetKey(void) { return entry->GetKey(); }; + string GetName(void) { return entry->GetName(); }; }; @@ -285,10 +285,11 @@ typedef map TagElValueNameHT; class GDCM_EXPORT ElValSet { // We need both accesses with a TagKey and the Dictentry.Name + TagElValueHT tagHt; TagElValueNameHT NameHt; -public: - void Add(ElValue*); +public: + void Add(ElValue*); void Print(ostream &); void PrintByName(ostream &); ElValue* GetElementByNumber(guint32 group, guint32 element); @@ -296,6 +297,9 @@ public: string GetElValueByNumber(guint32 group, guint32 element); string GetElValueByName (string); TagElValueHT & GetTagHt(void); + + int SetElValueByNumber(string content, guint32 group, guint32 element); + int SetElValueByName(string content, string TagName); }; @@ -355,6 +359,7 @@ private: // Qu'y a-t-il a corriger ? // // outside of the elements: + guint16 grPixel; guint16 numPixel; // Ne faudrait-il pas une indication sur la presence ou non @@ -472,12 +477,11 @@ public: string GetElValRepByName(string TagName); string GetElValRepByNumber(guint16 group, guint16 element); - // TODO Swig int SetPubElValByName(string content, string TagName); - // TODO Swig int SetPubElValByNumber(string content, guint16 group, guint16 element); + int SetPubElValByName(string content, string TagName); + int SetPubElValByNumber(string content, guint16 group, guint16 element); // TODO Swig int SetShaElValByName(string content, string ShadowTagName); // TODO Swig int SetShaElValByNumber(string content, guint16 group, guint16 element); - // TODO Swig int GetSwapCode(); }; // @@ -503,6 +507,7 @@ private: // Data pointe sur quoi? // sur les Pixels lus? // --> j'ajoute un champ public : Pixels + // (il faudra que l'utilisateur puisse modifier les pixels ?) void* Data; int Parsed; // weather allready parsed diff --git a/src/gdcmElValSet.cxx b/src/gdcmElValSet.cxx index 71f76056..1f0760a4 100644 --- a/src/gdcmElValSet.cxx +++ b/src/gdcmElValSet.cxx @@ -63,6 +63,20 @@ string ElValSet::GetElValueByNumber(guint32 group, guint32 element) { return tagHt.find(key)->second->GetValue(); } +int ElValSet::SetElValueByNumber(string content, guint32 group, guint32 element) { + TagKey key = gdcmDictEntry::TranslateToKey(group, element); + if ( ! tagHt.count(key)) + return 0; + if (tagHt.count(key) > 1) { + dbg.Verbose(0, "ElValSet::SetElValueByNumber", + "multiple entries for this key (FIXME) !"); + return (0); + } + + tagHt[key]->SetValue(content); + return(1); +} + string ElValSet::GetElValueByName(string TagName) { if ( ! NameHt.count(TagName)) return "gdcm::Unfound"; @@ -72,3 +86,15 @@ string ElValSet::GetElValueByName(string TagName) { return NameHt.find(TagName)->second->GetValue(); } +int ElValSet::SetElValueByName(string content, string TagName) { + if ( ! NameHt.count(TagName)) + return 0; + if (NameHt.count(TagName) > 1) { + dbg.Verbose(0, "ElValSet::SetElValue", + "multipe entries for this key (FIXME) !"); + return 0; + } + NameHt.find(TagName)->second->SetValue(content); +} + + diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index e9e31dc4..be4f259a 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -1084,6 +1084,33 @@ string gdcmHeader::GetElValRepByName(string TagName) { return GetShaElValRepByName(TagName); } +/** + * \ingroup gdcmHeader + * \brief Modifie la valeur d'un ElValue déja existant + * \ dans le PubElVals du gdcmHeader, + * \ accédé par ses numero de groupe et d'element. + */ +int gdcmHeader::SetPubElValByNumber(string content, guint16 group, guint16 element) { + //TagKey key = gdcmDictEntry::TranslateToKey(group, element); + //PubElVals.tagHt[key]->SetValue(content); + + return ( PubElVals.SetElValueByNumber (content, group, element) ); +} + + +/** + * \ingroup gdcmHeader + * \brief Modifie la valeur d'un ElValue déja existant + * \ dans le PubElVals du gdcmHeader, + * \ accédé par son nom + */ +int gdcmHeader::SetPubElValByName(string content, string TagName) { + //TagKey key = gdcmDictEntry::TranslateToKey(group, element); + //PubElVals.tagHt[key]->SetValue(content); + + return ( PubElVals.SetElValueByName (content, TagName) ); +} + /** * \ingroup gdcmHeader * \brief Parses the header of the file but does NOT load element values.