From 9eb58f53b417ac50bdfa817a02e6dd19ac6fbeb8 Mon Sep 17 00:00:00 2001 From: jpr Date: Wed, 26 Oct 2005 09:15:19 +0000 Subject: [PATCH] --> Optional Element 0x0000 (group length) is no longer written. --> Illegal groups (0,1,3,4,5,6,7) are no longer written, (even if they were found in the original file) For gdcm::File -images- only (I don't know the illegal group for other types of gdcm::Document -gdcm::DicomDir, right now; more to come- ) --- src/gdcmElementSet.cxx | 14 +++++++++----- src/gdcmElementSet.h | 9 ++++++--- src/gdcmFile.h | 9 ++++++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/gdcmElementSet.cxx b/src/gdcmElementSet.cxx index 378ecebd..c59de89a 100644 --- a/src/gdcmElementSet.cxx +++ b/src/gdcmElementSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.cxx,v $ Language: C++ - Date: $Date: 2005/10/26 06:07:26 $ - Version: $Revision: 1.68 $ + Date: $Date: 2005/10/26 09:15:19 $ + Version: $Revision: 1.69 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -55,9 +55,13 @@ void ElementSet::WriteContent(std::ofstream *fp, FileType filetype) i != TagHT.end(); ++i) { - // FIXME : find a trick to know if current object is a - // gdcm::File or a gdcm::Document - //if ( dynamic_cast< File* > ( this ) ) { // ignore illegal groups } + // depending on the gdcm::Document type + // (gdcm::File; gdcm::DicomDir, (more to come ?) + // some groups *cannot* be present. + // We hereby protect gdcm for writting stupid things + // if they were found in the original document. + if ( !MayIWrite( (i->second)->GetGroup() ) ) + continue; // Skip 'Group Length' element, since it may be wrong. // except for Group 0002 diff --git a/src/gdcmElementSet.h b/src/gdcmElementSet.h index 26ae0a20..7b4617f0 100644 --- a/src/gdcmElementSet.h +++ b/src/gdcmElementSet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.h,v $ Language: C++ - Date: $Date: 2005/10/25 14:52:34 $ - Version: $Revision: 1.49 $ + Date: $Date: 2005/10/26 09:15:19 $ + Version: $Revision: 1.50 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -62,7 +62,10 @@ public: protected: ElementSet(); ~ElementSet(); - + /// \brief Some group are illegal withing some Dicom Documents + /// Only the Document knows it. + bool MayIWrite(uint16_t gr) + { return true; } private: // Variables /// Hash Table (map), to provide fast access diff --git a/src/gdcmFile.h b/src/gdcmFile.h index 73590e86..d23d6130 100644 --- a/src/gdcmFile.h +++ b/src/gdcmFile.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.h,v $ Language: C++ - Date: $Date: 2005/10/25 14:52:34 $ - Version: $Revision: 1.118 $ + Date: $Date: 2005/10/26 09:15:19 $ + Version: $Revision: 1.119 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -177,7 +177,10 @@ public: protected: File(); ~File(); - + /// \brief Protect the Writer from writing illegal groups + bool MayIWrite(uint16_t group) + { if (group < 8 && group !=2 ) return false; else return true; } + /// Store the RLE frames info obtained during parsing of pixels. RLEFramesInfo *RLEInfo; /// Store the JPEG fragments info obtained during parsing of pixels. -- 2.48.1