X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmHeaderEntry.cxx;h=b445b624d4a6f70fcf3cedf2215c9bfb43a43833;hb=e037a39af09b4df452992e1129fa2a370171c44e;hp=e53120744a3385ac0f75921753cd04a5ca6439f3;hpb=8d4184fc7129f85d9ec384a3c7b9c5928a1f5b5e;p=gdcm.git diff --git a/src/gdcmHeaderEntry.cxx b/src/gdcmHeaderEntry.cxx index e5312074..b445b624 100644 --- a/src/gdcmHeaderEntry.cxx +++ b/src/gdcmHeaderEntry.cxx @@ -3,16 +3,14 @@ // #include "gdcmHeaderEntry.h" #include "gdcmTS.h" +#include "gdcmGlobal.h" #include "gdcmUtil.h" -#ifdef GDCM_NO_ANSI_STRING_STREAM -# include -# define ostringstream ostrstream -# else -# include -#endif #include // for std::ios::left, ... + +#define MAX_SIZE_PRINT_ELEMENT_VALUE 64 + //----------------------------------------------------------------------------- // Constructor / Destructor /** @@ -21,12 +19,17 @@ * @param in Pointer to existing dictionary entry */ gdcmHeaderEntry::gdcmHeaderEntry(gdcmDictEntry* in) { - ImplicitVR = false; - entry = in; + ImplicitVR = false; + voidArea = NULL; // unsecure memory area to hold 'non string' values + entry = in; } //----------------------------------------------------------------------------- // Print +/** + * \ingroup gdcmHeaderEntry + * \brief canonical Printer + */ void gdcmHeaderEntry::Print(std::ostream & os) { size_t o; unsigned short int g, e; @@ -37,6 +40,7 @@ void gdcmHeaderEntry::Print(std::ostream & os) { std::ostringstream s; guint32 lgth; char greltag[10]; //group element tag + g = GetGroup(); e = GetElement(); v = GetValue(); @@ -45,10 +49,10 @@ void gdcmHeaderEntry::Print(std::ostream & os) { sprintf(greltag,"%04x|%04x ",g,e); s << greltag ; - d2 = _CreateCleanString(v); // replace non printable characters by '.' + d2 = CreateCleanString(v); // replace non printable characters by '.' if (printLevel>=2) { s << "lg : "; - lgth = GetReadLength(); + lgth = GetReadLength(); // ReadLength, as opposed to UsableLength if (lgth == 0xffffffff) { sprintf(st,"x(ffff)"); // I said : "x(ffff)" ! s.setf(std::ios::left); @@ -75,16 +79,26 @@ void gdcmHeaderEntry::Print(std::ostream & os) { if (printLevel>=1) { s.setf(std::ios::left); - s << std::setw(66-GetName().length()) << " "; - } - - s << "[" << GetName()<< "]"; - if( (GetLength()<64) || (printLevel>=3) ) - s << " [" << d2 << "]"; - else - s << " [ gdcm::too long for print (" << GetLength() << ") ]"; + s << std::setw(66-GetName().length()) << " "; + } + + s << "[" << GetName()<< "]"; - // Display the UID value (instead of displaying the rough code) + if (voidArea != NULL) { + s << " [gdcm::Non String Data Loaded in Unsecure Area (" + << GetLength() << ") ]"; + } + + else { + if( (GetLength()=3) || + (d2.find("gdcm::NotLoaded.") < d2.length()) ) + s << " [" << d2 << "]"; + else + s << " [gdcm::too long for print (" << GetLength() << ") ]"; + } + + // Display the UID value (instead of displaying only the rough code) if (g == 0x0002) { // Any more to be displayed ? if ( (e == 0x0010) || (e == 0x0002) ) s << " ==>\t[" << ts->GetValue(v) << "]"; @@ -103,8 +117,12 @@ void gdcmHeaderEntry::Print(std::ostream & os) { if ( (vr == "UL") || (vr == "US") || (vr == "SL") || (vr == "SS") ) { if (v == "4294967295") // to avoid troubles in convertion sprintf (st," x(ffffffff)"); - else - sprintf(st," x(%x)",(unsigned long)atof(v.c_str())); + else { + if ( GetLength() !=0 ) + sprintf(st," x(%x)", atoi(v.c_str()));//FIXME + else + sprintf(st," "); + } s << st; } s << std::endl; @@ -114,6 +132,23 @@ void gdcmHeaderEntry::Print(std::ostream & os) { //----------------------------------------------------------------------------- // Public +/** + * \ingroup gdcmHeaderEntry + * \brief Gets the full length of the HeaderEntry (not only value length) + */ +guint32 gdcmHeaderEntry::GetFullLength(void) { + guint32 l; + l = GetLength(); + if ( IsImplicitVR() ) + l = l + 8; // 2 (gr) + 2 (el) + 4 (lgth) + else + if ( GetVR()=="OB" || GetVR()=="OW" || GetVR()=="SQ" ) + l = l + 12; // 2 (gr) + 2 (el) + 2 (vr) + 2 (unused) + 4 (lgth) + else + l = l + 8; // 2 (gr) + 2 (el) + 2 (vr) + 2 (lgth) + return(l); +} + //----------------------------------------------------------------------------- // Protected