From dfd2b1cd2925e77ef9466cfb2fc71706c84a418c Mon Sep 17 00:00:00 2001 From: regrain Date: Fri, 28 Jan 2005 10:34:27 +0000 Subject: [PATCH] * src/gdcmFile.cxx, gdcmDocument.cxx : fix the bug on the group|element 0002|0000. The value was incorrect. -- BeNours --- ChangeLog | 4 ++++ src/gdcmDocument.cxx | 25 +++++++++++++++---------- src/gdcmFile.cxx | 16 +++++++++++----- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index ed1691c7..b81dbe60 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-01-28 Benoit Regrain + * src/gdcmFile.cxx, gdcmDocument.cxx : fix the bug on the group|element + 0002|0000. The value was incorrect. + 2005-01-28 Benoit Regrain * vtk/vtkGdcmWriter.[h|cxx] : add the gestion of UID diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index a252297e..f6b6f99d 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2005/01/28 09:31:51 $ - Version: $Revision: 1.215 $ + Date: $Date: 2005/01/28 10:34:28 $ + Version: $Revision: 1.216 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -2181,23 +2181,28 @@ int Document::ComputeGroup0002Length( FileType filetype ) // for each zero-level Tag in the DCM Header DocEntry *entry = GetFirstEntry(); - while(entry) + while( entry ) { gr = entry->GetGroup(); - if (gr == 0x0002) + if( gr == 0x0002 ) { found0002 = true; - vr = entry->GetVR(); - - if (filetype == ExplicitVR) + + if( entry->GetElement() != 0x0000 ) { - if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) + vr = entry->GetVR(); + + if( filetype == ExplicitVR ) { - groupLength += 4; // explicit VR AND OB, OW, SQ : 4 more bytes + if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) + { + // explicit VR AND OB, OW, SQ : 4 more bytes + groupLength += 4; + } } + groupLength += 2 + 2 + 4 + entry->GetLength(); } - groupLength += 2 + 2 + 4 + entry->GetLength(); } else if (found0002 ) break; diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 9ba43132..6fc5a059 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2005/01/28 09:37:29 $ - Version: $Revision: 1.203 $ + Date: $Date: 2005/01/28 10:34:28 $ + Version: $Revision: 1.204 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -157,14 +157,21 @@ bool File::Write(std::string fileName, FileType filetype) return false; } + // Entry : 0002|0000 = group length -> recalculated + ValEntry *e0002 = GetValEntry(0x0002,0x0000); + if( e0002 ) + { + std::ostringstream sLen; + sLen << ComputeGroup0002Length(filetype); + e0002->SetValue(sLen.str()); + } + // Bits Allocated if ( GetEntryValue(0x0028,0x0100) == "12") { SetValEntry("16", 0x0028,0x0100); } - /// \todo correct 'Pixel group' Length if necessary - int i_lgPix = GetEntryLength(GrPixel, NumPixel); if (i_lgPix != -2) { @@ -178,7 +185,6 @@ bool File::Write(std::string fileName, FileType filetype) // (or in future gdcmPixelData class) // Drop Palette Color, if necessary - if ( GetEntryValue(0x0028,0x0002).c_str()[0] == '3' ) { // if SamplesPerPixel = 3, sure we don't need any LUT ! -- 2.45.1