]> Creatis software - gdcm.git/commitdiff
* Remove friend classes between DocEntry and File
authorregrain <regrain>
Fri, 28 Jan 2005 15:10:55 +0000 (15:10 +0000)
committerregrain <regrain>
Fri, 28 Jan 2005 15:10:55 +0000 (15:10 +0000)
   -- BeNours

ChangeLog
src/gdcmBinEntry.cxx
src/gdcmBinEntry.h
src/gdcmContentEntry.cxx
src/gdcmContentEntry.h
src/gdcmDocEntry.cxx
src/gdcmDocEntry.h
src/gdcmFile.cxx

index b81dbe60bb8f78ea5dc85488ca1008118d542df4..4c2a189eeb763355c775eaaf6a5b6a91972936bb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2005-01-28 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
-   * src/gdcmFile.cxx, gdcmDocument.cxx : fix the bug on the group|element 
+   * Remove friend classes between DocEntry and File
+
+2005-01-28 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+   * src/gdcmFile.cxx, gdcmDocument.cxx : fix the bug on the group|element
      0002|0000. The value was incorrect.
 
 2005-01-28 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
index a28e9a5a9edbc27f073ba6fada602613c059de51..f572c83ea9a15abf148b9048d403caee987bff3d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmBinEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 15:21:20 $
-  Version:   $Revision: 1.57 $
+  Date:      $Date: 2005/01/28 15:10:56 $
+  Version:   $Revision: 1.58 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -99,6 +99,8 @@ void BinEntry::Print(std::ostream &os, std::string const & )
    os << s.str();
 }
 
+//-----------------------------------------------------------------------------
+// Public
 /*
  * \brief   canonical Writer
  * @param fp already open file pointer
@@ -169,11 +171,10 @@ void BinEntry::WriteContent(std::ofstream *fp, FileType filetype)
       fp->seekp(lgr, std::ios::cur);
    }
 }
-//-----------------------------------------------------------------------------
-// Public
 
-
-/// \brief Sets the value (non string) of the current Dicom Header Entry
+/**
+ * \brief Sets the value (non string) of the current Dicom Header Entry
+ */
 void BinEntry::SetBinArea( uint8_t *area, bool self )  
 { 
    if (BinArea && SelfArea)
index 7e3e9ac9c83b05ccfc764e7f527729e5ed7bb018..63637ebe70e4317b8a9717b562c1923a4689c04c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmBinEntry.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 15:21:20 $
-  Version:   $Revision: 1.33 $
+  Date:      $Date: 2005/01/28 15:10:56 $
+  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
@@ -51,6 +51,8 @@ public:
    uint8_t *GetBinArea()  { return BinArea; }
 
    void  SetBinArea( uint8_t *area, bool self = true );
+   void SetSelfArea(bool area) { SelfArea = area; };
+   bool IsSelfArea() { return SelfArea; };
 
 private:
    /// \brief memory area to hold 'non std::string' representable values 
index a2723218a83e4926e463a504a5fede60519847af..d48ac1c2e636abdd81dce78d57aeda0e16f7834a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmContentEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/26 15:03:32 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2005/01/28 15:10:56 $
+  Version:   $Revision: 1.7 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -30,13 +30,6 @@ namespace gdcm
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
-
-
-//-----------------------------------------------------------------------------
-// Public
-
-//-----------------------------------------------------------------------------
-// Protected
 /**
  * \brief   Constructor for a given DictEntry
  * @param   e Pointer to existing dictionary entry
@@ -62,6 +55,21 @@ ContentEntry::ContentEntry(DocEntry *e)
 ContentEntry::~ContentEntry ()
 {
 }
+
+//-----------------------------------------------------------------------------
+// Public
+void ContentEntry::Copy(DocEntry *doc)
+{
+   DocEntry::Copy(doc);
+
+   ContentEntry *entry = dynamic_cast<ContentEntry *>(doc);
+   if(entry)
+      Value = entry->Value;
+}
+
+//-----------------------------------------------------------------------------
+// Protected
+
 //-----------------------------------------------------------------------------
 // Private
 
index b947a389637e072d52c3e0d56feb3fffb2796507..da8db0ed38092ec8cb651c91e015a0d5b6a4cabc 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmContentEntry.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 16:32:45 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2005/01/28 15:10:56 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -47,6 +47,8 @@ public:
    /// into a 'string', event if it's physically stored on disk as an integer
    std::string const &GetValue() const { return Value; };
 
+   void Copy(DocEntry *doc);
+
 protected:
    // Contructors are protected, not to be invoked by end user.
    ContentEntry(DictEntry *e);
index c8e5b4baa328e4057b3f83aa7d39c1a9646e9ec4..ec54641571e7440c813901897b79c9e49a1d7e4e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/26 09:49:53 $
-  Version:   $Revision: 1.47 $
+  Date:      $Date: 2005/01/28 15:10:56 $
+  Version:   $Revision: 1.48 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -28,8 +28,6 @@
 
 namespace gdcm 
 {
-
-// CLEAN ME
 #define MAX_SIZE_PRINT_ELEMENT_VALUE 64
 
 //-----------------------------------------------------------------------------
@@ -114,6 +112,8 @@ void DocEntry::Print(std::ostream &os, std::string const & )
    os << s.str();      
 }
 
+//-----------------------------------------------------------------------------
+// Public
 /**
  * \brief   Writes the common part of any ValEntry, BinEntry, SeqEntry
  * @param fp already open ofstream pointer
@@ -207,9 +207,6 @@ void DocEntry::WriteContent(std::ofstream *fp, FileType filetype)
    }
 }
 
-//-----------------------------------------------------------------------------
-// Public
-
 /**
  * \brief   Gets the full length of the elementary DocEntry (not only value
  *          length) depending on the VR.
@@ -267,10 +264,8 @@ bool DocEntry::IsSequenceDelimitor()
 //-----------------------------------------------------------------------------
 // Protected
 
-
 //-----------------------------------------------------------------------------
 // Private
 
 //-----------------------------------------------------------------------------
-
 } // end namespace gdcm
index 886a5abe6ab184281f1d8cfef6c704b072adb4e7..ba8718c583053087efd9287921801a1b9f9fae03 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/26 11:42:02 $
-  Version:   $Revision: 1.41 $
+  Date:      $Date: 2005/01/28 15:10:56 $
+  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
@@ -128,7 +128,7 @@ public:
    
    uint32_t GetFullLength();
    
-   void Copy(DocEntry *doc);
+   virtual void Copy(DocEntry *doc);
 
    bool IsItemDelimitor();
    bool IsSequenceDelimitor();   
@@ -136,13 +136,6 @@ public:
    virtual void Print (std::ostream &os = std::cout, std::string const & indent = ""); 
 
 protected:
-   /// \brief   Sets the DicEntry of the current Dicom entry
-   /// \remarks Used only by the gdcm::File !!! (possible because of a friend 
-   ///          link between them)
-   /// @param   newEntry pointer to the DictEntry
-   void SetDictEntry(DictEntry *newEntry) { DicomDict = newEntry; };
-
-// Variables
    /// \brief pointer to the underlying Dicom dictionary element
    DictEntry *DicomDict;
    
@@ -166,7 +159,6 @@ protected:
    TagKey Key;
 
 private:
-   friend class File; // To use SetDictEntry
 };
 } // end namespace gdcm
 //-----------------------------------------------------------------------------
index 6fc5a059a97cc4939eaaffde8bc6018c0af47efc..ffa7ae08bb998bb79502119382fcd58471e55adf 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/28 10:34:28 $
-  Version:   $Revision: 1.204 $
+  Date:      $Date: 2005/01/28 15:10:56 $
+  Version:   $Revision: 1.205 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -99,21 +99,37 @@ File::File( std::string const &filename ):
          ComputeJPEGFragmentInfo();
       CloseFile();
 
-      // Change the created dict entry
-      std::string PixelVR;
-      // 8 bits allocated is a 'O Bytes' , as well as 24 (old ACR-NEMA RGB)
-      // more than 8 (i.e 12, 16) is a 'O Words'
-      if ( GetBitsAllocated() == 8 || GetBitsAllocated() == 24 ) 
-         PixelVR = "OB";
-      else
-         PixelVR = "OW";
+      // Create a new BinEntry to change the the DictEntry
+      // The changed DictEntry will have 
+      // - a correct PixelVR OB or OW)
+      // - a VM to "PXL"
+      // - the name to "Pixel Data"
+      BinEntry *oldEntry = dynamic_cast<BinEntry *>(entry);
+      if(oldEntry)
+      {
+         std::string PixelVR;
+         // 8 bits allocated is a 'O Bytes' , as well as 24 (old ACR-NEMA RGB)
+         // more than 8 (i.e 12, 16) is a 'O Words'
+         if ( GetBitsAllocated() == 8 || GetBitsAllocated() == 24 ) 
+            PixelVR = "OB";
+         else
+            PixelVR = "OW";
+
+         // Change only made if usefull
+         if( PixelVR != oldEntry->GetVR() )
+         {
+            DictEntry* newDict = NewVirtualDictEntry(GrPixel,NumPixel,
+                                                     PixelVR,"1","Pixel Data");
 
-      DictEntry* newEntry = NewVirtualDictEntry(GrPixel, NumPixel,
-                                                PixelVR, "PXL", "Pixel Data");
+            BinEntry *newEntry = new BinEntry(newDict);
+            newEntry->Copy(entry);
+            newEntry->SetBinArea(oldEntry->GetBinArea(),oldEntry->IsSelfArea());
+            oldEntry->SetSelfArea(false);
 
-      // friend class hunting : should we *create* a new entry,
-      // instead of modifying its DictEntry,in order not to use 'friend' ?
-      entry->SetDictEntry( newEntry );
+            RemoveEntry(oldEntry);
+            AddEntry(newEntry);
+         }
+      }
    }
 }