+
+// 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);
+}
+
+/**
+ * \ingroup gdcmElValSet
+ * \brief Checks if a given Dicom element exists
+ * \ within a ElValSet
+ * @param Group
+ * @param Elem
+ * @return
+ */
+int gdcmElValSet::CheckIfExistByNumber(guint16 Group, guint16 Elem ) {
+ std::string key = TranslateToKey(Group, Elem );
+ return (tagHt.count(key));
+}
+
+/**
+ * \ingroup gdcmElValSet
+ * \brief
+ */
+void gdcmElValSet::Print(std::ostream & os) {
+
+ size_t o;
+ unsigned short int g, e;
+ TSKey v;
+ std::string d2;
+ gdcmTS * ts = gdcmGlobal::GetTS();
+
+ std::cout << "------------- using tagHt ---------------------" << std::endl;
+
+ for (TagElValueHT::iterator tag = tagHt.begin();
+ tag != tagHt.end();
+ ++tag){
+ g = tag->second->GetGroup();
+ e = tag->second->GetElement();
+ v = tag->second->GetValue();
+ o = tag->second->GetOffset();
+ d2 = _CreateCleanString(v); // replace non printable characters by '.'
+
+ os << tag->first << ": ";
+ os << " lgr : " << tag->second->GetLength();
+ os << ", Offset : " << o;
+ os << " x(" << std::hex << o << std::dec << ") ";
+ os << "\t[" << tag->second->GetVR() << "]";
+ os << "\t[" << tag->second->GetName() << "]";
+ os << "\t[" << d2 << "]";
+
+ // Display the UID value (instead of displaying the rough code)
+ if (g == 0x0002) { // Some 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;
+ }
+
+ std::cout << "------------ using listElem -------------------" << std::endl;
+
+ guint32 lgth;
+ char greltag[10]; //group element tag
+
+ for (ListTag::iterator i = listElem.begin();
+ i != listElem.end();
+ ++i){
+ g = (*i)->GetGroup();
+ e = (*i)->GetElement();
+ v = (*i)->GetValue();
+ o = (*i)->GetOffset();
+ sprintf(greltag,"%04x|%04x",g,e);
+ d2 = _CreateCleanString(v); // replace non printable characters by '.'
+ os << greltag << ": lgth : ";
+ lgth = (*i)->GetReadLength();
+ if ( lgth == 0xffffffff)
+ os << std::hex << lgth << std::dec ;
+ else
+ os << lgth;
+ 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;
+ }
+}
+
+/**
+ * \ingroup gdcmElValSet
+ * \brief
+ */
+void gdcmElValSet::PrintByName(std::ostream & os) {
+ for (TagElValueNameHT::iterator tag = NameHt.begin();
+ tag != NameHt.end();
+ ++tag){
+ os << tag->first << ": ";
+ os << "[" << tag->second->GetValue() << "]";
+ os << "[" << tag->second->GetKey() << "]";
+ os << "[" << tag->second->GetVR() << "]" << std::endl;
+ }
+}
+
+/**
+ * \ingroup gdcmElValSet
+ * \brief
+ * @param group
+ * @param element
+ * @return
+ */
+gdcmElValue* gdcmElValSet::GetElementByNumber(guint16 group, guint16 element) {
+ TagKey key = gdcmDictEntry::TranslateToKey(group, element);
+ if ( ! tagHt.count(key))
+ return (gdcmElValue*)0;
+ return tagHt.find(key)->second;
+}
+
+/**
+ * \ingroup gdcmElValSet
+ * \brief
+ * @return
+ */
+gdcmElValue* gdcmElValSet::GetElementByName(std::string TagName) {
+ if ( ! NameHt.count(TagName))
+ return (gdcmElValue*)0;
+ return NameHt.find(TagName)->second;
+}
+
+/**
+ * \ingroup gdcmElValSet
+ * \brief
+ * @param group
+ * @param element
+ * @return
+ */
+std::string gdcmElValSet::GetElValueByNumber(guint16 group, guint16 element) {
+ TagKey key = gdcmDictEntry::TranslateToKey(group, element);
+ if ( ! tagHt.count(key))
+ return GDCM_UNFOUND;
+ return tagHt.find(key)->second->GetValue();
+}
+
+/**
+ * \ingroup gdcmElValSet
+ * \brief
+ * @return
+ */
+std::string gdcmElValSet::GetElValueByName(std::string TagName) {
+ if ( ! NameHt.count(TagName))
+ return GDCM_UNFOUND;
+ return NameHt.find(TagName)->second->GetValue();
+}
+
+/**
+ * \ingroup gdcmElValSet
+ * \brief
+ * @param content
+ * @param group
+ * @param element
+ * @return
+ */
+int gdcmElValSet::SetElValueByNumber(std::string content,
+ guint16 group, guint16 element) {
+ TagKey key = gdcmDictEntry::TranslateToKey(group, element);
+ if ( ! tagHt.count(key))
+ return 0;
+ int l = content.length();
+ if(l%2) { // Odd length are padded with a space (020H).
+ l++;
+ content = content + '\0';
+ }
+ tagHt[key]->SetValue(content);
+
+ std::string vr = tagHt[key]->GetVR();
+ guint32 lgr;
+
+ if( (vr == "US") || (vr == "SS") )
+ lgr = 2;
+ else if( (vr == "UL") || (vr == "SL") )
+ lgr = 4;
+ else
+ lgr = l;
+ tagHt[key]->SetLength(lgr);
+ return 1;
+}
+
+/**
+ * \ingroup gdcmElValSet
+ * \brief
+ * @param content
+ * @param TagName
+ * @return
+ */
+int gdcmElValSet::SetElValueByName(std::string content, std::string TagName) {
+ if ( ! NameHt.count(TagName))
+ return 0;
+ int l = content.length();
+ if(l%2) { // Odd length are padded with a space (020H).
+ l++;
+ // Well. I know that '/0' is NOT a space
+ // but it doesn't work with a space.
+ // Use hexedit and see 0002|0010 value (Transfer Syntax UID)
+ content = content + '\0';
+ }
+ NameHt[TagName]->SetValue(content);
+
+ std::string vr = NameHt[TagName]->GetVR();
+ guint32 lgr;
+
+ if( (vr == "US") || (vr == "SS") )
+ lgr = 2;
+ else if( (vr == "UL") || (vr == "SL") )
+ lgr = 4;
+ else
+ lgr = content.length();
+
+// TODO : WARNING: le cas de l'element des pixels (7fe0,0010) n'est pas traite
+// par SetElValueByName
+// il faudra utiliser SetElValueByNumber
+
+ NameHt[TagName]->SetLength(lgr);
+ return 1;