]> Creatis software - gdcm.git/commitdiff
We are no longer cheated by Elem belonging to group 0x0002,
authorjpr <jpr>
Thu, 26 Jul 2007 08:36:49 +0000 (08:36 +0000)
committerjpr <jpr>
Thu, 26 Jul 2007 08:36:49 +0000 (08:36 +0000)
located inside a Sequence, when we ReWrite as Implicit VR.
Thx to Mathieu for reporting the pb.

23 files changed:
src/gdcmDataEntry.cxx
src/gdcmDataEntry.h
src/gdcmDicomDir.cxx
src/gdcmDicomDirMeta.cxx
src/gdcmDicomDirMeta.h
src/gdcmDicomDirPatient.cxx
src/gdcmDicomDirPatient.h
src/gdcmDicomDirSerie.cxx
src/gdcmDicomDirSerie.h
src/gdcmDicomDirStudy.cxx
src/gdcmDicomDirStudy.h
src/gdcmDicomDirVisit.h
src/gdcmDocEntry.cxx
src/gdcmDocEntry.h
src/gdcmDocEntrySet.h
src/gdcmDocument.cxx
src/gdcmElementSet.cxx
src/gdcmElementSet.h
src/gdcmFileHelper.cxx
src/gdcmSQItem.cxx
src/gdcmSQItem.h
src/gdcmSeqEntry.cxx
src/gdcmSeqEntry.h

index b46b6e7720b5271a183b458ca9d50c693a3a29ab..182d7391a9fc56fe5bc3aef348d64f3697a5cf89 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDataEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/06/04 13:40:01 $
-  Version:   $Revision: 1.43 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.44 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -544,13 +544,15 @@ void DataEntry::Copy(DocEntry *doc)
 }
 
 /**
- * \brief   Writes the 'value' area of a DataEntry
+ * \brief   Writes the 'common part' + the 'value' area of a DataEntry
  * @param fp already open ofstream pointer
  * @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
  */
-void DataEntry::WriteContent(std::ofstream *fp, FileType filetype)
+void DataEntry::WriteContent(std::ofstream *fp, FileType filetype, 
+                                                      bool insideMetaElements)
 { 
-   DocEntry::WriteContent(fp, filetype);
+   // writes the 'common part'
+   DocEntry::WriteContent(fp, filetype, insideMetaElements);
 
    if ( GetGroup() == 0xfffe )
    {
index d06093a9266f0e107f11ebdadc2dd54ef9704f6b..2bae50a1c8a518d1717f264e4e07b9455aad3094 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDataEntry.h,v $
   Language:  C++
-  Date:      $Date: 2007/07/04 10:40:56 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  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
@@ -51,7 +51,8 @@ public:
    void Print(std::ostream &os = std::cout, std::string const &indent = "");
 
 // Write
-   virtual void WriteContent(std::ofstream *fp, FileType filetype);
+   virtual void WriteContent(std::ofstream *fp, FileType filetype,
+                                                   bool insideMetaElements );
    uint32_t ComputeFullLength();
    
 // Set/Get data
index 5a6a91c923783a6b66ee129c95cdd9e05f9f3815..a6aa0ad963254fe898e44a6ed0472e8ead5b14fc 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:08 $
-  Version:   $Revision: 1.193 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.194 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -492,7 +492,7 @@ bool DicomDir::Write(std::string const &fileName)
    binary_write( *fp, "DICM");
  
    DicomDirMeta *ptrMeta = GetMeta();
-   ptrMeta->WriteContent(fp, ExplicitVR);
+   ptrMeta->WriteContent(fp, ExplicitVR, true);
    
    // force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta
    for(i=0;i<6;++i)
@@ -504,7 +504,7 @@ bool DicomDir::Write(std::string const &fileName)
                                      cc != Patients.end();
                                    ++cc )
    {
-      (*cc)->WriteContent( fp, ExplicitVR );
+      (*cc)->WriteContent( fp, ExplicitVR, false );
    }
    
    // force writing Sequence Delimitation Item
index 8dfdb628d5a74d341c37d61984b4bb96f32c25f7..37c66051e5ea136daf2263f22e94600db4199fc7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirMeta.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:08 $
-  Version:   $Revision: 1.37 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.38 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -56,7 +56,8 @@ DicomDirMeta::~DicomDirMeta()
  * @param filetype type of the file (ImplicitVR, ExplicitVR, ...)
  * @return
  */ 
-void DicomDirMeta::WriteContent(std::ofstream *fp, FileType filetype)
+void DicomDirMeta::WriteContent(std::ofstream *fp, FileType filetype,
+                                                     bool insideMetaElements)
 {
    // 'File Meta Information Version'
    
@@ -84,7 +85,8 @@ void DicomDirMeta::WriteContent(std::ofstream *fp, FileType filetype)
                                i!= DocEntries.end();
                              ++i)
    {   
-      (*i)->WriteContent(fp, filetype);
+   // true : we are in MetaElements
+      (*i)->WriteContent(fp, filetype, true);
    }
 }
 
index dc46710708ef25785b3e8e6ae700f087d961bc72..e7f8e26fc2fccf2cba15abdfea8b3216d924126d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirMeta.h,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:08 $
-  Version:   $Revision: 1.22 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  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
@@ -37,7 +37,7 @@ public:
    static DicomDirMeta *New(bool empty=false) {return new DicomDirMeta(empty);}
 
    virtual void Print(std::ostream &os = std::cout, std::string const &indent = "" );
-   virtual void WriteContent(std::ofstream *fp, FileType t);
+   virtual void WriteContent(std::ofstream *fp, FileType t, bool insideMetaElements);
    int ComputeGroup0002Length( );
    
 protected:
index 616d182c4c4c72f90b22c6bc40a7eb068573e305..0e2e577a789f0b759288781381d76075ec628d57 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirPatient.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:08 $
-  Version:   $Revision: 1.41 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.42 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -57,15 +57,15 @@ DicomDirPatient::~DicomDirPatient()
  * @param fp ofstream to write to
  * @param t Type of the File (explicit VR, implicitVR, ...) 
  */ 
-void DicomDirPatient::WriteContent(std::ofstream *fp, FileType t)
+void DicomDirPatient::WriteContent(std::ofstream *fp, FileType t, bool insideMetaElements)
 {
-   DicomDirObject::WriteContent(fp, t);
+   DicomDirObject::WriteContent(fp, t, false);
 
    for(ListDicomDirStudy::iterator cc = Studies.begin();
                                    cc!= Studies.end();
                                  ++cc )
    {
-      (*cc)->WriteContent( fp, t );
+      (*cc)->WriteContent( fp, t, false );
    }
 }
 
index 74345d8b57ac11e7307aacd274975c3a0063acd6..9b6dfaa9a6c135492bcde140caa0f4e23aef611c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirPatient.h,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:08 $
-  Version:   $Revision: 1.31 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.32 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -42,7 +42,7 @@ public:
    static DicomDirPatient *New(bool empty=false) {return new DicomDirPatient(empty);}
 
    void Print(std::ostream &os = std::cout, std::string const &indent = "" );
-   void WriteContent(std::ofstream *fp, FileType t);
+   void WriteContent(std::ofstream *fp, FileType t, bool insideMetaElements);
   
    // Patient methods
    /// \brief Adds a new gdcmDicomDirStudy to the Patient
index 97bd2594c4dc1112dc9981896ebddec581498f70..1fe41dc3afec6b08784cd6140b4030676319e36b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirSerie.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:08 $
-  Version:   $Revision: 1.43 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.44 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -58,21 +58,21 @@ DicomDirSerie::~DicomDirSerie()
  * @param fp ofstream to write to
  * @param t Type of the File (explicit VR, implicitVR, ...)
  */ 
-void DicomDirSerie::WriteContent(std::ofstream *fp, FileType t)
+void DicomDirSerie::WriteContent(std::ofstream *fp, FileType t, bool insideMetaElements)
 {
-   DicomDirObject::WriteContent(fp, t);
+   DicomDirObject::WriteContent(fp, t, false);
 
    for(ListDicomDirImage::iterator cc = Images.begin();
                                    cc!= Images.end();
                                  ++cc )
    {
-      (*cc)->WriteContent( fp, t );
+      (*cc)->WriteContent( fp, t, false );
    } 
    for(ListDicomDirPrivate::iterator cc2 = Privates.begin();
                                      cc2!= Privates.end();
                                    ++cc2 )
    {
-      (*cc2)->WriteContent( fp, t );
+      (*cc2)->WriteContent( fp, t, false);
    }   
 }
 
index e1f535aef3e882c5ceb5f1ef353b735278fa9630..e2fa2e8fcfeb34360673cb517a08b5beb17ee19a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirSerie.h,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:08 $
-  Version:   $Revision: 1.34 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.35 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -43,7 +43,7 @@ public:
    static DicomDirSerie *New(bool empty=false) {return new DicomDirSerie(empty);}
 
    void Print( std::ostream &os = std::cout, std::string const &indent = "" );
-   void WriteContent( std::ofstream *fp, FileType t );
+   void WriteContent( std::ofstream *fp, FileType t, bool insideMetaElements );
 
    // 'Image' methods
    DicomDirImage *NewImage();
index 0353b0783ab1c19ee973aef1f78184ab7d178067..e7f5cef21d22f10df1085f04b5c8f3c8051ab228 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirStudy.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:08 $
-  Version:   $Revision: 1.43 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.44 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -58,22 +58,22 @@ DicomDirStudy::~DicomDirStudy()
  * @param t Type of the File (explicit VR, implicitVR, ...) 
  * @return
  */ 
-void DicomDirStudy::WriteContent(std::ofstream *fp, FileType t)
+void DicomDirStudy::WriteContent(std::ofstream *fp, FileType t, bool insideMetaElements)
 {
-   DicomDirObject::WriteContent(fp, t);
+   DicomDirObject::WriteContent(fp, t, false);
 
    for(ListDicomDirSerie::iterator cc = Series.begin();
                                    cc!= Series.end();
                                  ++cc )
    {
-      (*cc)->WriteContent( fp, t );
+      (*cc)->WriteContent( fp, t, false );
    }
 
    for(ListDicomDirVisit::iterator icc = Visits.begin();
                                    icc!= Visits.end();
                                  ++icc )
    {
-      (*icc)->WriteContent( fp, t );
+      (*icc)->WriteContent( fp, t, false );
    }
 }
 
index d4a82b5a5d15a3fb7b7cc6e573a37491b75066eb..17b4bb4463c3969907187f45c2d398de5fcb698e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirStudy.h,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:09 $
-  Version:   $Revision: 1.33 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.34 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -49,7 +49,7 @@ public:
    static DicomDirStudy *New(bool empty=false) {return new DicomDirStudy(empty);}
 
    void Print(std::ostream &os = std::cout, std::string const &indent = "" );
-   void WriteContent(std::ofstream *fp, FileType t);
+   void WriteContent(std::ofstream *fp, FileType t, bool insideMetaElements);
 
    // 'Serie' methods
    DicomDirSerie *NewSerie();
index b4a925ba6daecade189ba3ca1ab99abfe5a97536..1fdc3dc4f64db1e473f26fcddde1ea448b4b9269 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirVisit.h,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:09 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -37,7 +37,6 @@ public:
    static DicomDirVisit *New(bool empty=false) {return new DicomDirVisit(empty);}
 
    void Print( std::ostream &os = std::cout, std::string const &indent = "" );
-  // void WriteContent( std::ofstream *fp, FileType t );
 
 protected:
    DicomDirVisit(bool empty=false); 
index 2466076dae15f362087efe6ae42b4e57baa7c158..79103b0164324676c56294b98486f3979a196c14 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/07/24 16:17:04 $
-  Version:   $Revision: 1.89 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.90 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -71,7 +71,7 @@ DocEntry::~DocEntry()
  * @param fp already open ofstream pointer
  * @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
  */
-void DocEntry::WriteContent(std::ofstream *fp, FileType filetype)
+void DocEntry::WriteContent(std::ofstream *fp, FileType filetype, bool insideMetaElements)
 {
    uint32_t ffff  = 0xffffffff;
    uint16_t group = GetGroup();
@@ -103,7 +103,7 @@ void DocEntry::WriteContent(std::ofstream *fp, FileType filetype)
    binary_write( *fp, elem);  //element number
 
    // Dicom V3 group 0x0002 is *always* Explicit VR !
-   if ( filetype == ExplicitVR || filetype == JPEG || filetype == JPEG2000 || group == 0x0002 )
+   if ( filetype == ExplicitVR || filetype == JPEG || filetype == JPEG2000 || (group == 0x0002 && insideMetaElements) )
    {
 // ----------- Writes the common part : the VR + the length 
   
@@ -321,8 +321,11 @@ void DocEntry::Print(std::ostream &os, std::string const & )
    s << "[" << vr  << "] ";
 
    std::string name;
-   if ( GetElement() == 0x0000 )
+   uint16_t e = GetElement();
+   if ( e == 0x0000 )
       name = "Group Length";
+   else if ( GetGroup()%2 == 1 && ( e >= 0x0010 && e <= 0x00ff ) )
+      name = "Private Creator";
    else
    {
       name = GetName();
index ba4dda21f46e29733bfa9c8e64ae01fbeeed224f..f5fe3ab2a61f386a6e8a95a49c6a427bd185582f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.h,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:09 $
-  Version:   $Revision: 1.67 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.68 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -41,7 +41,8 @@ class GDCM_EXPORT DocEntry : public RefCounter
 
 public:
    virtual void Print (std::ostream &os = std::cout, std::string const &indent = ""); 
-   virtual void WriteContent(std::ofstream *fp, FileType filetype);
+   virtual void WriteContent(std::ofstream *fp, FileType filetype, 
+                             bool insideMetaElements);
 
    /// \brief  Gets the DicEntry of the current Dicom entry
    /// @return The DicEntry of the current Dicom entry
index 73b3ca985ba5b2f31ed1e78a72b5ab93516e0f91..083ec9f836fb3d49c805d3eb9844d3ef425e8b54 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntrySet.h,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:09 $
-  Version:   $Revision: 1.69 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.70 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -36,8 +36,8 @@ class DictEntry;
 //-----------------------------------------------------------------------------
 /**
  * \brief
- * \ref DocEntrySet is an abstract base class for \ref ElementSet
- * and \ref SQItem which are both containers for DocEntries.
+ * \ref DocEntrySet is an abstract base class for \ref ElementSet, \ref SQItem
+ *  which are both containers for DocEntries.
  *  - \ref ElementSet is based on the STL map<> container
  * (see \ref ElementSet::TagHT)
  *  - \ref SQItem is based on an STL list container (see \ref ListDocEntry).
@@ -64,7 +64,8 @@ class GDCM_EXPORT DocEntrySet : public RefCounter
 
 public:
    /// \brief write any type of entry to the entry set
-   virtual void WriteContent (std::ofstream *fp, FileType filetype) = 0;
+   virtual void WriteContent (std::ofstream *fp, FileType filetype,
+                                                 bool insideMetaElements) = 0;
 
    /// \brief Remove all Entry of the current set
    virtual void ClearEntry() = 0;
index 32e52d4a2a9bd472f19f8bd5ad807ca7c9d665db..1370bae853b61823178b764425204f9327246b0b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/07/11 12:21:01 $
-  Version:   $Revision: 1.363 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.364 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -722,7 +722,7 @@ void Document::WriteContent(std::ofstream *fp, FileType filetype)
     * --> We don't write the element 0x0000 (group length)
     */
 
-   ElementSet::WriteContent(fp, filetype); // This one is recursive
+   ElementSet::WriteContent(fp, filetype, false); // This one is recursive
 }
 
 // -----------------------------------------
@@ -2219,7 +2219,7 @@ DocEntry *Document::ReadNextDocEntry()
    changeFromUN = false;
    CurrentGroup = GetInt16();
    CurrentElem  = GetInt16();
-   
+      
    // In 'true DICOM' files Group 0002 is always little endian
    if ( HasDCMPreamble )
    {
@@ -2244,10 +2244,10 @@ DocEntry *Document::ReadNextDocEntry()
          realVR = "UL";
       }
 
-      // Commented out in order not to generate 'Shadow Groups' where some 
+      // Was commented out in order not to generate 'Shadow Groups' where some 
       // Data Elements are Explicit VR and some other ones Implicit VR
-      // (Stupid MatLab DICOM Reader couldn't read gdcm-written images)
-      /*
+      // -> Better we fix the problem at Write time
+     
       else if (CurrentGroup%2 == 1 &&  
                                (CurrentElem >= 0x0010 && CurrentElem <=0x00ff ))
       {  
@@ -2255,7 +2255,7 @@ DocEntry *Document::ReadNextDocEntry()
       // (gggg-0010->00FF where gggg is odd) attributes have to be LO
          realVR = "LO";
       }
-      */
+      
       else
       {
          DictEntry *dictEntry = GetDictEntry(CurrentGroup,CurrentElem);//only when ImplicitVR
index ecac10b2a38b04daa93f3e30381470ee85f28c4a..a38db035db7714fc4e2410f55c7a5f6d29d0898c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:10 $
-  Version:   $Revision: 1.76 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.77 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -49,18 +49,32 @@ ElementSet::~ElementSet()
   * @param fp ofstream to write to  
   * @param filetype    ExplicitVR/ImplicitVR/ACR/ACR_LIBIDO/JPEG/JPEG2000/...
   */ 
-void ElementSet::WriteContent(std::ofstream *fp, FileType filetype)
+void ElementSet::WriteContent(std::ofstream *fp, FileType filetype, bool dummy)
 {
+   bool insideMetaElements     = false;
+   bool yetOutsideMetaElements = false;
+   
    for (TagDocEntryHT::const_iterator i = TagHT.begin(); 
                                      i != TagHT.end(); 
                                     ++i)
-   { 
+   {
+        int group = (i->second)->GetGroup();
+       
+       if (yetOutsideMetaElements==false && group == 0x0002)
+          insideMetaElements = true;
+    
+       if (insideMetaElements == true && group != 0x0002)
+       {
+          yetOutsideMetaElements = true;
+          insideMetaElements     = false;
+       }
+   
        // 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() ) ) 
+       if ( !MayIWrite( group ) )
           continue;
   
       // Skip 'Group Length' element, since it may be wrong.
@@ -74,7 +88,8 @@ void ElementSet::WriteContent(std::ofstream *fp, FileType filetype)
              ||( (filetype == ACR || filetype == ACR_LIBIDO ) && (i->second)->GetGroup() == 0x0008 ) )
         )
        {
-             i->second->WriteContent(fp, filetype);
+             // There are DocEntries, written recursively
+             i->second->WriteContent(fp, filetype, insideMetaElements );
        }             
    } 
 }
index ec9b90cd0593ed75daa3c07ec0784d9f301b921b..c384044c4f99cb98d1f3d80586eeeaa0057393ce 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.h,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:10 $
-  Version:   $Revision: 1.55 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.56 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -45,7 +45,8 @@ public:
    virtual void Print(std::ostream &os = std::cout, 
                       std::string const &indent = "" ); 
 
-   void WriteContent(std::ofstream *fp, FileType filetype); 
+   void WriteContent(std::ofstream *fp, FileType filetype,
+                                                    bool insideMetaElements); 
 
    bool AddEntry(DocEntry *Entry);
    bool RemoveEntry(DocEntry *EntryToRemove);
index d652eba776a8407dc2fcac49aea83e7a72103938..2f54d3edc9579bb3a11f6306b7c40f93bdee9894 100644 (file)
@@ -4,8 +4,8 @@
   Module:    $RCSfile: gdcmFileHelper.cxx,v $
   Language:  C++
 
-  Date:      $Date: 2007/07/24 16:17:04 $
-  Version:   $Revision: 1.118 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  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
@@ -2094,7 +2094,7 @@ void FileHelper::ConvertFixGreyLevels(uint8_t *raw, size_t rawSize)
 
 //-----------------------------------------------------------------------------
 /**
- * \brief   Prints the common part of DataEntry, SeqEntry
+ * \brief   Prints the FileInternal + info on PixelReadConvertor
  * @param   os ostream we want to print in
  * @param indent (unused)
  */
index a945413b762ddaadd8350fbd3df36d619965e709..c93e630caf991e8ef1a3a1c836b63088f960901a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:11 $
-  Version:   $Revision: 1.85 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.86 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -54,7 +54,8 @@ SQItem::~SQItem()
  * @param fp     file pointer to an already open file. 
  * @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
  */
-void SQItem::WriteContent(std::ofstream *fp, FileType filetype)
+void SQItem::WriteContent(std::ofstream *fp, FileType filetype, 
+                                                     bool insideMetaElements)
 {
    int j;
    uint16_t item[4] = { 0xfffe, 0xe000, 0xffff, 0xffff };
@@ -87,8 +88,8 @@ void SQItem::WriteContent(std::ofstream *fp, FileType filetype)
                  // --> makes no difference since the only bugged file we have
                  // contains 'impossible tag' fffe|0000 in last position !                            
       }
-
-      (*it)->WriteContent(fp, filetype);
+      // false : we are not in MetaElements
+      (*it)->WriteContent(fp, filetype, false);
    }
       
     //we force the writting of an 'Item Delimitation' item
index 147643e52bf12f375cbae45ed11ee760c9effc52..4231f32005ec0e086eb197ffb4719e63a639fc57 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.h,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:11 $
-  Version:   $Revision: 1.52 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.53 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -47,7 +47,7 @@ public:
 
    virtual void Print(std::ostream &os = std::cout, 
                       std::string const &indent = "" ); 
-   void WriteContent(std::ofstream *fp, FileType filetype);
+   void WriteContent(std::ofstream *fp, FileType filetype, bool insideMetaElements);
    uint32_t ComputeFullLength();
 
    bool AddEntry(DocEntry *Entry); // add to the List
index 684d444dacd0312266ea619ac4847c5bcb5d16ca..0e18e40c665be0733b702bf7bbd67cb45d83262c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:11 $
-  Version:   $Revision: 1.68 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  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
@@ -80,7 +80,7 @@ SeqEntry::~SeqEntry()
  * @param fp pointer to an already open file
  * @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
  */
-void SeqEntry::WriteContent(std::ofstream *fp, FileType filetype)
+void SeqEntry::WriteContent(std::ofstream *fp, FileType filetype, bool dummy)
 {
    uint16_t seq_term_gr = 0xfffe;
    uint16_t seq_term_el = 0xe0dd;
@@ -89,13 +89,13 @@ void SeqEntry::WriteContent(std::ofstream *fp, FileType filetype)
    // ignore 'Zero length' Sequences
    if ( GetReadLength() == 0 )
       return;
-
-   DocEntry::WriteContent(fp, filetype);
+   // false : we are not in MetaElements
+   DocEntry::WriteContent(fp, filetype, false);
    for(ListSQItem::iterator cc  = Items.begin();
                             cc != Items.end();
                           ++cc)
-   {        
-      (*cc)->WriteContent(fp, filetype);
+   {   
+      (*cc)->WriteContent(fp, filetype, false);
    }
    
    // we force the writting of a Sequence Delimitation item
index 778858c64291ad65789b726366e1e05273e2f660..488b37588ff1b84794bd46ed0a24c688fceebd87 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.h,v $
   Language:  C++
-  Date:      $Date: 2007/05/23 14:18:11 $
-  Version:   $Revision: 1.43 $
+  Date:      $Date: 2007/07/26 08:36:49 $
+  Version:   $Revision: 1.44 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -51,7 +51,7 @@ public:
                            {return new SeqEntry(group,elem);}
    
    void Print(std::ostream &os = std::cout, std::string const &indent = "" ); 
-   void WriteContent(std::ofstream *fp, FileType filetype);
+   void WriteContent(std::ofstream *fp, FileType filetype, bool insideMetaElements);
    uint32_t ComputeFullLength();
 
    void AddSQItem(SQItem *it, int itemNumber);