From: regrain Date: Wed, 24 Nov 2004 11:17:46 +0000 (+0000) Subject: * Amelioration of code, remove some code copy. For the loading of X-Git-Tag: Version1.0.bp~572 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=0b01703cc07d46a6ae718e01c6beee14599a9da1;p=gdcm.git * Amelioration of code, remove some code copy. For the loading of BinEntry (in gdcmDocument), add the test to verify if the file is already opened or not. -- BeNours --- diff --git a/ChangeLog b/ChangeLog index f540095c..6e84dc28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-11-24 Benoit Regrain + * Amelioration of code, remove some code copy. For the loading of + BinEntry (in gdcmDocument), add the test to verify if the file is already + opened or not. + 2004-11-24 Benoit Regrain * src/gdcmDocEntryArchive.[h|cxx] : bug fix and add a method to temporary remove a DocEntry in the header (push an empty DocEntry) diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 306354a4..c5d39139 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/11/19 12:44:00 $ - Version: $Revision: 1.135 $ + Date: $Date: 2004/11/24 11:17:47 $ + Version: $Revision: 1.136 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1065,7 +1065,12 @@ void Document::LoadEntryBinArea(uint16_t group, uint16_t elem) if ( !docElement ) return; - size_t o =(size_t)docElement->GetOffset(); + BinEntry *binElement = dynamic_cast(docElement); + if( !binElement ) + return; + + LoadEntryBinArea(binElement); +/* size_t o =(size_t)docElement->GetOffset(); Fp->seekg( o, std::ios_base::beg); size_t l = docElement->GetLength(); uint8_t* a = new uint8_t[l]; @@ -1088,8 +1093,9 @@ void Document::LoadEntryBinArea(uint16_t group, uint16_t elem) { delete[] a; dbg.Verbose(0, "Document::LoadEntryBinArea setting failed."); - } + }*/ } + /** * \brief Loads (from disk) the element content * when a string is not suitable @@ -1097,8 +1103,13 @@ void Document::LoadEntryBinArea(uint16_t group, uint16_t elem) */ void Document::LoadEntryBinArea(BinEntry* element) { + bool openFile = !Fp; + if(openFile) + OpenFile(); + size_t o =(size_t)element->GetOffset(); Fp->seekg(o, std::ios_base::beg); + size_t l = element->GetLength(); uint8_t* a = new uint8_t[l]; if( !a ) @@ -1116,6 +1127,9 @@ void Document::LoadEntryBinArea(BinEntry* element) } element->SetBinArea(a); + + if(openFile) + CloseFile(); } /** diff --git a/src/gdcmDocument.h b/src/gdcmDocument.h index 1ad9350d..c36efc15 100644 --- a/src/gdcmDocument.h +++ b/src/gdcmDocument.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.h,v $ Language: C++ - Date: $Date: 2004/11/17 19:49:13 $ - Version: $Revision: 1.61 $ + Date: $Date: 2004/11/24 11:17:47 $ + Version: $Revision: 1.62 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -277,9 +277,6 @@ public: /// 'Swap code' accessor (see \ref SwapCode ) int GetSwapCode() { return SwapCode; } - /// File pointer - std::ifstream * GetFP() { return Fp; } - bool operator<(Document &document); }; diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index c5219ed2..666a8e96 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/11/24 10:23:47 $ - Version: $Revision: 1.160 $ + Date: $Date: 2004/11/24 11:17:47 $ + Version: $Revision: 1.161 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -209,6 +209,22 @@ uint8_t* File::GetImageData() return 0; } + if ( HeaderInternal->HasLUT() && PixelConverter->BuildRGBImage() ) + { + return PixelConverter->GetRGB(); + } + else + { + // When no LUT or LUT conversion fails, return the decompressed + return PixelConverter->GetDecompressed(); + } + +/* if ( ! GetDecompressed() ) + { + // If the decompression failed nothing can be done. + return 0; + } + uint8_t* pixelData; if ( HeaderInternal->HasLUT() && PixelConverter->BuildRGBImage() ) { @@ -220,7 +236,7 @@ uint8_t* File::GetImageData() pixelData = PixelConverter->GetDecompressed(); } -/*// PIXELCONVERT CLEANME +// PIXELCONVERT CLEANME // Restore the header in a disk-consistent state // (if user asks twice to get the pixels from disk) if ( PixelRead != -1 ) // File was "read" before @@ -275,9 +291,9 @@ uint8_t* File::GetImageData() // We say the value *is* loaded. SetPixelData(pixelData); -// END PIXELCONVERT CLEANME*/ +// END PIXELCONVERT CLEANME - return pixelData; + return pixelData;*/ } /** @@ -351,13 +367,14 @@ size_t File::GetImageDataIntoVector (void* destination, size_t maxSize) */ uint8_t* File::GetImageDataRaw () { - uint8_t* decompressed = GetDecompressed(); + return GetDecompressed(); +/* uint8_t* decompressed = GetDecompressed(); if ( ! decompressed ) { return 0; } -/*// PIXELCONVERT CLEANME +// PIXELCONVERT CLEANME // Restore the header in a disk-consistent state // (if user asks twice to get the pixels from disk) if ( PixelRead != -1 ) // File was "read" before @@ -387,9 +404,9 @@ uint8_t* File::GetImageDataRaw () SetPixelData(decompressed); PixelRead = 1; // PixelRaw -// END PIXELCONVERT CLEANME*/ +// END PIXELCONVERT CLEANME - return decompressed; + return decompressed;*/ } uint8_t* File::GetDecompressed()