From 643a8d9fe7dc8470db4cf7a6de639beebb339076 Mon Sep 17 00:00:00 2001 From: regrain Date: Fri, 28 Jan 2005 15:10:55 +0000 Subject: [PATCH] * Remove friend classes between DocEntry and File -- BeNours --- ChangeLog | 5 ++++- src/gdcmBinEntry.cxx | 13 ++++++------ src/gdcmBinEntry.h | 6 ++++-- src/gdcmContentEntry.cxx | 26 +++++++++++++++-------- src/gdcmContentEntry.h | 6 ++++-- src/gdcmDocEntry.cxx | 13 ++++-------- src/gdcmDocEntry.h | 14 +++--------- src/gdcmFile.cxx | 46 +++++++++++++++++++++++++++------------- 8 files changed, 74 insertions(+), 55 deletions(-) diff --git a/ChangeLog b/ChangeLog index b81dbe60..4c2a189e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2005-01-28 Benoit Regrain - * src/gdcmFile.cxx, gdcmDocument.cxx : fix the bug on the group|element + * Remove friend classes between DocEntry and File + +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 diff --git a/src/gdcmBinEntry.cxx b/src/gdcmBinEntry.cxx index a28e9a5a..f572c83e 100644 --- a/src/gdcmBinEntry.cxx +++ b/src/gdcmBinEntry.cxx @@ -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) diff --git a/src/gdcmBinEntry.h b/src/gdcmBinEntry.h index 7e3e9ac9..63637ebe 100644 --- a/src/gdcmBinEntry.h +++ b/src/gdcmBinEntry.h @@ -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 diff --git a/src/gdcmContentEntry.cxx b/src/gdcmContentEntry.cxx index a2723218..d48ac1c2 100644 --- a/src/gdcmContentEntry.cxx +++ b/src/gdcmContentEntry.cxx @@ -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(doc); + if(entry) + Value = entry->Value; +} + +//----------------------------------------------------------------------------- +// Protected + //----------------------------------------------------------------------------- // Private diff --git a/src/gdcmContentEntry.h b/src/gdcmContentEntry.h index b947a389..da8db0ed 100644 --- a/src/gdcmContentEntry.h +++ b/src/gdcmContentEntry.h @@ -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); diff --git a/src/gdcmDocEntry.cxx b/src/gdcmDocEntry.cxx index c8e5b4ba..ec546415 100644 --- a/src/gdcmDocEntry.cxx +++ b/src/gdcmDocEntry.cxx @@ -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 diff --git a/src/gdcmDocEntry.h b/src/gdcmDocEntry.h index 886a5abe..ba8718c5 100644 --- a/src/gdcmDocEntry.h +++ b/src/gdcmDocEntry.h @@ -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 //----------------------------------------------------------------------------- diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 6fc5a059..ffa7ae08 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 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(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); + } + } } } -- 2.45.1