From 3ac7a631bee01193732c9ae23e90dc75181697ec Mon Sep 17 00:00:00 2001 From: jpr Date: Thu, 9 Sep 2004 17:49:24 +0000 Subject: [PATCH] Some fixes to help dealing with UnLoaded values (ForceLoad no yet commited) --- src/gdcmBinEntry.cxx | 21 ++++++++++++++------- src/gdcmBinEntry.h | 6 +++--- src/gdcmCommon.h | 9 ++++++--- src/gdcmDocEntry.cxx | 6 +++--- src/gdcmDocument.cxx | 33 ++++++++++++++++----------------- src/gdcmFile.cxx | 12 +++++++++--- src/gdcmHeader.cxx | 11 ++++++++--- src/gdcmValEntry.cxx | 7 ++++--- 8 files changed, 63 insertions(+), 42 deletions(-) diff --git a/src/gdcmBinEntry.cxx b/src/gdcmBinEntry.cxx index 651ed623..720bbd77 100644 --- a/src/gdcmBinEntry.cxx +++ b/src/gdcmBinEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmBinEntry.cxx,v $ Language: C++ - Date: $Date: 2004/08/31 14:24:47 $ - Version: $Revision: 1.23 $ + Date: $Date: 2004/09/09 17:49:24 $ + Version: $Revision: 1.24 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -44,7 +44,7 @@ gdcmBinEntry::gdcmBinEntry(gdcmDocEntry* e) : gdcmValEntry(e->GetDictEntry()) PrintLevel = e->GetPrintLevel(); SQDepthLevel = e->GetDepthLevel(); - VoidArea = NULL; // let's be carefull ! + VoidArea = 0; // let's be carefull ! } /** @@ -55,7 +55,7 @@ gdcmBinEntry::~gdcmBinEntry() if (VoidArea) { free (VoidArea); - VoidArea = NULL; // let's be carefull ! + VoidArea = 0; // let's be carefull ! } } @@ -73,8 +73,9 @@ void gdcmBinEntry::Print(std::ostream &os) void *voidArea = GetVoidArea(); if (voidArea) { - s << " [gdcm::Binary data loaded with length is " - << GetLength() << "]"; + //s << " [" << GDCM_BINLOADED + s << " [" << GetValue() + << "; length = " << GetLength() << "]"; } else { @@ -84,7 +85,8 @@ void gdcmBinEntry::Print(std::ostream &os) } else { - s << " [gdcm::Binary data NOT loaded]"; + //s << " [gdcm::Binary data NOT loaded]"; + s << " [" < -const std::string GDCM_UNFOUND = "gdcm::Unfound"; /// MEMORY LEAK +const std::string GDCM_UNFOUND = "gdcm::Unfound"; /// MEMORY LEAK +const std::string GDCM_BINLOADED = "gdcm::Binary data loaded"; +const std::string GDCM_NOTLOADED = "gdcm::NotLoaded"; +const std::string GDCM_UNREAD = "gdcm::UnRead"; typedef std::string gdcmTagKey; typedef std::string TagName; diff --git a/src/gdcmDocEntry.cxx b/src/gdcmDocEntry.cxx index 208bd1e6..54c7ed04 100644 --- a/src/gdcmDocEntry.cxx +++ b/src/gdcmDocEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.cxx,v $ Language: C++ - Date: $Date: 2004/09/03 15:09:30 $ - Version: $Revision: 1.17 $ + Date: $Date: 2004/09/09 17:49:24 $ + Version: $Revision: 1.18 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -164,7 +164,7 @@ void gdcmDocEntry::Write(FILE *fp, FileType filetype) // Unknown was 'written' // deal with Little Endian fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,fp); - fwrite ( &z, (size_t)2 ,(size_t)1 ,fp); + fwrite ( &z, (size_t)2 ,(size_t)1 ,fp); } else { diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 71312ce5..6a25788f 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2004/09/07 13:57:04 $ - Version: $Revision: 1.71 $ + Date: $Date: 2004/09/09 17:49:24 $ + Version: $Revision: 1.72 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1504,34 +1504,33 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry) if (length > MaxSizeLoadEntry) { if (gdcmBinEntry* binEntryPtr = dynamic_cast< gdcmBinEntry* >(entry) ) - { - s << "gdcm::NotLoaded (BinEntry)"; + { + //s << "gdcm::NotLoaded (BinEntry)"; + s << GDCM_NOTLOADED; s << " Address:" << (long)entry->GetOffset(); s << " Length:" << entry->GetLength(); s << " x(" << std::hex << entry->GetLength() << ")"; binEntryPtr->SetValue(s.str()); } - // to be sure we are at the end of the value ... - fseek(Fp, (long)entry->GetOffset()+(long)entry->GetLength(), SEEK_SET); - // Following return introduced by JPR on version 1.25. Since the - // treatement of a ValEntry is never executed (doh!) this means - // we were lucky up to now because we NEVER encountered a ValEntry - // whose length was bigger thant MaxSizeLoadEntry !? I can't believe - // this could ever work... - return; //FIXME FIXME FIXME FIXME JPR ???? - // Be carefull : a BinEntry IS_A ValEntry ... - if (gdcmValEntry* valEntryPtr = dynamic_cast< gdcmValEntry* >(entry) ) + else if (gdcmValEntry* valEntryPtr = dynamic_cast< gdcmValEntry* >(entry) ) { - s << "gdcm::NotLoaded. (ValEntry)"; + // s << "gdcm::NotLoaded. (ValEntry)"; + s << GDCM_NOTLOADED; s << " Address:" << (long)entry->GetOffset(); s << " Length:" << entry->GetLength(); s << " x(" << std::hex << entry->GetLength() << ")"; valEntryPtr->SetValue(s.str()); } + else + { + // fusible + std::cout<< "MaxSizeLoadEntry exceeded, neither a BinEntry " + << "nor a ValEntry ?! Should never print that !" << std::endl; + } + // to be sure we are at the end of the value ... fseek(Fp,(long)entry->GetOffset()+(long)entry->GetLength(),SEEK_SET); - return; } @@ -1610,7 +1609,7 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry) { dbg.Verbose(1, "gdcmDocument::LoadDocEntry", "unread element value"); - valEntry->SetValue("gdcm::UnRead"); + valEntry->SetValue(GDCM_UNREAD); return; } diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index a2ddfc70..000b5bae 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2004/09/01 16:23:59 $ - Version: $Revision: 1.122 $ + Date: $Date: 2004/09/09 17:49:25 $ + Version: $Revision: 1.123 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -223,7 +223,10 @@ void *gdcmFile::GetImageData() GetImageDataIntoVector(PixelData, ImageDataSize); // Will be 7fe0, 0010 in standard case GetHeader()->SetEntryVoidAreaByNumber( PixelData, - GetHeader()->GetGrPixel(), GetHeader()->GetNumPixel()); + GetHeader()->GetGrPixel(), GetHeader()->GetNumPixel()); + // Now, the value is loaded. + GetHeader()->SetEntryByNumber( GDCM_BINLOADED, + GetHeader()->GetGrPixel(), GetHeader()->GetNumPixel()); } PixelRead = 0; // no PixelRaw @@ -348,6 +351,9 @@ void * gdcmFile::GetImageDataRaw () // will be 7fe0, 0010 in standard cases GetHeader()->SetEntryVoidAreaByNumber(PixelData, GetHeader()->GetGrPixel(), GetHeader()->GetNumPixel()); + // Now, the value is loaded. + GetHeader()->SetEntryByNumber( GDCM_BINLOADED, + GetHeader()->GetGrPixel(), GetHeader()->GetNumPixel()); } PixelRead = 1; // PixelRaw diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 4419fb91..654a1b08 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmHeader.cxx,v $ Language: C++ - Date: $Date: 2004/09/01 16:23:59 $ - Version: $Revision: 1.183 $ + Date: $Date: 2004/09/09 17:49:25 $ + Version: $Revision: 1.184 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1194,7 +1194,6 @@ uint8_t* gdcmHeader::GetLUTRGBA() *a = 1; // Alpha component a += 4; } - return LUTRGBA; } @@ -1208,6 +1207,12 @@ std::string gdcmHeader::GetTransfertSyntaxName() // use the gdcmTS (TS : Transfert Syntax) std::string transfertSyntax = GetEntryByNumber(0x0002,0x0010); + if ( transfertSyntax == GDCM_NOTLOADED ) { // fusible + std::cout << "Transfert Syntax not loaded. " << std::endl + << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" + << std::endl; + return "Uncompressed ACR-NEMA"; + } if ( transfertSyntax == GDCM_UNFOUND ) { dbg.Verbose(0, "gdcmHeader::GetTransfertSyntaxName:" diff --git a/src/gdcmValEntry.cxx b/src/gdcmValEntry.cxx index 8b14f72f..ebf6947f 100644 --- a/src/gdcmValEntry.cxx +++ b/src/gdcmValEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmValEntry.cxx,v $ Language: C++ - Date: $Date: 2004/08/27 15:48:44 $ - Version: $Revision: 1.22 $ + Date: $Date: 2004/09/09 17:49:25 $ + Version: $Revision: 1.23 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -92,7 +92,8 @@ void gdcmValEntry::Print(std::ostream & os) v = GetValue(); // not applicable for SQ ... d2 = CreateCleanString(v); // replace non printable characters by '.' if( (GetLength()<=MAX_SIZE_PRINT_ELEMENT_VALUE) || - (PrintLevel>=3) || (d2.find("gdcm::NotLoaded.") < d2.length()) ) + //(PrintLevel>=3) || (d2.find("gdcm::NotLoaded.") < d2.length()) ) + (PrintLevel>=3) || (d2.find(GDCM_NOTLOADED) < d2.length()) ) { s << " [" << d2 << "]"; } -- 2.48.1