# include <sstream>
#endif
+#include <iomanip> // for std::ios::left, ...
+
//-----------------------------------------------------------------------------
// Constructor / Destructor
/**
delete EntryToDelete;
tag->second=NULL;
}
-
tagHT.clear();
}
gdcmTS * ts = gdcmGlobal::GetTS();
std::ostringstream s;
-
- s << "------------- using tagHT ---------------------" << std::endl;
+/*
+// DO NOT remove this code right now.
// Tag HT
s << "------------- using tagHT ---------------------" << std::endl;
}
s << std::endl;
}
-
+*/
// List element
guint32 lgth;
char greltag[10]; //group element tag
-
-
- s << "------------ using listEntries -------------------" << std::endl;
+
+ s << "------------ using listEntries ----------------" << std::endl;
+ char st[11];
for (ListTag::iterator i = listEntries.begin();
i != listEntries.end();
++i){
o = (*i)->GetOffset();
sprintf(greltag,"%04x|%04x",g,e);
d2 = _CreateCleanString(v); // replace non printable characters by '.'
- s << greltag << ": lgth : ";
+ s << greltag << " lg : ";
+ //lgth = (*i)->GetLength();
lgth = (*i)->GetReadLength();
- if ( lgth == 0xffffffff)
- s << std::hex << lgth << std::dec ;
- else
- s << lgth;
- s << ",\t Offset : " << o;
- s << " x(" << std::hex << o << std::dec << ") ";
- s << "\t[" << (*i)->GetVR() << "]";
- s << "\t[" << (*i)->GetName() << "]";
- s << "\t[" << d2 << "]";
-
- // Display the UID value (instead of displaying the rough code)
+ if (lgth == 0xffffffff) {
+ sprintf(st,"x(%ff)");
+ s.setf(std::ios::left);
+ s << std::setw(10-strlen(st)) << " ";
+ s << st << " ";
+ s.setf(std::ios::left);
+ s << std::setw(8) << "-1";
+ } else {
+ sprintf(st,"x(%x)",lgth);
+ s.setf(std::ios::left);
+ s << std::setw(10-strlen(st)) << " ";
+ s << st << " ";
+ s.setf(std::ios::left);
+ s << std::setw(8) << lgth;
+ }
+ s << " Off.: ";
+ sprintf(st,"x(%x)",o);
+ s << std::setw(10-strlen(st)) << " ";
+ s << st << " ";
+ s << std::setw(8) << o;
+ s << "[" << (*i)->GetVR() << "] ";
+ s.setf(std::ios::left);
+ s << std::setw(66-(*i)->GetName().length()) << " ";
+ s << "[" << (*i)->GetName()<< "] ";
+ s << "[" << d2 << "]";
+ // Display the UID value (instead of displaying the rough code)
if (g == 0x0002) { // Any more to be displayed ?
if ( (e == 0x0010) || (e == 0x0002) )
s << " ==>\t[" << ts->GetValue(v) << "]";
if ( (e == 0x0016) || (e == 0x1150) )
s << " ==>\t[" << ts->GetValue(v) << "]";
}
- }
+ }
+ if (e == 0x0000) { // elem 0x0000 --> group length
+ if (v == "4294967295") // to avoid troubles in convertion
+ sprintf (st," x(ffffffff)");
+ else
+ sprintf(st," x(%08x)",atoi(v.c_str()));
+ s << st;
+ }
s << std::endl;
- }
+ }
os<<s.str();
}
* \ingroup gdcmHeaderEntrySet
* \brief add a new Dicom Element pointer to
* the H Table and to the chained List
+ * \warning push_bash in listEntries ONLY during ParseHeader
+ * \todo something to allow further Elements addition,
+ * \ when position to be taken care of
* @param newHeaderEntry
*/
void gdcmHeaderEntrySet::Add(gdcmHeaderEntry * newHeaderEntry) {
-// tagHT [newHeaderEntry->GetKey()] = newHeaderEntry;
-
+// tagHT [newHeaderEntry->GetKey()] = newHeaderEntry;
tagHT.insert( PairHT( newHeaderEntry->GetKey(),newHeaderEntry) );
-
-// WARNING : push_bash in listEntries ONLY during ParseHeader
-// TODO : something to allow further Elements addition
-// position to be taken care of !
listEntries.push_back(newHeaderEntry);
}
* \ingroup gdcmHeaderEntrySet
* \brief Re-computes the length of a ACR-NEMA/Dicom group from a DcmHeader
* \warning : to be re-written using the chained list instead of the H table.
+ * \warning : DO NOT use (doesn't work any longer because of the multimap)
* \todo : to be re-written using the chained list instead of the H table
* @param SkipSequence TRUE if we don't want to write Sequences (ACR-NEMA Files)
* @param type Type of the File (ExplicitVR,ImplicitVR, ACR, ...)
tk = g->first + "|0000"; // generate the element full tag
if ( tagHT.count(tk) == 0) { // if element 0x0000 not found
- gdcmDictEntry * tagZ = new gdcmDictEntry(gr_bid, 0x0000, "UL");
+ gdcmDictEntry * tagZ = gdcmGlobal::GetDicts()->NewVirtualDictEntry(gr_bid, 0x0000, "UL");
elemZ = new gdcmHeaderEntry(tagZ);
elemZ->SetLength(4);
Add(elemZ); // create it
* @param type type of the File to be written
* (ACR-NEMA, ExplicitVR, ImplicitVR)
* @param _fp already open file pointer
- * @return
*/
void gdcmHeaderEntrySet::WriteEntries(FileType type, FILE * _fp) {
guint16 gr, el;
std::vector<std::string> tokens;
- // TODO : use listEntries to iterate, not TagHt!
+ // uses now listEntries to iterate, not TagHt!
+ //
// pb : gdcmHeaderEntrySet.Add does NOT update listEntries
- // find a trick in STL to do it, at low cost !
+ // TODO : find a trick (in STL?) to do it, at low cost !
void *ptr;
- // Tout ceci ne marche QUE parce qu'on est sur un proc Little Endian
- // restent a tester les echecs en ecriture (apres chaque fwrite)
+ // TODO (?) tester les echecs en ecriture (apres chaque fwrite)
- for (TagHeaderEntryHT::iterator tag2=tagHT.begin();
- tag2 != tagHT.end();
+ for (ListTag::iterator tag2=listEntries.begin();
+ tag2 != listEntries.end();
++tag2){
- gr = tag2->second->GetGroup();
- el = tag2->second->GetElement();
- lgr = tag2->second->GetLength();
- val = tag2->second->GetValue().c_str();
- vr = tag2->second->GetVR();
+ gr = (*tag2)->GetGroup();
+ el = (*tag2)->GetElement();
+ lgr = (*tag2)->GetLength();
+ val = (*tag2)->GetValue().c_str();
+ vr = (*tag2)->GetVR();
if ( type == ACR ) {
if (gr < 0x0008) continue; // ignore pure DICOM V3 groups
if (vr == "US" || vr == "SS") {
tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
- Tokenize (tag2->second->GetValue(), tokens, "\\");
+ Tokenize ((*tag2)->GetValue(), tokens, "\\");
for (unsigned int i=0; i<tokens.size();i++) {
val_uint16 = atoi(tokens[i].c_str());
ptr = &val_uint16;
}
if (vr == "UL" || vr == "SL") {
tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
- Tokenize (tag2->second->GetValue(), tokens, "\\");
+ Tokenize ((*tag2)->GetValue(), tokens, "\\");
for (unsigned int i=0; i<tokens.size();i++) {
val_uint32 = atoi(tokens[i].c_str());
ptr = &val_uint32;