2 //-----------------------------------------------------------------------------
4 #include "gdcmDocEntry.h"
6 #include "gdcmGlobal.h"
9 #include <iomanip> // for std::ios::left, ...
12 #define MAX_SIZE_PRINT_ELEMENT_VALUE 64
14 //-----------------------------------------------------------------------------
15 // Constructor / Destructor
17 * \ingroup gdcmDocEntry
18 * \brief Constructor from a given gdcmDictEntry
19 * @param in Pointer to existing dictionary entry
21 gdcmDocEntry::gdcmDocEntry(gdcmDictEntry* in) {
26 //-----------------------------------------------------------------------------
29 * \ingroup gdcmDocEntry
30 * \brief canonical Printer
32 void gdcmDocEntry::Print(std::ostream & os) {
34 // TODO : (no more chained list ...)
38 unsigned short int g, e;
42 gdcmTS * ts = gdcmGlobal::GetTS();
45 char greltag[10]; //group element tag
52 sprintf(greltag,"%04x|%04x ",g,e);
55 d2 = CreateCleanString(v); // replace non printable characters by '.'
58 lgth = GetReadLength(); // ReadLength, as opposed to UsableLength
59 if (lgth == 0xffffffff) {
60 sprintf(st,"x(ffff)"); // I said : "x(ffff)" !
61 s.setf(std::ios::left);
62 s << std::setw(10-strlen(st)) << " ";
64 s.setf(std::ios::left);
65 s << std::setw(8) << "-1";
67 sprintf(st,"x(%x)",lgth);
68 s.setf(std::ios::left);
69 s << std::setw(10-strlen(st)) << " ";
71 s.setf(std::ios::left);
72 s << std::setw(8) << lgth;
75 sprintf(st,"x(%x)",o);
76 s << std::setw(10-strlen(st)) << " ";
78 s << std::setw(8) << o;
81 s << "[" << vr << "] ";
84 s.setf(std::ios::left);
85 s << std::setw(66-GetName().length()) << " ";
88 s << "[" << GetName()<< "]";
90 if (voidArea != NULL) {
91 s << " [gdcm::Non String Data Loaded in Unsecure Area ("
92 << GetLength() << ") ]";
96 if( (GetLength()<MAX_SIZE_PRINT_ELEMENT_VALUE) ||
98 (d2.find("gdcm::NotLoaded.") < d2.length()) )
99 s << " [" << d2 << "]";
101 s << " [gdcm::too long for print (" << GetLength() << ") ]";
104 // Display the UID value (instead of displaying only the rough code)
105 if (g == 0x0002) { // Any more to be displayed ?
106 if ( (e == 0x0010) || (e == 0x0002) )
107 s << " ==>\t[" << ts->GetValue(v) << "]";
110 if ( (e == 0x0016) || (e == 0x1150) )
111 s << " ==>\t[" << ts->GetValue(v) << "]";
114 if ( (e == 0x1510) || (e == 0x1512) )
115 s << " ==>\t[" << ts->GetValue(v) << "]";
119 //if (e == 0x0000) { // elem 0x0000 --> group length
120 if ( (vr == "UL") || (vr == "US") || (vr == "SL") || (vr == "SS") ) {
121 if (v == "4294967295") // to avoid troubles in convertion
122 sprintf (st," x(ffffffff)");
124 if ( GetLength() !=0 )
125 sprintf(st," x(%x)", atoi(v.c_str()));//FIXME
137 //-----------------------------------------------------------------------------
141 * \ingroup gdcmDocEntry
142 * \brief Gets the full length of the DocEntry (not only value length)
144 guint32 gdcmDocEntry::GetFullLength(void) {
147 if ( IsImplicitVR() )
148 l = l + 8; // 2 (gr) + 2 (el) + 4 (lgth)
150 if ( GetVR()=="OB" || GetVR()=="OW" || GetVR()=="SQ" )
151 l = l + 12; // 2 (gr) + 2 (el) + 2 (vr) + 2 (unused) + 4 (lgth)
153 l = l + 8; // 2 (gr) + 2 (el) + 2 (vr) + 2 (lgth)
158 * \ingroup gdcmDocEntry
159 * \brief Copies all the attributes from an other DocEntry
162 void gdcmDocEntry::Copy (gdcmDocEntry* e) {
163 this->entry = e->entry;
164 this->UsableLength = e->UsableLength;
165 this->ReadLength = e->ReadLength;
166 this->ImplicitVR = e->ImplicitVR;
167 this->Offset = e->Offset;
168 this->printLevel = e->printLevel;
169 this->SQDepthLevel = e->SQDepthLevel;
172 //-----------------------------------------------------------------------------
175 //-----------------------------------------------------------------------------
178 //-----------------------------------------------------------------------------