X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=inline;f=src%2FgdcmDict.cxx;h=70768a0d0afd73d23c7f86ddb242e67f6bbb3ce9;hb=5473319b31bf630394e7865122f1745ecc122a4b;hp=f21e37a1bd99b83623bbd576b96df65a97231a3a;hpb=70e24c6c61481f9836e26b6b44a9670d92a4f43b;p=gdcm.git diff --git a/src/gdcmDict.cxx b/src/gdcmDict.cxx index f21e37a1..70768a0d 100644 --- a/src/gdcmDict.cxx +++ b/src/gdcmDict.cxx @@ -1,15 +1,15 @@ +// gdcmDict.cxx + #include -#include "gdcmlib.h" +#include "gdcm.h" #include "gdcmUtil.h" -gdcmDict::gdcmDict(char * FileName) { +gdcmDict::gdcmDict(const char* FileName) { std::ifstream from(FileName); - dbg.Error(!from, "gdcmDictSet::gdcmDictSet:", - "can't open dictionary"); + dbg.Error(!from, "gdcmDict::gdcmDict: can't open dictionary", FileName); guint16 group, element; // CLEANME : use defines for all those constants char buff[1024]; - char trash[10]; TagKey key, vr, fourth, name; while (!from.eof()) { from >> hex >> group >> element; @@ -39,8 +39,68 @@ void gdcmDict::Print(ostream& os) { } } +// renvoie une ligne de Dictionnaire Dicom à partir de (numGroup, numElement) + gdcmDictEntry * gdcmDict::GetTag(guint32 group, guint32 element) { TagKey key = gdcmDictEntry::TranslateToKey(group, element); - TagHT::iterator found = entries.find(key); - return found->second; + if ( ! entries.count(key)) + return (gdcmDictEntry*)0; + if (entries.count(key) > 1) + dbg.Verbose(0, "gdcmDict::GetTag", + "multiple entries for this key (FIXME) !"); + return entries.find(key)->second; +} + + +int gdcmDict::ReplaceEntry(gdcmDictEntry* NewEntry) { + + // au cas ou la NewEntry serait incomplete + // Question : cela peut-il se produire ? + // + // --> NON : voir constructeur + //TagKey key; + //key = NewEntry->GetKey(); + //if (key =="") { + // NewEntry->gdcmDictEntry::SetKey( + // gdcmDictEntry::TranslateToKey(NewEntry->GetGroup(), NewEntry->GetElement()) + // ); + //} + + entries.erase (NewEntry->gdcmDictEntry::GetKey()); + entries[ NewEntry->GetKey()] = NewEntry; + return (1); + // Question : Dans quel cas ça peut planter ? } + + +int gdcmDict::AddNewEntry(gdcmDictEntry* NewEntry) { + + TagKey key; + key = NewEntry->GetKey(); + + if(entries.count(key) >= 1) { + printf("gdcmDict::AddNewEntry %s deja present\n", key.c_str()); + return(0); + } else { + entries[NewEntry->GetKey()] = NewEntry; + return(1); + } + } + + +int gdcmDict::RemoveEntry(TagKey key) { + if(entries.count(key) == 1) { + entries.erase(key); + return (1); + } else { + printf("gdcmDict::RemoveEntry %s non trouve\n", key.c_str()); + return (0); + } +} + + +int gdcmDict::RemoveEntry (guint16 group, guint16 element) { + + return( RemoveEntry(gdcmDictEntry::TranslateToKey(group, element)) ); +} +