]> Creatis software - gdcm.git/commitdiff
--> Optional Element 0x0000 (group length) is no longer written.
authorjpr <jpr>
Wed, 26 Oct 2005 09:15:19 +0000 (09:15 +0000)
committerjpr <jpr>
Wed, 26 Oct 2005 09:15:19 +0000 (09:15 +0000)
--> 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
src/gdcmElementSet.h
src/gdcmFile.h

index 378ecebd68d8a6add4af0da117b0862c74ee891e..c59de89aecbd496b0911f67da800c56359e866ea 100644 (file)
@@ -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 
index 26ae0a20eb32c5d426f27724309039116f66f5df..7b4617f0c10e7ddaec0a39858c97a02620659b80 100644 (file)
@@ -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
index 73590e8651a47fd6f776f9a6fa68d29c9e9cabba..d23d61303833751400678938f0d26ec86995d026 100644 (file)
@@ -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.