6 TagElValueHT & ElValSet::GetTagHt(void) {
10 void ElValSet::Add(ElValue * newElValue) {
11 tagHt [newElValue->GetKey()] = newElValue;
12 NameHt[newElValue->GetName()] = newElValue;
15 void ElValSet::Print(ostream & os) {
16 for (TagElValueHT::iterator tag = tagHt.begin();
19 os << tag->first << ": ";
20 os << "[" << tag->second->GetValue() << "]";
21 os << "[" << tag->second->GetName() << "]";
22 os << "[" << tag->second->GetVR() << "]" << endl;
27 int ElValSet::Write(FILE * _fp) {
29 // ATTENTION : fonction non terminée (commitée a titre de precaution)
42 // parcourir la table pour recalculer la longueur des 'elements 0x0000'
43 // au cas ou un tag ai été ajouté par rapport à ce qui a été lu
44 // dans l'image native
46 // cf : code IdDcmWriteFile
49 for (TagElValueHT::iterator tag = tagHt.begin();
57 // resteront à tester les echecs en écriture
59 for (TagElValueHT::iterator tag = tagHt.begin();
64 // peut-on se passer des affectations?
65 // - passer l'adresse du resultat d'une fonction (???)
66 // - acceder au champ sans passer par un accesseur ?
68 gr = tag->second->GetGroup();
69 el = tag->second->GetElement();
70 lgr = tag->second->GetLength();
71 val = tag->second->GetValue().c_str();
72 vr = tag->second->GetVR();
74 fwrite ( &gr,(size_t)2 ,(size_t)1 ,_fp); //group
75 fwrite ( &el,(size_t)2 ,(size_t)1 ,_fp); //element
77 //fwrite ( vr,(size_t)2 ,(size_t)1 ,_fp); //VR
79 // On fait de l'implicit VR (penser a forcer le SYNTAX TRANSFERT UID)
81 fwrite ( &lgr,(size_t)4 ,(size_t)1 ,_fp); //lgr
83 if (vr == "US" || vr == "SS") {
84 val_int16 = atoi(val);
86 fwrite ( ptr,(size_t)2 ,(size_t)1 ,_fp);
89 if (vr == "UL" || vr == "SL") {
90 val_int32 = atoi(val);
92 fwrite ( ptr,(size_t)4 ,(size_t)1 ,_fp);
96 // Les pixels ne sont pas chargés dans l'element !
97 if ((gr == 0x7fe0) && (el == 0x0010) ) break;
99 fwrite ( val,(size_t)lgr ,(size_t)1 ,_fp); //valeur Elem
107 void ElValSet::PrintByName(ostream & os) {
108 for (TagElValueNameHT::iterator tag = NameHt.begin();
111 os << tag->first << ": ";
112 os << "[" << tag->second->GetValue() << "]";
113 os << "[" << tag->second->GetKey() << "]";
114 os << "[" << tag->second->GetVR() << "]" << endl;
118 ElValue* ElValSet::GetElementByNumber(guint32 group, guint32 element) {
119 TagKey key = gdcmDictEntry::TranslateToKey(group, element);
120 if ( ! tagHt.count(key))
122 if (tagHt.count(key) > 1)
123 dbg.Verbose(0, "ElValSet::GetElementByNumber",
124 "multiple entries for this key (FIXME) !");
125 return tagHt.find(key)->second;
128 ElValue* ElValSet::GetElementByName(string TagName) {
129 if ( ! NameHt.count(TagName))
131 if (NameHt.count(TagName) > 1)
132 dbg.Verbose(0, "ElValSet::GetElement",
133 "multipe entries for this key (FIXME) !");
134 return NameHt.find(TagName)->second;
137 string ElValSet::GetElValueByNumber(guint32 group, guint32 element) {
138 TagKey key = gdcmDictEntry::TranslateToKey(group, element);
139 if ( ! tagHt.count(key))
140 return "gdcm::Unfound";
141 if (tagHt.count(key) > 1)
142 dbg.Verbose(0, "ElValSet::GetElValueByNumber",
143 "multiple entries for this key (FIXME) !");
144 return tagHt.find(key)->second->GetValue();
147 int ElValSet::SetElValueByNumber(string content, guint32 group, guint32 element) {
148 TagKey key = gdcmDictEntry::TranslateToKey(group, element);
149 if ( ! tagHt.count(key))
151 if (tagHt.count(key) > 1) {
152 dbg.Verbose(0, "ElValSet::SetElValueByNumber",
153 "multiple entries for this key (FIXME) !");
157 tagHt[key]->SetValue(content);
161 string ElValSet::GetElValueByName(string TagName) {
162 if ( ! NameHt.count(TagName))
163 return "gdcm::Unfound";
164 if (NameHt.count(TagName) > 1)
165 dbg.Verbose(0, "ElValSet::GetElValue",
166 "multipe entries for this key (FIXME) !");
167 return NameHt.find(TagName)->second->GetValue();
170 int ElValSet::SetElValueByName(string content, string TagName) {
171 if ( ! NameHt.count(TagName))
173 if (NameHt.count(TagName) > 1) {
174 dbg.Verbose(0, "ElValSet::SetElValue",
175 "multipe entries for this key (FIXME) !");
178 NameHt.find(TagName)->second->SetValue(content);