2 //-----------------------------------------------------------------------------
5 #include "gdcmDocEntry.h"
7 #include "gdcmGlobal.h"
10 #include <iomanip> // for std::ios::left, ...
13 #define MAX_SIZE_PRINT_ELEMENT_VALUE 64
15 //-----------------------------------------------------------------------------
16 // Constructor / Destructor
18 * \ingroup gdcmDocEntry
19 * \brief Constructor from a given gdcmDictEntry
20 * @param in Pointer to existing dictionary entry
22 gdcmDocEntry::gdcmDocEntry(gdcmDictEntry* in) {
27 //-----------------------------------------------------------------------------
30 * \ingroup gdcmDocEntry
31 * \brief canonical Printer
33 void gdcmDocEntry::Print(std::ostream & os) {
35 // TODO : (no more chained list ...)
39 unsigned short int g, e;
43 gdcmTS * ts = gdcmGlobal::GetTS();
46 char greltag[10]; //group element tag
53 sprintf(greltag,"%04x|%04x ",g,e);
56 d2 = CreateCleanString(v); // replace non printable characters by '.'
59 lgth = GetReadLength(); // ReadLength, as opposed to UsableLength
60 if (lgth == 0xffffffff) {
61 sprintf(st,"x(ffff)"); // I said : "x(ffff)" !
62 s.setf(std::ios::left);
63 s << std::setw(10-strlen(st)) << " ";
65 s.setf(std::ios::left);
66 s << std::setw(8) << "-1";
68 sprintf(st,"x(%x)",lgth);
69 s.setf(std::ios::left);
70 s << std::setw(10-strlen(st)) << " ";
72 s.setf(std::ios::left);
73 s << std::setw(8) << lgth;
76 sprintf(st,"x(%x)",o);
77 s << std::setw(10-strlen(st)) << " ";
79 s << std::setw(8) << o;
82 s << "[" << vr << "] ";
85 s.setf(std::ios::left);
86 s << std::setw(66-GetName().length()) << " ";
89 s << "[" << GetName()<< "]";
91 if (voidArea != NULL) {
92 s << " [gdcm::Non String Data Loaded in Unsecure Area ("
93 << GetLength() << ") ]";
97 if( (GetLength()<MAX_SIZE_PRINT_ELEMENT_VALUE) ||
99 (d2.find("gdcm::NotLoaded.") < d2.length()) )
100 s << " [" << d2 << "]";
102 s << " [gdcm::too long for print (" << GetLength() << ") ]";
105 // Display the UID value (instead of displaying only the rough code)
106 if (g == 0x0002) { // Any more to be displayed ?
107 if ( (e == 0x0010) || (e == 0x0002) )
108 s << " ==>\t[" << ts->GetValue(v) << "]";
111 if ( (e == 0x0016) || (e == 0x1150) )
112 s << " ==>\t[" << ts->GetValue(v) << "]";
115 if ( (e == 0x1510) || (e == 0x1512) )
116 s << " ==>\t[" << ts->GetValue(v) << "]";
120 //if (e == 0x0000) { // elem 0x0000 --> group length
121 if ( (vr == "UL") || (vr == "US") || (vr == "SL") || (vr == "SS") ) {
122 if (v == "4294967295") // to avoid troubles in convertion
123 sprintf (st," x(ffffffff)");
125 if ( GetLength() !=0 )
126 sprintf(st," x(%x)", atoi(v.c_str()));//FIXME
138 //-----------------------------------------------------------------------------
142 * \ingroup gdcmDocEntry
143 * \brief Gets the full length of the DocEntry (not only value length)
145 guint32 gdcmDocEntry::GetFullLength(void) {
148 if ( IsImplicitVR() )
149 l = l + 8; // 2 (gr) + 2 (el) + 4 (lgth)
151 if ( GetVR()=="OB" || GetVR()=="OW" || GetVR()=="SQ" )
152 l = l + 12; // 2 (gr) + 2 (el) + 2 (vr) + 2 (unused) + 4 (lgth)
154 l = l + 8; // 2 (gr) + 2 (el) + 2 (vr) + 2 (lgth)
159 * \ingroup gdcmDocEntry
160 * \brief Copies all the attributes from an other DocEntry
163 void gdcmDocEntry::Copy (gdcmDocEntry* e) {
164 this->entry = e->entry;
165 this->UsableLength = e->UsableLength;
166 this->ReadLength = e->ReadLength;
167 this->ImplicitVR = e->ImplicitVR;
168 this->Offset = e->Offset;
169 this->printLevel = e->printLevel;
170 this->SQDepthLevel = e->SQDepthLevel;
173 bool gdcmDocEntry::isItemDelimitor() {
174 if ( (GetGroup() == 0xfffe) && (GetElement() == 0xe00d) )
180 bool gdcmDocEntry::isSequenceDelimitor() {
181 if (GetGroup() == 0xfffe && GetElement() == 0xe0dd)
187 //-----------------------------------------------------------------------------
191 //-----------------------------------------------------------------------------
194 //-----------------------------------------------------------------------------