]> Creatis software - gdcm.git/commitdiff
Remove useless accesses to the Dicom Dictionnary std::map
authorjpr <jpr>
Tue, 11 Apr 2006 16:03:26 +0000 (16:03 +0000)
committerjpr <jpr>
Tue, 11 Apr 2006 16:03:26 +0000 (16:03 +0000)
29 files changed:
src/gdcmArgMgr.cxx
src/gdcmCommon.h
src/gdcmDataEntry.cxx
src/gdcmDataEntry.h
src/gdcmDebug.h
src/gdcmDefaultDicts.cxx.in
src/gdcmDicomDir.cxx
src/gdcmDicomDirElement.cxx
src/gdcmDicomDirElement.h
src/gdcmDicomDirObject.cxx
src/gdcmDicomEntry.cxx
src/gdcmDicomEntry.h
src/gdcmDict.cxx
src/gdcmDict.h
src/gdcmDocEntry.cxx
src/gdcmDocEntry.h
src/gdcmDocEntryArchive.cxx
src/gdcmDocEntrySet.cxx
src/gdcmDocEntrySet.h
src/gdcmDocument.cxx
src/gdcmFile.cxx
src/gdcmFileHelper.cxx
src/gdcmFileHelper.h
src/gdcmMacro.h
src/gdcmRefCounter.h
src/gdcmSeqEntry.cxx
src/gdcmSeqEntry.h
src/gdcmSerieHelper.cxx
src/gdcmTagKey.h

index 172cb7d2ac191bc0cf278098fa3c764663921686..0aebf37833c72e4934ce58f6010c10910a57afd3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmArgMgr.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/01/26 18:34:13 $
-  Version:   $Revision: 1.20 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.21 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -99,8 +99,13 @@ namespace gdcm
    }
 
    /* Set labels to upper-case (labels are not case sensitive ) *********/
+   char *secu;
    for ( i=0; i<ArgCount; i++)
+   {
+      secu = ArgLab[i];
       ArgLab[i] = Majuscule ( ArgLab[i] ) ;
+      //free (secu); //we still need it in the caller pgm.
+   }
 
   /* Standard arguments are managed by ArgStdArgs **********************/
    ArgStdArgs(); 
@@ -137,6 +142,7 @@ int ArgMgr::ArgMgrDefined( const char *param )
     trouve = ( strcmp( ArgLab[i], temp )==0 ) ;
     if ( trouve )
     {
+      free (temp);
       ArgUsed[i] = true ;           
       for ( int j=1; j<i; j++)
       {                     
@@ -144,8 +150,9 @@ int ArgMgr::ArgMgrDefined( const char *param )
             ArgUsed[j] = i ;
       }
       return i ;
-    }
+    }   
   }
+  free (temp);
   return 0 ;
 }
 
index aa3e9aa25dee0e4732110ba71f44048665a1b9ff..76d2dc4d791725d52384576ec8ea8d065b31083c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmCommon.h,v $
   Language:  C++
-  Date:      $Date: 2006/03/17 14:31:43 $
-  Version:   $Revision: 1.108 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.109 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -22,7 +22,7 @@
 #include "gdcmConfigure.h"
 #include "gdcmSystem.h"
 #include "gdcmMacro.h"
-
+#include "gdcmVRKey.h"
 #include <string>
 
 //-----------------------------------------------------------------------------
@@ -157,6 +157,8 @@ struct DicomElement
    unsigned short int Group;
    /// Dicom Element number
    unsigned short int Elem;
+   /// Value Representation
+   VRKey VR;
    /// value (coded as a std::string) of the Element
    std::string Value;
 };
index abdbf5a9e02a251b7cb646b6f443695e34d8a253..0c5178650fc2ec019c13532e7dcf82527372f72a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDataEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/03/31 07:52:23 $
-  Version:   $Revision: 1.35 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.36 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -43,8 +43,9 @@ uint32_t DataEntry::MaxSizePrintEntry = MAX_SIZE_PRINT_ELEMENT_VALUE;
  * \brief   Constructor for a given DictEntry
  * @param   e Pointer to existing dictionary entry
  */
-DataEntry::DataEntry(DictEntry *e) 
-            : DocEntry(e)
+DataEntry::DataEntry(uint16_t group,uint16_t elem,
+                                     VRKey const &vr) 
+            : DocEntry(group,elem,vr)
 {
    State = STATE_LOADED;
    Flag = FLAG_NONE;
@@ -58,7 +59,8 @@ DataEntry::DataEntry(DictEntry *e)
  * @param   e Pointer to existing Doc entry
  */
 DataEntry::DataEntry(DocEntry *e)
-            : DocEntry(e->GetDictEntry())
+            //: DocEntry(e->GetDictEntry())
+            : DocEntry(e->GetGroup(),e->GetElement(), e->GetVR()  )
 {
    Flag = FLAG_NONE;
    BinArea = 0;
@@ -255,7 +257,7 @@ double DataEntry::GetValue(const uint32_t &id) const
 /**
  * \brief Checks if the multiplicity of the value follows Dictionary VM
  */
-bool DataEntry::IsValueCountValid() const
+bool DataEntry::IsValueCountValid() /*const*/
 {
   uint32_t vm;
   const std::string &strVM = GetVM();
@@ -414,7 +416,7 @@ void DataEntry::SetString(std::string const &value)
    }
    else
    {
-      if( value.size() > 0 )
+      //if( value.size() > 0 )  // when user sets a string to 0, *do* the job.
       {
          size_t l =  value.size();    
          SetLength(l + l%2);
@@ -422,7 +424,7 @@ void DataEntry::SetString(std::string const &value)
          memcpy(BinArea, value.c_str(), l);
          if (l%2)
             BinArea[l] = '\0';
-      }
+      }      
    }
    State = STATE_LOADED;
 }
@@ -495,7 +497,7 @@ std::string const &DataEntry::GetString() const
    else
    {
       StrArea.append((const char *)BinArea,GetLength());
-      // to avoid gdcm propagate oddities in lengthes
+      // to avoid gdcm to propagate oddities in lengthes
       if ( GetLength()%2)
          StrArea.append(" ",1);  
    }
@@ -555,9 +557,9 @@ void DataEntry::WriteContent(std::ofstream *fp, FileType filetype)
         
    uint8_t *data = BinArea; //safe notation
    size_t l = GetLength(); 
-   gdcmDebugMacro("in DataEntry::WriteContent " << GetKey() << " AtomicLength: "
-              << Global::GetVR()->GetAtomicElementLength(this->GetVR() ) // << " BinArea in :" << &BinArea
-             );
+//   gdcmDebugMacro("in DataEntry::WriteContent " << GetKey() << " AtomicLength: "
+//              << Global::GetVR()->GetAtomicElementLength(this->GetVR() ) // << " BinArea in :" << &BinArea
+//             );
    if (BinArea) // the binArea was *actually* loaded
    {
 #if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
index 0464c372a6b46d2465cd2f5a1032ac0a0c63ca13..1b9aba72dc86437a185a52ff689a6a7effd6d1e6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDataEntry.h,v $
   Language:  C++
-  Date:      $Date: 2006/03/01 09:29:29 $
-  Version:   $Revision: 1.13 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.14 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -40,10 +40,13 @@ class GDCM_EXPORT DataEntry  : public DocEntry
 
 public:
 /// \brief Contructs a DataEntry with a RefCounter from DictEntry
-   static DataEntry *New(DictEntry *e) {return new DataEntry(e);}
+//   static DataEntry *New(DictEntry *e) {return new DataEntry(e);}
 /// \brief Contructs a DataEntry with a RefCounter from DocEntry
    static DataEntry *New(DocEntry *d)  {return new DataEntry(d);}
-
+/// \brief Contructs a DataEntry with a RefCounter from elementary items
+   static DataEntry *New(uint16_t group,uint16_t elem, VRKey const &vr)  
+           {return new DataEntry(group,elem,vr);}
+   
 // Print
    void Print(std::ostream &os = std::cout, std::string const &indent = "");
 
@@ -64,7 +67,7 @@ public:
    void SetValue(const uint32_t &id,const double &val);
    double GetValue(const uint32_t &id) const;
    uint32_t GetValueCount() const;
-   bool IsValueCountValid() const;
+   bool IsValueCountValid() /*const*/; // GetVM may update the pointer DicomDict
 
    void SetString(std::string const &value);
    std::string const &GetString() const;
@@ -107,7 +110,7 @@ public:
    // Flags
    /// \brief sets the 'pixel data flag'   
    void SetFlag(const TValueFlag &flag) { Flag = flag; }
-   /// \brief returns the 'pixel data flag'    
+   /// \brief returns the 'pixel data flag'
    const TValueFlag &GetFlag() const { return Flag; }
    /// \brief true id Entry is a Pixel Data entry
    bool IsPixelData() { return (Flag &FLAG_PIXELDATA) != 0; }
@@ -124,8 +127,9 @@ public:
    bool GetDSValue(std::vector <double> &valueVector);
 
 protected:
-   DataEntry(DictEntry *e);
-   DataEntry(DocEntry *d); 
+  // DataEntry(DictEntry *e);
+   DataEntry(DocEntry *d);
+   DataEntry(uint16_t group,uint16_t elem,VRKey const &vr); 
    ~DataEntry();
 
 // Methods :
index 4f5462c3f03b245a405c55a91f80f726653920ee..dbc9a06cc0b74320e9f454f4bfa9d243136dfe1e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDebug.h,v $
   Language:  C++
-  Date:      $Date: 2006/01/03 14:28:53 $
-  Version:   $Revision: 1.53 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.54 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -210,7 +210,7 @@ private:
 // No NDEBUG test to always have a return of warnings !!!
 // -> Rien compris! JPRx
 #define gdcmLogBodyMacro(obj, msg)                         \
-{                                                              \
+{                                                          \
    if( Debug::GetLogFlag() )                               \
       gdcmMessageBodyMacro(gdcm::CMD_LOG,obj,msg,"");      \
 }
index 21d39605d90972db675831fec5444b7e21d4ee50..9e7b439751434b0855658d4d052a260a05b5ae10 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDefaultDicts.cxx.in,v $
   Language:  C++
-  Date:      $Date: 2005/10/20 15:24:08 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.12 $
 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -76,6 +76,8 @@ typedef struct
    const char *type;
    unsigned short group;
    unsigned short element;
+   //VRKey vr;
+   const char *vr;
    const char *value;
 } ELEMENT;
 
@@ -93,7 +95,7 @@ void FillDefaultDIRDict(DicomDirElement *dde)
 
    while( e.type != 0 )
    {
-      // Force to use the string comparision operator ==
+      // Force to use the string comparison operator ==
       strType = e.type;
       if( strType == "metaElem" )
          type = DD_META;
@@ -110,6 +112,7 @@ void FillDefaultDIRDict(DicomDirElement *dde)
 
       elem.Group = e.group;
       elem.Elem  = e.element;
+      elem.VR    = e.vr;
       elem.Value = e.value;
       dde->AddEntry( type, elem);
       e = dataElement[++i];
index 2ca54af0f96aee3e5e6db84d9a11ac7ebf90e6dc..6812b76f0652d55359bf770c105bcbce311ce114 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/02/16 20:06:13 $
-  Version:   $Revision: 1.186 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.187 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -962,9 +962,10 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
    {
       tmpGr     = it->Group;
       tmpEl     = it->Elem;
-      dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl);
-
-      entry     = DataEntry::New( dictEntry ); 
+      //dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl);
+      //entry     = DataEntry::New( dictEntry );
+       
+      entry     = DataEntry::New(tmpGr, tmpEl, GDCM_VRUNKNOWN); /// \todo : modify dicomelements file, to store VR
       entry->SetOffset(0); // just to avoid further missprinting
 
       if ( header )
index d0bc124b95ebd851c98fc5ea881b1f2ffd72de0a..537d7df8f7fce5b68d158632113b65086926361d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirElement.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/04 15:29:59 $
-  Version:   $Revision: 1.42 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.43 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -50,10 +50,10 @@ DicomDirElement::DicomDirElement()
    else
    {
       char buff[1024];
+      char buff2[1024];
       std::string strType;
       DicomElement elem;
       DicomDirType type;
-
       while (!from.eof())
       {
          from >> std::ws;
@@ -80,14 +80,20 @@ DicomDirElement::DicomDirElement()
 
          if ( type!=DD_UNKNOWN )
          {
-            from >> std::hex >> elem.Group >> elem.Elem;
+            from >> std::hex >> elem.Group >> elem.Elem;//  >> elem.VR;
 
+            from.getline(buff2, 1024, '"');
+            from >> std::ws;
+            from.getline(buff2, 1024, '"');
+            elem.VR[0] = buff2[0];
+            elem.VR[1] = buff2[1];
+    
             from >> std::ws;
             from.getline(buff, 1024, '"');
             from >> std::ws;
             from.getline(buff, 1024, '"');
             elem.Value = buff;
-
+    
             AddEntry(type, elem);
          }
          from.getline(buff, 1024, '\n');
@@ -147,13 +153,15 @@ bool DicomDirElement::AddEntry(DicomDirType type, DicomElement const &elem)
  * @param type Element type (DD_PATIENT, DD_STUDY, DD_SERIE, DD_IMAGE) 
  * @param group  Group number of the entry to be added
  * @param elem Element number of the entry to be added
+ * @param vr Value Representation of the entry to be added
  */
 void DicomDirElement::AddDicomDirElement(DicomDirType type,
-                                         uint16_t group, uint16_t elem)
+                                         uint16_t group, uint16_t elem, VRKey vr)
 {
    DicomElement el;
    el.Group = group;
    el.Elem  = elem;
+   el.VR    = vr;
    el.Value = "";
    AddEntry(type, el);
 }
@@ -174,7 +182,6 @@ void DicomDirElement::Print(std::ostream &os,std::string const &)
 {
    std::ostringstream s;
    std::list<DicomElement>::iterator it;
-   //char greltag[10];  //group element tag
    TagKey greltag;
 
    s << "Meta Elements :"<<std::endl;
index fe9dda9876ba26859a62bb3a893164a403447bbe..7ed69983be83857689f6fdb1e9b19333370d7d5c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirElement.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 16:31:23 $
-  Version:   $Revision: 1.37 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  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
@@ -20,6 +20,7 @@
 #define GDCMDICOMDIRELEMENT_H
 
 #include "gdcmRefCounter.h"
+#include "gdcmVRKey.h"
 
 #include <list>
 
@@ -125,7 +126,7 @@ public:
 
    // Only one instance of ddElem 
    void AddDicomDirElement(DicomDirType type,
-                           uint16_t group, uint16_t elem);
+                           uint16_t group, uint16_t elem, VRKey vr);
 
 protected:
    DicomDirElement();
index 1625584cb2670c6542cd653c781ead5035d3137b..4013716b320f2168616cfe239124f20d06b54328 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirObject.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/25 09:22:15 $
-  Version:   $Revision: 1.23 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.24 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -57,17 +57,18 @@ void DicomDirObject::FillObject(ListDicomDirMetaElem const &elemList)
 {
   // FillObject fills up the SQItem that will be connected to the right place
    ListDicomDirMetaElem::const_iterator it;
-   uint16_t tmpGr,tmpEl;
-   DictEntry *dictEntry;
+   //uint16_t tmpGr,tmpEl;
+   //DictEntry *dictEntry;
    DataEntry *entry;
       
    // for all the Elements found in they own part of the DicomDir dict.     
    for(it = elemList.begin(); it != elemList.end(); ++it)
    {
-      tmpGr = it->Group;
-      tmpEl = it->Elem;
-      dictEntry = Global::GetDicts()->GetDefaultPubDict()->GetEntry(tmpGr,tmpEl);
-      entry = DataEntry::New(dictEntry);
+      //tmpGr = it->Group;
+      //tmpEl = it->Elem;
+      //dictEntry = Global::GetDicts()->GetDefaultPubDict()->GetEntry(tmpGr,tmpEl);
+      //entry = DataEntry::New(dictEntry);
+      entry = DataEntry::New(it->Group, it->Elem, it->VR );
       entry->SetOffset(0); // just to avoid further missprinting
       entry->SetString(it->Value);
 
index ef260fba115243b440548f26943042a2e30021af..9afd602cd2232270794a1c077f12ec9c332409b0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/21 07:38:57 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 =========================================================================*/
 
 #include "gdcmDicomEntry.h"
-#include "gdcmDebug.h"
-#include "gdcmUtil.h"
+//#include "gdcmDebug.h"
+//#include "gdcmUtil.h"
 
-#include <iomanip> // for std::ios::left, ...
+//#include <iomanip> // for std::ios::left, ...
 #include <fstream>
-#include <stdio.h> // for sprintf
+//#include <stdio.h> // for sprintf
 
 namespace gdcm 
 {
@@ -37,8 +37,9 @@ namespace gdcm
 DicomEntry::DicomEntry(const uint16_t &group,const uint16_t &elem,
                        const VRKey &vr)
 {
-   Tag.SetGroup(group);
-   Tag.SetElement(elem);
+   //Tag.SetGroupElement(group);
+   //Tag.SetElement(elem);
+   Tag.SetGroupElement(group,elem);
    VR = vr;
 }
 
@@ -51,20 +52,6 @@ DicomEntry::~DicomEntry()
 
 //-----------------------------------------------------------------------------
 // Public
-/**
- * \brief   concatenates 2 uint16_t (supposed to be a Dicom group number 
- *                                              and a Dicom element number)
- * @param  group the Dicom group number used to build the tag
- * @param  elem the Dicom element number used to build the tag
- * @return the built tag
- */
-TagKey DicomEntry::TranslateToKey(uint16_t group, uint16_t elem)
-{
-   // according to 'Purify', TranslateToKey is one of the most
-   // time consuming methods.
-   // Let's try to shorten it !
-   return TagKey(group,elem);
-}
 
 //-----------------------------------------------------------------------------
 // Protected
index 6f843b5868793acf3cdbab3014b468bab76a3d7e..513c2d9cbad20eb8ada49c5a906768b6da4db0b2 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomEntry.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 15:30:04 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.10 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -68,7 +68,8 @@ public:
    const TagKey &GetKey() const { return Tag; }
 
 // Key creation
-   static TagKey TranslateToKey(uint16_t group, uint16_t elem);
+   static TagKey TranslateToKey(uint16_t group, uint16_t elem)
+                                { return TagKey(group,elem); }
 
 protected:
    DicomEntry(const uint16_t &group,const uint16_t &elt,
index 1af0d6b5da07990c6b495ff6199187f8bd2ebf15..6d20d5eb0ac5ed39b0fe8d6ff9ebaaf8f98c0ade 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDict.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/05 13:25:26 $
-  Version:   $Revision: 1.83 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.84 $
                                                                                 
   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 @@ Dict::Dict( )
  */
 Dict::Dict(std::string const &filename)
 {
-
+   gdcmDebugMacro( "in Dict::Dict, filename =[" << filename << "]" );
    std::ifstream from( filename.c_str() );
    if ( !from )
    {
@@ -57,6 +57,8 @@ Dict::Dict(std::string const &filename)
    }
    else
    {
+      gdcmDebugMacro( "in Dict::Dict, DoTheLoadingJob filename =[" 
+                    << filename << "]" );
       DoTheLoadingJob(from);
       Filename = filename;
    }
@@ -160,7 +162,10 @@ bool Dict::AddEntry(DictEntry *newEntry)
  * @param   newEntry new entry (overwrites any previous one with same tag)
  * @return  false if Dicom Element doesn't exist
  */
-bool Dict::ReplaceEntry(DictEntry *newEntry)
+ /* seems to be useless
+bool Dict::ReplaceEntry(DictEntry *newEntry) // seems to be useless
 {
    const TagKey &key = newEntry->GetKey();
    if ( RemoveEntry(key) )
@@ -171,7 +176,7 @@ bool Dict::ReplaceEntry(DictEntry *newEntry)
    } 
    return false;
 }
-
+*/
 /**
  * \brief  removes an already existing Dicom Dictionary Entry,
  *         identified by its Tag
@@ -183,8 +188,8 @@ bool Dict::RemoveEntry(TagKey const &key)
    TagKeyHT::const_iterator it = KeyHt.find(key);
    if ( it != KeyHt.end() ) 
    {
-      it->second->Unregister();
-      KeyHt.erase(key);
+      it->second->Unregister(); // delete the entry
+      KeyHt.erase(key);         // remove pointer from HTable
 
       return true;
    } 
@@ -215,9 +220,11 @@ void Dict::ClearEntry()
    // we assume all the pointed DictEntries are already cleaned-up
    // when we clean KeyHt.
    TagKeyHT::const_iterator it;
+
    for(it = KeyHt.begin();it!=KeyHt.end();++it)
-      it->second->Unregister();
-   KeyHt.clear();
+      it->second->Unregister(); // delete the entry
+   KeyHt.clear();               // remove all the entries from HTable
+
 }
 
 /**
@@ -322,19 +329,23 @@ void Dict::DoTheLoadingJob(std::ifstream &from)
  */
 void Dict::Print(std::ostream &os, std::string const & )
 {
-   os << "Dict file name : " << Filename << std::endl;
+   os << "Dict file name : [" << Filename << "]" << std::endl;
    std::ostringstream s;
 
    for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag)
-   {
+   {  
+std::cout << tag->second->GetKey() << " " << tag->second->GetName() 
+          << std::endl;
       s << "Entry : ";
       s << "(" << tag->second->GetKey() << ") = "
         << std::dec;
       s << tag->second->GetVR() << ", ";
       s << tag->second->GetVM() << ", ";
       s << tag->second->GetName() << "."  << std::endl;
+     
    }
    os << s.str();
+
 }
 
 //-----------------------------------------------------------------------------
index b460bf784b8da1dd73bec359750fc25d2c6dc071..0e86bedf4ff8e78a4cc5b5adfcd4886766926dcd 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDict.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 16:31:23 $
-  Version:   $Revision: 1.48 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.49 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -61,7 +61,7 @@ public:
 
 // Entries
    bool AddEntry(DictEntry *newEntry);
-   bool ReplaceEntry(DictEntry *newEntry);
+  // bool ReplaceEntry(DictEntry *newEntry); // useless ?
    bool RemoveEntry (TagKey const &key);
    bool RemoveEntry (uint16_t group, uint16_t elem);
    void ClearEntry();
index c076fcc0987ca1ecf780525792eddc2b3488da44..1760277ab7fb3d789c8633dfdbe8da32d93df929 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/03/22 13:19:25 $
-  Version:   $Revision: 1.82 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.83 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -23,7 +23,7 @@
 #include "gdcmGlobal.h"
 #include "gdcmUtil.h"
 #include "gdcmDebug.h"
-
+#include "gdcmDictSet.h"
 #include <iomanip> // for std::ios::left, ...
 #include <fstream>
 
@@ -34,23 +34,22 @@ namespace gdcm
 // Constructor / Destructor
 /**
  * \brief   Constructor from a given DictEntry
- * @param   in Pointer to existing dictionary entry
+ * @param   group Group number
+ * @param   elem Element number
+ * @param   vr VR 
  */
-DocEntry::DocEntry(DictEntry *in)
+DocEntry::DocEntry(uint16_t group, uint16_t elem, VRKey const &vr)
 {
    ImplicitVR = false;
-   DicomDict  = in;
+   DicomDict  = 0;   
    Offset     = 0 ; // To avoid further missprinting
 
    // init some variables
    ReadLength = 0;
    Length = 0;
 
-   gdcmAssertMacro(DicomDict);
-   DicomDict->Register();
-
-   VR = in->GetVR();
-   Key = in->GetKey();
+   VR = vr;
+   Key.SetGroupElem(group,elem);
 }
 
 /**
@@ -58,9 +57,11 @@ DocEntry::DocEntry(DictEntry *in)
  */
 DocEntry::~DocEntry()
 {
-   gdcmAssertMacro(DicomDict);
-
-   DicomDict->Unregister();
+   if (DicomDict)
+   {
+      gdcmAssertMacro(DicomDict);
+      DicomDict->Unregister();
+   }
 }
 
 //-----------------------------------------------------------------------------
@@ -80,7 +81,7 @@ void DocEntry::WriteContent(std::ofstream *fp, FileType filetype)
    VRKey vr       = GetVR();
    uint16_t elem  = GetElement();
    uint32_t lgth  = GetLength();
-
+  
    if ( group == 0xfffe && elem == 0x0000 )
    {
      // Fix in order to make some MR PHILIPS images e-film readable
@@ -108,7 +109,7 @@ void DocEntry::WriteContent(std::ofstream *fp, FileType filetype)
   
       // Special case of delimiters:
       if (group == 0xfffe)
-      {
+      {   
          // Delimiters have NO Value Representation
          // Hence we skip writing the VR.
          //
@@ -121,7 +122,6 @@ void DocEntry::WriteContent(std::ofstream *fp, FileType filetype)
          binary_write(*fp, ff);
          return;
       }
-
       uint16_t zero = 0;
       uint16_t shortLgr = (uint16_t)lgth;
 
@@ -129,13 +129,11 @@ void DocEntry::WriteContent(std::ofstream *fp, FileType filetype)
       {
          // GDCM_VRUNKNOWN was stored in the Entry VR;
          // deal with Entry as if TS were Implicit VR
          binary_write(*fp, lgth);
       }
       else
       {
          binary_write(*fp, vr.str());
-
          // See PS 3.5-2004 page 33, 36                  
          if ( (vr == "SQ") || (vr == "OB") || (vr == "OW") || (vr == "OF") 
           ||  (vr == "UN") || (vr == "UT") )
@@ -173,6 +171,39 @@ void DocEntry::WriteContent(std::ofstream *fp, FileType filetype)
    }
 }
 
+/// \brief Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom
+/// Dictionnary of the current Dicom Header Entry
+std::string const &DocEntry::GetName() 
+{ 
+   if (DicomDict == 0)
+      DicomDict =
+                 Global::GetDicts()->GetDefaultPubDict()->GetEntry(Key[0],Key[1]);
+   if (DicomDict == 0)
+      return GDCM_UNKNOWN;
+   else
+   {
+      DicomDict->Register();
+      return DicomDict->GetName();
+   }
+}
+
+   /// \brief Returns the 'Value Multiplicity' (e.g. "1", "6", "1-n", "3-n"),
+   /// found in the Dicom entry or in the Dicom Dictionnary
+   /// of the current Dicom entry
+std::string const &DocEntry::GetVM()
+{
+   if (DicomDict == 0)
+      DicomDict =
+                 Global::GetDicts()->GetDefaultPubDict()->GetEntry(Key[0],Key[1]);
+   if (DicomDict == 0)
+      return GDCM_UNKNOWN;
+   else
+   {
+      DicomDict->Register();
+      return DicomDict->GetVM();
+   }
+}
+
 /**
  * \brief   Gets the full length of the elementary DocEntry (not only value
  *          length) depending on the VR.
index b41337035391d7933307273fd0b5cf29d47f1e18..950cc1d8d11b00fdc1d9fa5c0bb3744ca391d69b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.h,v $
   Language:  C++
-  Date:      $Date: 2006/03/22 13:19:25 $
-  Version:   $Revision: 1.61 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.62 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -48,11 +48,11 @@ public:
    DictEntry * GetDictEntry() { return DicomDict; } 
 
    /// Returns the Dicom Group number of the current Dicom entry
-   const uint16_t GetGroup() const   { return Key.GetGroup();  }
+   const uint16_t GetGroup() const   { return Key[0];  }
    //const uint16_t &GetGroup() const   { return DicomDict->GetGroup();  }
 
    /// Returns the Dicom Element number of the current Dicom entry
-   const uint16_t GetElement() const { return Key.GetElement();}   
+   const uint16_t GetElement() const { return Key[1];}   
    //const uint16_t &GetElement() const { return DicomDict->GetElement();}
 
    /// Returns the 'key' of the current Dicom entry
@@ -61,7 +61,7 @@ public:
 
    /// \brief Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom
    /// Dictionnary of the current Dicom Header Entry
-   std::string const &GetName() const { return DicomDict->GetName(); }
+   std::string const &GetName();
 
    /// \brief Returns the 'Value Representation' (e.g. "PN" : Person Name,
    /// "SL" : Signed Long), found in the Dicom header or in the Dicom
@@ -72,11 +72,12 @@ public:
    /// \brief Returns the 'Value Multiplicity' (e.g. "1", "6", "1-n", "3-n"),
    /// found in the Dicom entry or in the Dicom Dictionnary
    /// of the current Dicom entry
-   std::string const &GetVM() const { return DicomDict->GetVM(); }
+   std::string const &GetVM();
 
    /// Sets the 'Value Multiplicity' of the current Dicom entry
-   void SetVM( TagName const &v) { DicomDict->SetVM(v); } 
-
+   //void SetVM( TagName const &v) { DicomDict->SetVM(v); } 
+   void SetVM( TagName &v) { std::cout << "-----------------FIXME : SetVM "; }
+    
    /// \brief Returns offset (since the beginning of the file, including
    /// the File Preamble, if any) of the value of the current Dicom entry
    /// \warning offset of the *value*, not of the Dicom entry
@@ -128,12 +129,13 @@ public:
 
    /// \brief Tells us if the VR of the current Dicom entry is Unknown
    /// @return true if the VR is unknown
-   bool IsVRUnknown() const { return DicomDict->IsVRUnknown(); }
+//   bool IsVRUnknown() const { return DicomDict->IsVRUnknown(); }
+     bool IsVRUnknown() const { return VR == GDCM_VRUNKNOWN; }
 
    /// \brief Tells us if the VM of the current Dicom entry is Unknown
    /// @return true if the VM is unknown
-   bool IsVMUnknown() const { return DicomDict->IsVMUnknown(); }
-
+//   bool IsVMUnknown() const { return DicomDict->IsVMUnknown(); }
+   bool IsVMUnknown() { return GetVM() == GDCM_UNKNOWN; }
    bool IsItemDelimitor();
    bool IsItemStarter();
    bool IsSequenceDelimitor();   
@@ -141,7 +143,8 @@ public:
    virtual void Copy(DocEntry *doc);
 
 protected:
-   DocEntry(DictEntry*);
+  // DocEntry(DictEntry*);
+   DocEntry(uint16_t group, uint16_t elem, VRKey const &vr);
    virtual ~DocEntry();
 
    /// \brief pointer to the underlying Dicom dictionary element
index c82a1e96c2c779a8010788813bf56c45468b87b5..b8bb023bac436dcf405125328ad86797c99e4124 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntryArchive.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/24 16:00:47 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  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
@@ -56,12 +56,17 @@ bool DocEntryArchive::Push(DocEntry *newEntry)
    if ( !newEntry )
       return false;
 
-   uint16_t group = newEntry->GetDictEntry()->GetGroup();
-   uint16_t elem  = newEntry->GetDictEntry()->GetElement();
-   TagKey key = DictEntry::TranslateToKey(group,elem);
+   //uint16_t group = newEntry->GetDictEntry()->GetGroup();
+   //uint16_t elem  = newEntry->GetDictEntry()->GetElement();
+   //TagKey key = DictEntry::TranslateToKey(group,elem);
 
+   TagKey key = newEntry->GetKey();
+   
    if ( Archive.find(key) == Archive.end() )
    {
+      uint16_t group = newEntry->GetGroup();
+      uint16_t elem  = newEntry->GetElement();
+      
       // Save the old DocEntry if any
       DocEntry *old = ArchFile->GetDocEntry(group, elem);
       Archive[key]  = old;
@@ -89,8 +94,8 @@ bool DocEntryArchive::Push(DocEntry *newEntry)
  */
 bool DocEntryArchive::Push(uint16_t group, uint16_t elem)
 {
-   TagKey key = DictEntry::TranslateToKey(group, elem);
-
+   //TagKey key = DictEntry::TranslateToKey(group, elem);
+   TagKey key(group, elem);
    if ( Archive.find(key)==Archive.end() )
    {
       // Save the old DocEntry if any
@@ -117,8 +122,8 @@ bool DocEntryArchive::Push(uint16_t group, uint16_t elem)
  */
 bool DocEntryArchive::Restore(uint16_t group, uint16_t elem)
 {
-   TagKey key=DictEntry::TranslateToKey(group, elem);
-
+   //TagKey key=DictEntry::TranslateToKey(group, elem);
+   TagKey key(group, elem);
    TagDocEntryHT::iterator restoreIt=Archive.find(key);
    if ( restoreIt!=Archive.end() )
    {
index 7be85dff36dd317cc05cb37a282d7ef5326daf29..05a552492a513c6c098c20d81ba7a173b530bb1f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntrySet.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/03/22 13:19:25 $
-  Version:   $Revision: 1.71 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.72 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -205,7 +205,7 @@ bool DocEntrySet::SetEntryBinArea(uint8_t *content, int lgth, DataEntry *entry)
 
 /**
  * \brief   Modifies the value of a given Doc Entry (Dicom Element)
- *          when it exists. Create it with the given value when unexistant.
+ *          when it exists. Creates it with the given value when unexistant.
  * @param   value (string) Value to be set
  * @param   group   Group number of the Entry 
  * @param   elem  Element number of the Entry
@@ -219,7 +219,7 @@ DataEntry *DocEntrySet::InsertEntryString(std::string const &value,
 {
    DataEntry *dataEntry = 0;
    DocEntry *currentEntry = GetDocEntry( group, elem );
-   
+   VRKey localVR = vr;
    if (currentEntry)
    {
       dataEntry = dynamic_cast<DataEntry *>(currentEntry);
@@ -239,19 +239,35 @@ DataEntry *DocEntrySet::InsertEntryString(std::string const &value,
          }
       }
    }
+  
+   else // the 'currentEntry' was not found
+   {
+      if ( vr == GDCM_VRUNKNOWN ) // user didn't specify a VR.
+                                  //  Probabely he trusts the Dicom Dict !
+      {
+          DictEntry *e = 
+            Global::GetDicts()->GetDefaultPubDict()->GetEntry(group, elem);
+          if ( e )
+          {
+             localVR = e->GetVR();  
+             e->Register(); // ?? JPRx
+         }
+      }
+   }
 
    // Create a new dataEntry if necessary
    if ( !dataEntry )
    {
-      dataEntry = NewDataEntry( group, elem, vr );
+      dataEntry = NewDataEntry( group, elem, localVR );
 
       if ( !AddEntry(dataEntry) )
       {
-         gdcmWarningMacro("AddEntry failed although this is a creation.");
+         gdcmWarningMacro("AddEntry " << dataEntry->GetKey() 
+                 << " failed although this is a creation.");
          dataEntry->Delete();
          return NULL;
       }
-      dataEntry->Delete();
+      dataEntry->Delete(); // ?!? JPRx
    }
 
    // Set the dataEntry value
@@ -398,6 +414,7 @@ bool DocEntrySet::CheckIfEntryExist(uint16_t group, uint16_t elem )
    return GetDocEntry(group,elem)!=NULL;
 }
 
+
 /**
  * \brief   Build a new DataEntry from all the low level arguments. 
  *          Check for existence of dictionary entry, and build
@@ -410,10 +427,8 @@ bool DocEntrySet::CheckIfEntryExist(uint16_t group, uint16_t elem )
 DataEntry *DocEntrySet::NewDataEntry(uint16_t group,uint16_t elem,
                                      VRKey const &vr) 
 {
-   DictEntry *dictEntry = GetDictEntry(group, elem, vr);
 
-   DataEntry *newEntry = DataEntry::New(dictEntry);
-   dictEntry->Unregister(); // GetDictEntry register it
+   DataEntry *newEntry = DataEntry::New(group,elem,vr);
    if (!newEntry) 
    {
       gdcmWarningMacro( "Failed to allocate DataEntry for ("
@@ -433,10 +448,11 @@ DataEntry *DocEntrySet::NewDataEntry(uint16_t group,uint16_t elem,
  */
 SeqEntry* DocEntrySet::NewSeqEntry(uint16_t group, uint16_t elem) 
 {
-   DictEntry *dictEntry = GetDictEntry(group, elem, "SQ");
+   //DictEntry *dictEntry = GetDictEntry(group, elem, "SQ");
 
-   SeqEntry *newEntry = SeqEntry::New( dictEntry );
-   dictEntry->Unregister(); // GetDictEntry register it
+   //SeqEntry *newEntry = SeqEntry::New( dictEntry );
+   SeqEntry *newEntry = SeqEntry::New( group,elem );
+   //dictEntry->Unregister(); // GetDictEntry register it
    if (!newEntry)
    {
       gdcmWarningMacro( "Failed to allocate SeqEntry for ("
@@ -462,7 +478,7 @@ DictEntry *DocEntrySet::GetDictEntry(uint16_t group,uint16_t elem)
 {
    DictEntry *found = 0;
    /// \todo store the DefaultPubDict somwhere, in order not to access the HTable
-   ///       every time !
+   ///       every time ! --> Done!
    Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
    if (!pubDict) 
    {
@@ -477,66 +493,6 @@ DictEntry *DocEntrySet::GetDictEntry(uint16_t group,uint16_t elem)
    return found;
 }
 
-/**
- * \brief   Searches [both] the public [and the shadow dictionary (when they
- *          exist)] for the presence of the DictEntry with given
- *          group and element, and creates a new virtual DictEntry if necessary
- * @param   group  group number of the searched DictEntry
- * @param   elem element number of the searched DictEntry
- * @param   vr V(alue) R(epresentation) to use, if necessary 
- * @return  Corresponding DictEntry when it exists, NULL otherwise.
- * \remarks The returned DictEntry is registered
- */
-DictEntry *DocEntrySet::GetDictEntry(uint16_t group, uint16_t elem,
-                                     VRKey const &vr)
-{
-   DictEntry *dictEntry = GetDictEntry(group,elem);
-   DictEntry *goodEntry = dictEntry;
-   VRKey goodVR = vr;
-   TagName vm;
-   if (elem == 0x0000)
-      goodVR="UL";
-
-   if ( goodEntry )
-   {
-      if ( goodVR != goodEntry->GetVR()
-        && goodVR != GDCM_VRUNKNOWN )
-      {
-         gdcmWarningMacro("For (" << std::hex << group << "|"
-            << elem << "), found VR : [" << vr << "]"
-            << " expected: [" << goodEntry->GetVR() << "]" ) ;
-        // avoid confusing further validator with "FIXME" VM
-        // when possible      
-         vm = dictEntry->GetVM();
-         goodEntry = NULL;
-      }
-      dictEntry->Unregister();
-   }
-   else
-   {
-      vm = "FIXME";
-   }
-   // Create a new virtual DictEntry if necessary
-   if (!goodEntry)
-   {
-      if (dictEntry)
-      {
-
-         goodEntry = DictEntry::New(group, elem, goodVR, vm,
-                                    dictEntry->GetName() );
-      }
-      else
-      {
-         goodEntry = DictEntry::New(group, elem, goodVR);
-      }
-   }
-   else
-   {
-      goodEntry->Register();
-   }
-   return goodEntry;
-}
-
 //-----------------------------------------------------------------------------
 // Private
 
index d2a5f485c4fcf5b33438b8e8744d05904abef74d..a9c98e421b40846d61e51d85a93882125fc1420f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntrySet.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/30 08:48:17 $
-  Version:   $Revision: 1.67 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  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
@@ -121,8 +121,8 @@ protected:
 
 // DictEntry  related utilities
    DictEntry *GetDictEntry(uint16_t group, uint16_t elem);
-   DictEntry *GetDictEntry(uint16_t group, uint16_t elem,
-                           VRKey const &vr);
//  DictEntry *GetDictEntry(uint16_t group, uint16_t elem,
//                          VRKey const &vr);
    /// To be able to backtrack (Private Sequence, Implicit VR related pb)
    DocEntry *PreviousDocEntry;
 
index 06a91f83695301b25ba07cf7a7f7a1301888b2f7..d2991e701c874f6862f9ab85fb4bbd6e267ddc96 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/03/14 12:09:18 $
-  Version:   $Revision: 1.345 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.346 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -695,7 +695,6 @@ void Document::WriteContent(std::ofstream *fp, FileType filetype)
       fp->write(filePreamble, 128);
       fp->write("DICM", 4);
    }
-
    /*
     * \todo rewrite later, if really usefull
     *       - 'Group Length' element is optional in DICOM
@@ -1053,7 +1052,7 @@ void Document::ParseDES(DocEntrySet *set, long offset,
    bool delim_mode_intern = delim_mode;
    bool first = true;
    gdcmDebugMacro( "Enter in ParseDES, delim-mode " <<  delim_mode
-                     << " at offset " << std::hex << "0x(" << offset << ")" ); 
+                     << " at offset " << std::hex << "0x(" << offset << ")" );    
    while (true)
    {
    
@@ -1063,10 +1062,10 @@ void Document::ParseDES(DocEntrySet *set, long offset,
 // Uncomment to track the bug
 /*   
    if( Debug::GetDebugFlag() )   
-      std::cout << std::dec <<"(long)(Fp->tellg()) " << (long)(Fp->tellg()) 
+      std::cout << std::dec <<"(long)(Fp->tellg()) " << (long)(Fp->tellg()) // in Debug mode
                 << std::hex << " 0x(" <<(long)(Fp->tellg()) <<  ")" << std::endl;
-*/
-
+*/   
    // if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max) // Once per DocEntry   
       if ( !delim_mode ) // 'and then' doesn't exist in C++ :-(
          if ( ((long)(Fp->tellg())-offset) >= l_max) // Once per DocEntry, when no delim mode
@@ -1232,7 +1231,6 @@ void Document::ParseDES(DocEntrySet *set, long offset,
                      l, delim_mode_intern);
 
             gdcmDebugMacro( "Exit from ParseSQ, delim " << delim_mode_intern);
          }
          if ( !set->AddEntry( newSeqEntry ) )
          {
@@ -1593,7 +1591,9 @@ uint32_t Document::FindDocEntryLengthOBOrOW()
 VRKey Document::FindDocEntryVR()
 {
    if ( Filetype != ExplicitVR )
+   {
       return GDCM_VRUNKNOWN;
+   }
 
    // Delimiters (0xfffe), are not explicit VR ... 
    if ( CurrentGroup == 0xfffe )
@@ -1620,7 +1620,7 @@ VRKey Document::FindDocEntryVR()
    if ( !CheckDocEntryVR(vr) )
    {
 /*   
-      std::cout << "================================================================Unknown VR" 
+//      std::cout << "================================================================Unknown VR" 
                << std::hex << "0x(" 
                         << (unsigned int)vr[0] << "|" << (unsigned int)vr[1] 
                         << ")" << "for : " <<  CurrentGroup
@@ -2052,7 +2052,7 @@ void Document::SwitchByteSwapCode()
  * \brief  during parsing, Header Elements too long are not loaded in memory
  * @param newSize new size
  */
-void Document::SetMaxSizeLoadEntry(long newSize) 
+void Document::SetMaxSizeLoadEntry(long newSize)
 {
    if ( newSize < 0 )
    {
@@ -2071,7 +2071,7 @@ void Document::SetMaxSizeLoadEntry(long newSize)
  *          (read the 'Group Number', the 'Element Number',
  *          gets the Dict Entry
  *          gets the VR, gets the length, gets the offset value)
- * @return  On succes : the newly created DocEntry, NULL on failure.      
+ * @return  On succes : the newly created DocEntry, NULL on failure.
  */
 DocEntry *Document::ReadNextDocEntry()
 {
@@ -2082,11 +2082,11 @@ DocEntry *Document::ReadNextDocEntry()
    }
    catch ( FormatError )
    {
-      // We reached the EOF (or an error occured) therefore 
+      // We reached the EOF (or an error occured) therefore
       // header parsing has to be considered as finished.
       return 0;
    }
-   
+
    // In 'true DICOM' files Group 0002 is always little endian
    if ( HasDCMPreamble )
    {
@@ -2094,11 +2094,10 @@ DocEntry *Document::ReadNextDocEntry()
          HandleOutOfGroup0002(CurrentGroup, CurrentElem);
       else
          // Sometimes file contains groups of tags with reversed endianess.
-         HandleBrokenEndian(CurrentGroup, CurrentElem);  
+         HandleBrokenEndian(CurrentGroup, CurrentElem);
     }
-        
+
    VRKey vr = FindDocEntryVR();
-   
    VRKey realVR = vr;
 
    if ( vr == GDCM_VRUNKNOWN )
@@ -2107,6 +2106,11 @@ DocEntry *Document::ReadNextDocEntry()
       {
          realVR = "UL";     // must be UL
       }
+      else if (CurrentGroup == 0xfffe) // Don't get DictEntry for Delimitors
+      {
+         realVR = "UL";
+      }
+
       // 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)
@@ -2121,11 +2125,11 @@ DocEntry *Document::ReadNextDocEntry()
       */
       else
       {
-         DictEntry *dictEntry = GetDictEntry(CurrentGroup,CurrentElem);
+         DictEntry *dictEntry = GetDictEntry(CurrentGroup,CurrentElem);//only when ImplicitVR
          if ( dictEntry )
          {
             realVR = dictEntry->GetVR();
-            dictEntry->Unregister();
+            dictEntry->Unregister(); // GetDictEntry registered it 
          }
       }
    }
@@ -2133,8 +2137,10 @@ DocEntry *Document::ReadNextDocEntry()
    DocEntry *newEntry;
    //if ( Global::GetVR()->IsVROfSequence(realVR) )
    if (realVR == "SQ")
+   {
       newEntry = NewSeqEntry(CurrentGroup, CurrentElem);
-   else 
+   }
+   else
    {
       newEntry = NewDataEntry(CurrentGroup, CurrentElem, realVR);
       static_cast<DataEntry *>(newEntry)->SetState(DataEntry::STATE_NOTLOADED);
@@ -2146,14 +2152,14 @@ DocEntry *Document::ReadNextDocEntry()
       {
          // We thought this was explicit VR, but we end up with an
          // implicit VR tag. Let's backtrack.
-         if ( newEntry->GetGroup() != 0xfffe )
+         //if ( newEntry->GetGroup() != 0xfffe )
+         if (CurrentGroup != 0xfffe )
          { 
-            std::string msg;
             int offset = Fp->tellg();//Only when heuristic for Explicit/Implicit was wrong
-            msg = Util::Format(
-                        "Entry (%04x,%04x) at x(%x) should be Explicit VR\n", 
-                        newEntry->GetGroup(), newEntry->GetElement(), offset );
-            gdcmWarningMacro( msg.c_str() );
+
+            gdcmWarningMacro("Entry (" << newEntry->GetKey() << ") at x("
+                     <<  offset << ") should be Explicit VR");
           }
       }
       newEntry->SetImplicitVR();
index 6d45581b8e9c420d9acb1f1ec63752835e723e80..4ccb1e7ae0b52a14856c7b130a601333be791600 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/03/29 16:13:00 $
-  Version:   $Revision: 1.317 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.318 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -216,6 +216,11 @@ bool File::DoTheLoadingJob( )
       // The changed DictEntry will have 
       // - a correct PixelVR OB or OW)
       // - the name to "Pixel Data"
+      
+       //==>Take it easy!
+       //==> Just change the VR !
+
+/* 
       DataEntry *oldEntry = dynamic_cast<DataEntry *>(entry);
       if (oldEntry)
       {
@@ -229,21 +234,34 @@ bool File::DoTheLoadingJob( )
 
          // Change only made if usefull
          if ( PixelVR != oldEntry->GetVR() )
-         {
-            DictEntry* newDict = DictEntry::New(GrPixel,NumPixel,
-                                                PixelVR,"1","Pixel Data");
-
-            DataEntry *newEntry = DataEntry::New(newDict);
-            newDict->Delete();
-            newEntry->Copy(entry);
-            newEntry->SetBinArea(oldEntry->GetBinArea(),oldEntry->IsSelfArea());
-            oldEntry->SetSelfArea(false);
-
-            RemoveEntry(oldEntry);
-            AddEntry(newEntry);
-            newEntry->Delete();
+         {       
+            //DictEntry* newDict = DictEntry::New(GrPixel,NumPixel,
+            //                                    PixelVR,"1","Pixel Data");
+            //DataEntry *newEntry = DataEntry::New(newDict);
+            //newDict->Delete();
+            //newEntry->Copy(entry);
+            //newEntry->SetBinArea(oldEntry->GetBinArea(),oldEntry->IsSelfArea());
+            //oldEntry->SetSelfArea(false);
+
+            //RemoveEntry(oldEntry);
+            //AddEntry(newEntry);
+            //newEntry->Delete();
+  
          }
       }
+*/
+         VRKey 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 != entry->GetVR() )
+         { 
+            entry->SetVR(PixelVR);  
+         }         
    }
    return true;
 }
@@ -1539,7 +1557,7 @@ bool File::Write(std::string fileName, FileType writetype)
          // no (GrPixel, NumPixel) element
          std::string s_lgPix = Util::Format("%d", i_lgPix+12);
          s_lgPix = Util::DicomString( s_lgPix.c_str() );
-         InsertEntryString(s_lgPix,GrPixel, 0x0000);   
+         InsertEntryString(s_lgPix,GrPixel, 0x0000, "UL");   
       }
    }
    Document::WriteContent(fp, writetype);
index 7e7be8e5a5b93d2823e73fb440c20e264f622466..12bfe7cf5767b985b32f67fefb479b996c5527cf 100644 (file)
@@ -4,8 +4,8 @@
   Module:    $RCSfile: gdcmFileHelper.cxx,v $
   Language:  C++
 
-  Date:      $Date: 2006/03/29 16:09:48 $
-  Version:   $Revision: 1.98 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.99 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -661,6 +661,9 @@ bool FileHelper::WriteAcr (std::string const &fileName)
  */
 bool FileHelper::Write(std::string const &fileName)
 {
+
+   CheckMandatoryElements(); //called once, here !
+   
    bool flag = false;
    DocEntry *e;   
    switch(WriteType)
@@ -671,7 +674,7 @@ bool FileHelper::Write(std::string const &fileName)
  
       case Unknown:  // should never happen; ExplicitVR is the default value
       case ExplicitVR:
-      
+
    // User should ask gdcm to write an image in Explicit VR mode
    // only when he is sure *all* the VR of *all* the DataElements is known.
    // i.e : when there are *only* Public Groups
@@ -680,10 +683,11 @@ bool FileHelper::Write(std::string const &fileName)
    // Let's just *dream* about it; *never* trust a user !
    // We turn to Implicit VR if at least the VR of one element is unknown.
    
          e = FileInternal->GetFirstEntry();
          while (e != 0)
          {
-            if (e->GetVR() == "  ")
+            if (e->GetVR() == "  ")  
             {
                SetWriteTypeToDcmImplVR();
                SetWriteFileTypeToImplicitVR();
@@ -698,7 +702,9 @@ bool FileHelper::Write(std::string const &fileName)
             SetWriteFileTypeToExplicitVR();
          }
          break;
+
+  SetWriteFileTypeToExplicitVR(); // to see JPRx
+  break;
       case ACR:
       case ACR_LIBIDO:
       // NOTHING is done here just for LibIDO.
@@ -708,7 +714,8 @@ bool FileHelper::Write(std::string const &fileName)
       // (shame on him !)
       // We add Recognition Code (RET)
         if ( ! FileInternal->GetDataEntry(0x0008, 0x0010) )
-            FileInternal->InsertEntryString("ACR-NEMA V1.0 ", 0x0008, 0x0010);
+            FileInternal->InsertEntryString("ACR-NEMA V1.0 ", 
+                                             0x0008, 0x0010, "LO");
          SetWriteFileTypeToACR();
         // SetWriteFileTypeToImplicitVR(); // ACR IS implicit VR !
          break;
@@ -718,9 +725,7 @@ bool FileHelper::Write(std::string const &fileName)
          SetWriteFileTypeToJPEG();
          break;
    }
-   
-   CheckMandatoryElements();
-
    // --------------------------------------------------------------
    // Special Patch to allow gdcm to re-write ACR-LibIDO formated images
    //
@@ -757,9 +762,10 @@ bool FileHelper::Write(std::string const &fileName)
       check = FileInternal->Write(fileName,WriteType);
    }
 
-   RestoreWrite();
-   RestoreWriteFileType();
-   RestoreWriteMandatory();
+   RestoreWrite(); 
+  // RestoreWriteFileType();
+  // RestoreWriteMandatory();
+   
 
    // --------------------------------------------------------------
    // Special Patch to allow gdcm to re-write ACR-LibIDO formated images
@@ -845,7 +851,7 @@ void FileHelper::SetWriteToRaw()
    } 
    else
    {
-      DataEntry *photInt = CopyDataEntry(0x0028,0x0004);
+      DataEntry *photInt = CopyDataEntry(0x0028,0x0004,"CS");
       if (FileInternal->HasLUT() )
       {
          photInt->SetString("PALETTE COLOR ");
@@ -890,13 +896,13 @@ void FileHelper::SetWriteToRGB()
    {
       PixelReadConverter->BuildRGBImage();
       
-      DataEntry *spp = CopyDataEntry(0x0028,0x0002);
+      DataEntry *spp = CopyDataEntry(0x0028,0x0002,"US");
       spp->SetString("3 ");
 
-      DataEntry *planConfig = CopyDataEntry(0x0028,0x0006);
+      DataEntry *planConfig = CopyDataEntry(0x0028,0x0006,"US");
       planConfig->SetString("0 ");
 
-      DataEntry *photInt = CopyDataEntry(0x0028,0x0004);
+      DataEntry *photInt = CopyDataEntry(0x0028,0x0004,"CS");
       photInt->SetString("RGB ");
 
       if ( PixelReadConverter->GetRGB() )
@@ -947,13 +953,13 @@ void FileHelper::SetWriteToRGB()
       // samples per pixels = 1 (in the read file)
       if ( FileInternal->GetBitsAllocated()==24 ) 
       {
-         DataEntry *bitsAlloc = CopyDataEntry(0x0028,0x0100);
+         DataEntry *bitsAlloc = CopyDataEntry(0x0028,0x0100,"US");
          bitsAlloc->SetString("8 ");
 
-         DataEntry *bitsStored = CopyDataEntry(0x0028,0x0101);
+         DataEntry *bitsStored = CopyDataEntry(0x0028,0x0101,"US");
          bitsStored->SetString("8 ");
 
-         DataEntry *highBit = CopyDataEntry(0x0028,0x0102);
+         DataEntry *highBit = CopyDataEntry(0x0028,0x0102,"US");
          highBit->SetString("7 ");
 
          Archive->Push(bitsAlloc);
@@ -976,8 +982,10 @@ void FileHelper::SetWriteToRGB()
  */ 
 void FileHelper::RestoreWrite()
 {
+
    Archive->Restore(0x0028,0x0002);
    Archive->Restore(0x0028,0x0004);
+   
    Archive->Restore(0x0028,0x0006);
    Archive->Restore(GetFile()->GetGrPixel(),GetFile()->GetNumPixel());
 
@@ -997,7 +1005,6 @@ void FileHelper::RestoreWrite()
    // For the Palette Color Lookup Table UID
    Archive->Restore(0x0028,0x1203); 
 
-
    // group 0002 may be pushed out for ACR-NEMA writting purposes 
    Archive->Restore(0x0002,0x0000);
    Archive->Restore(0x0002,0x0001);
@@ -1009,6 +1016,7 @@ void FileHelper::RestoreWrite()
    Archive->Restore(0x0002,0x0016);
    Archive->Restore(0x0002,0x0100);
    Archive->Restore(0x0002,0x0102);
+
 }
 
 /**
@@ -1040,7 +1048,7 @@ void FileHelper::SetWriteFileTypeToJPEG()
    std::string ts = Util::DicomString( 
       Global::GetTS()->GetSpecialTransferSyntax(TS::JPEGBaselineProcess1) );
 
-   DataEntry *tss = CopyDataEntry(0x0002,0x0010);
+   DataEntry *tss = CopyDataEntry(0x0002,0x0010,"UI");
    tss->SetString(ts);
 
    Archive->Push(tss);
@@ -1055,7 +1063,7 @@ void FileHelper::SetWriteFileTypeToExplicitVR()
    std::string ts = Util::DicomString( 
       Global::GetTS()->GetSpecialTransferSyntax(TS::ExplicitVRLittleEndian) );
 
-   DataEntry *tss = CopyDataEntry(0x0002,0x0010);
+   DataEntry *tss = CopyDataEntry(0x0002,0x0010,"UI");
    tss->SetString(ts);
    Archive->Push(tss);
    tss->Delete();
@@ -1069,7 +1077,7 @@ void FileHelper::SetWriteFileTypeToImplicitVR()
    std::string ts = Util::DicomString(
       Global::GetTS()->GetSpecialTransferSyntax(TS::ImplicitVRLittleEndian) );
 
-   DataEntry *tss = CopyDataEntry(0x0002,0x0010);
+   DataEntry *tss = CopyDataEntry(0x0002,0x0010,"UI");
    tss->SetString(ts);
    Archive->Push(tss);
    tss->Delete();
@@ -1095,9 +1103,12 @@ void FileHelper::SetWriteToLibido()
    {
       std::string rows, columns; 
 
-      DataEntry *newRow=DataEntry::New(oldRow->GetDictEntry());
-      DataEntry *newCol=DataEntry::New(oldCol->GetDictEntry());
-
+      //DataEntry *newRow=DataEntry::New(oldRow->GetDictEntry());
+      //DataEntry *newCol=DataEntry::New(oldCol->GetDictEntry());
+      
+      DataEntry *newRow=DataEntry::New(0x0028, 0x0010, "US");
+      DataEntry *newCol=DataEntry::New(0x0028, 0x0011, "US");
+      
       newRow->Copy(oldCol);
       newCol->Copy(oldRow);
 
@@ -1111,7 +1122,7 @@ void FileHelper::SetWriteToLibido()
       newCol->Delete();
    }
 
-   DataEntry *libidoCode = CopyDataEntry(0x0008,0x0010);
+   DataEntry *libidoCode = CopyDataEntry(0x0008,0x0010,"LO");
    libidoCode->SetString("ACRNEMA_LIBIDO_1.1");
    Archive->Push(libidoCode);
    libidoCode->Delete();
@@ -1127,7 +1138,7 @@ void FileHelper::SetWriteToNoLibido()
    {
       if ( recCode->GetString() == "ACRNEMA_LIBIDO_1.1" )
       {
-         DataEntry *libidoCode = CopyDataEntry(0x0008,0x0010);
+         DataEntry *libidoCode = CopyDataEntry(0x0008,0x0010,"LO");
          libidoCode->SetString("");
          Archive->Push(libidoCode);
          libidoCode->Delete();
@@ -1156,11 +1167,10 @@ void FileHelper::RestoreWriteOfLibido()
  * @param   group   Group number of the Entry 
  * @param   elem  Element number of the Entry
  * @param   vr  Value Representation of the Entry
- *          FIXME : what is it used for?
  * \return  pointer to the new Bin Entry (NULL when creation failed).
  */ 
 DataEntry *FileHelper::CopyDataEntry(uint16_t group, uint16_t elem,
-                                   const TagName &vr)
+                                   const VRKey &vr)
 {
    DocEntry *oldE = FileInternal->GetDocEntry(group, elem);
    DataEntry *newE;
@@ -1171,7 +1181,8 @@ DataEntry *FileHelper::CopyDataEntry(uint16_t group, uint16_t elem,
 
    if ( oldE )
    {
-      newE = DataEntry::New(oldE->GetDictEntry());
+      //newE = DataEntry::New(oldE->GetDictEntry());
+      newE = DataEntry::New(group, elem, vr);
       newE->Copy(oldE);
    }
    else
@@ -1378,7 +1389,7 @@ void FileHelper::CheckMandatoryElements()
    // Create them if not found
    // Always modify the value
    // Push the entries to the archive.
-      CopyMandatoryEntry(0x0002,0x0000,"0");
+      CopyMandatoryEntry(0x0002,0x0000,"0","UL");
 
       DataEntry *e_0002_0001 = CopyDataEntry(0x0002,0x0001, "OB");
       e_0002_0001->SetBinArea((uint8_t*)Util::GetFileMetaInformationVersion(),
@@ -1390,41 +1401,90 @@ void FileHelper::CheckMandatoryElements()
       if ( ContentType == FILTERED_IMAGE || ContentType == UNMODIFIED_PIXELS_IMAGE)
       {      
    // we keep the original 'Media Storage SOP Class UID', we default it if missing
-         CheckMandatoryEntry(0x0002,0x0002,"1.2.840.10008.5.1.4.1.1.7"); 
+         CheckMandatoryEntry(0x0002,0x0002,"1.2.840.10008.5.1.4.1.1.7","UI"); 
       }
       else
       {
    // It's *not* an image comming straight from a source. We force
    // 'Media Storage SOP Class UID'  --> [Secondary Capture Image Storage]
-         CopyMandatoryEntry(0x0002,0x0002,"1.2.840.10008.5.1.4.1.1.7");
+         CopyMandatoryEntry(0x0002,0x0002,"1.2.840.10008.5.1.4.1.1.7","UI");
       }
       
    // 'Media Storage SOP Instance UID'   
-      CopyMandatoryEntry(0x0002,0x0003,sop);
+      CopyMandatoryEntry(0x0002,0x0003,sop,"UI");
       
    // 'Implementation Class UID'
    // FIXME : in all examples we have, 0x0002,0x0012 is not so long :
    //         seems to be Root UID + 4 digits (?)
-      CopyMandatoryEntry(0x0002,0x0012,Util::CreateUniqueUID());
+      CopyMandatoryEntry(0x0002,0x0012,Util::CreateUniqueUID(),"UI");
 
    // 'Implementation Version Name'
       std::string version = "GDCM ";
       version += Util::GetVersion();
-      CopyMandatoryEntry(0x0002,0x0013,version);
+      CopyMandatoryEntry(0x0002,0x0013,version,"SH");
    }
 
    // --------------------- For DataSet ---------------------
+
+   if ( ContentType != USER_OWN_IMAGE) // when it's not a user made image
+   { 
+   
+      gdcmDebugMacro( "USER_OWN_IMAGE (1)");
+    // If 'SOP Class UID' exists ('true DICOM' image)
+   // we create the 'Source Image Sequence' SeqEntry
+   // to hold informations about the Source Image
+  
+      DataEntry *e_0008_0016 = FileInternal->GetDataEntry(0x0008, 0x0016);
+      if ( e_0008_0016 )
+      {
+      // Create 'Source Image Sequence' SeqEntry
+//     SeqEntry *sis = SeqEntry::New (
+//            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x2112) );
+      SeqEntry *sis = SeqEntry::New (0x0008, 0x2112);
+      SQItem *sqi = SQItem::New(1);
+      // (we assume 'SOP Instance UID' exists too) 
+      // create 'Referenced SOP Class UID'
+//     DataEntry *e_0008_1150 = DataEntry::New(
+//            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1150) );
+      DataEntry *e_0008_1150 = DataEntry::New(0x0008, 0x1150, "UI");
+      e_0008_1150->SetString( e_0008_0016->GetString());
+      sqi->AddEntry(e_0008_1150);
+      e_0008_1150->Delete();
+      
+      // create 'Referenced SOP Instance UID'
+      DataEntry *e_0008_0018 = FileInternal->GetDataEntry(0x0008, 0x0018);
+//      DataEntry *e_0008_1155 = DataEntry::New(
+//            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1155) );
+      DataEntry *e_0008_1155 = DataEntry::New(0x0008, 0x1155, "UI");
+      e_0008_1155->SetString( e_0008_0018->GetString());
+      sqi->AddEntry(e_0008_1155);
+      e_0008_1155->Delete();
+
+      sis->AddSQItem(sqi,1);
+      sqi->Delete();
+
+      // temporarily replaces any previous 'Source Image Sequence' 
+      Archive->Push(sis);
+      sis->Delete();
+      // FIXME : is 'Image Type' *really* depending on the presence of 'SOP Class UID'?
+       if ( ContentType == FILTERED_IMAGE)      
+      // the user *knows* he just modified the pixels
+      // the image is no longer an 'Original' one
+         CopyMandatoryEntry(0x0008,0x0008,"DERIVED\\PRIMARY","CS");    
+      }
+   }
       
    if ( ContentType == FILTERED_IMAGE || ContentType == UNMODIFIED_PIXELS_IMAGE)
    {      
    // we keep the original 'Media Storage SOP Class UID', we default it if missing (it should be present !)
-         CheckMandatoryEntry(0x0008,0x0016,"1.2.840.10008.5.1.4.1.1.7");      
+         CheckMandatoryEntry(0x0008,0x0016,"1.2.840.10008.5.1.4.1.1.7","UI");      
    }
    else
    {
    // It's *not* an image comming straight from a source. We force
    // 'Media Storage SOP Class UID'  --> [Secondary Capture Image Storage]
-         CopyMandatoryEntry(0x0008,0x0016,"1.2.840.10008.5.1.4.1.1.7");      
+         CopyMandatoryEntry(0x0008,0x0016,"1.2.840.10008.5.1.4.1.1.7", "UI");      
    }   
 
    // Push out 'LibIDO-special' entries, if any
@@ -1437,7 +1497,7 @@ void FileHelper::CheckMandatoryElements()
    // - we're gonna write the image as Bits Stored = 16
    if ( FileInternal->GetEntryString(0x0028,0x0100) ==  "12")
    {
-      CopyMandatoryEntry(0x0028,0x0100,"16");
+      CopyMandatoryEntry(0x0028,0x0100,"16","US");
    }
 
    // Check if user wasn't drunk ;-)
@@ -1447,7 +1507,7 @@ void FileHelper::CheckMandatoryElements()
    int nbBitsAllocated = FileInternal->GetBitsAllocated();
    if ( nbBitsAllocated == 0 || nbBitsAllocated > 32)
    {
-      CopyMandatoryEntry(0x0028,0x0100,"16");
+      CopyMandatoryEntry(0x0028,0x0100,"16","US");
       gdcmWarningMacro("(0028,0100) changed from "
          << nbBitsAllocated << " to 16 for consistency purpose");
       nbBitsAllocated = 16; 
@@ -1458,7 +1518,7 @@ void FileHelper::CheckMandatoryElements()
    {
       s.str("");
       s << nbBitsAllocated;
-      CopyMandatoryEntry(0x0028,0x0101,s.str());
+      CopyMandatoryEntry(0x0028,0x0101,s.str(),"US");
       gdcmWarningMacro("(0028,0101) changed from "
                        << nbBitsStored << " to " << nbBitsAllocated
                        << " for consistency purpose" );
@@ -1472,7 +1532,7 @@ void FileHelper::CheckMandatoryElements()
    {
       s.str("");
       s << nbBitsStored - 1; 
-      CopyMandatoryEntry(0x0028,0x0102,s.str());
+      CopyMandatoryEntry(0x0028,0x0102,s.str(),"US");
       gdcmWarningMacro("(0028,0102) changed from "
                        << highBitPosition << " to " << nbBitsAllocated-1
                        << " for consistency purpose");
@@ -1483,7 +1543,7 @@ void FileHelper::CheckMandatoryElements()
    {
       pixelSpacing = "1.0\\1.0";
        // if missing, Pixel Spacing forced to "1.0\1.0"
-      CopyMandatoryEntry(0x0028,0x0030,pixelSpacing);
+      CopyMandatoryEntry(0x0028,0x0030,pixelSpacing,"DS");
    }
    
    // 'Imager Pixel Spacing' : defaulted to 'Pixel Spacing'
@@ -1491,65 +1551,21 @@ void FileHelper::CheckMandatoryElements()
    if ( ContentType != USER_OWN_IMAGE)
    //  we write it only when we are *sure* the image comes from
    //         an imager (see also 0008,0x0064)          
-      CheckMandatoryEntry(0x0018,0x1164,pixelSpacing);
+      CheckMandatoryEntry(0x0018,0x1164,pixelSpacing,"DS");
    
    // Samples Per Pixel (type 1) : default to grayscale 
-   CheckMandatoryEntry(0x0028,0x0002,"1");
+   CheckMandatoryEntry(0x0028,0x0002,"1","US");
 
    // --- Check UID-related Entries ---
-
-
-   if ( ContentType != USER_OWN_IMAGE) // when it's not a user made image
-   { 
-    // If 'SOP Class UID' exists ('true DICOM' image)
-   // we create the 'Source Image Sequence' SeqEntry
-   // to hold informations about the Source Image
-  
-      DataEntry *e_0008_0016 = FileInternal->GetDataEntry(0x0008, 0x0016);
-      if ( e_0008_0016 )
-      {
-      // Create 'Source Image Sequence' SeqEntry
-      SeqEntry *sis = SeqEntry::New (
-            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x2112) );
-      SQItem *sqi = SQItem::New(1);
-      // (we assume 'SOP Instance UID' exists too) 
-      // create 'Referenced SOP Class UID'
-      DataEntry *e_0008_1150 = DataEntry::New(
-            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1150) );
-      e_0008_1150->SetString( e_0008_0016->GetString());
-      sqi->AddEntry(e_0008_1150);
-      e_0008_1150->Delete();
-      
-      // create 'Referenced SOP Instance UID'
-      DataEntry *e_0008_0018 = FileInternal->GetDataEntry(0x0008, 0x0018);
-      DataEntry *e_0008_1155 = DataEntry::New(
-            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1155) );
-      e_0008_1155->SetString( e_0008_0018->GetString());
-      sqi->AddEntry(e_0008_1155);
-      e_0008_1155->Delete();
-
-      sis->AddSQItem(sqi,1);
-      sqi->Delete();
-
-      // temporarily replaces any previous 'Source Image Sequence' 
-      Archive->Push(sis);
-      sis->Delete();
  
-      // FIXME : is 'Image Type' *really* depending on the presence of 'SOP Class UID'?
-       if ( ContentType == FILTERED_IMAGE)      
-      // the user *knows* he just modified the pixels
-      // the image is no longer an 'Original' one
-         CopyMandatoryEntry(0x0008,0x0008,"DERIVED\\PRIMARY");    
-      }
-   }    
-
    // At the end, not to overwrite the original ones,
    // needed by 'Referenced SOP Instance UID', 'Referenced SOP Class UID'   
    // 'SOP Instance UID'  
-   CopyMandatoryEntry(0x0008,0x0018,sop);
+   CopyMandatoryEntry(0x0008,0x0018,sop,"UI");
 
    if ( ContentType == USER_OWN_IMAGE)
    {
+      gdcmDebugMacro( "USER_OWN_IMAGE (2)");   
        // Conversion Type.
        // Other possible values are :
        // See PS 3.3, Page 408
@@ -1563,7 +1579,7 @@ void FileHelper::CheckMandatoryElements()
        // DRW = Drawing
        // SYN = Synthetic Image
            
-      CheckMandatoryEntry(0x0008,0x0064,"SYN"); // Why not?
+      CheckMandatoryEntry(0x0008,0x0064,"SYN","CS"); // Why not?
    } 
 /*
    if ( ContentType == CREATED_IMAGE)
@@ -1580,20 +1596,20 @@ void FileHelper::CheckMandatoryElements()
 
    // Instance Creation Date
    const std::string &date = Util::GetCurrentDate();
-   CopyMandatoryEntry(0x0008,0x0012,date);
+   CopyMandatoryEntry(0x0008,0x0012,date,"DA");
  
    // Instance Creation Time
    const std::string &time = Util::GetCurrentTime();
-   CopyMandatoryEntry(0x0008,0x0013,time);
+   CopyMandatoryEntry(0x0008,0x0013,time,"TM");
 
    // Study Date
-   CheckMandatoryEntry(0x0008,0x0020,date);
+   CheckMandatoryEntry(0x0008,0x0020,date,"DA");
    // Study Time
-   CheckMandatoryEntry(0x0008,0x0030,time);
+   CheckMandatoryEntry(0x0008,0x0030,time,"TM");
 
    // Accession Number
    //CopyMandatoryEntry(0x0008,0x0050,"");
-   CheckMandatoryEntry(0x0008,0x0050,"");
+   CheckMandatoryEntry(0x0008,0x0050,"","SH");
    
 
    // ----- Add Mandatory Entries if missing ---
@@ -1611,7 +1627,7 @@ void FileHelper::CheckMandatoryElements()
    //          keeping the same 'Study Instance UID' for various images
    // The user may add images to a 'Manufacturer Study',
    //          adding new Series to an already existing Study 
-   CheckMandatoryEntry(0x0020,0x000d,Util::CreateUniqueUID());
+   CheckMandatoryEntry(0x0020,0x000d,Util::CreateUniqueUID(),"UI");
 
    // 'Serie Instance UID'
    // Keep the value if exists
@@ -1619,16 +1635,16 @@ void FileHelper::CheckMandatoryElements()
    // keeping the same 'Serie Instance UID' for various images
    // The user shouldn't add any image to a 'Manufacturer Serie'
    // but there is no way no to prevent him for doing that 
-   CheckMandatoryEntry(0x0020,0x000e,Util::CreateUniqueUID());
+   CheckMandatoryEntry(0x0020,0x000e,Util::CreateUniqueUID(),"UI");
 
    // Study ID
-   CheckMandatoryEntry(0x0020,0x0010,"");
+   CheckMandatoryEntry(0x0020,0x0010,"","SH");
 
    // Series Number
-   CheckMandatoryEntry(0x0020,0x0011,"");
+   CheckMandatoryEntry(0x0020,0x0011,"","IS");
 
    // Instance Number
-   CheckMandatoryEntry(0x0020,0x0013,"");
+   CheckMandatoryEntry(0x0020,0x0013,"","IS");
    
    // Patient Orientation
    // Can be computed from (0020|0037) :  Image Orientation (Patient)
@@ -1636,36 +1652,36 @@ void FileHelper::CheckMandatoryElements()
    std::string ori = o->GetOrientation ( FileInternal );
    o->Delete();
    if (ori != "\\" && ori != GDCM_UNFOUND)
-      CheckMandatoryEntry(0x0020,0x0020,ori);
+      CheckMandatoryEntry(0x0020,0x0020,ori,"CS");
    else   
-      CheckMandatoryEntry(0x0020,0x0020,"");
+      CheckMandatoryEntry(0x0020,0x0020,"","CS");
 
    // Default Patient Position to HFS
-   CheckMandatoryEntry(0x0018,0x5100,"HFS");
+   CheckMandatoryEntry(0x0018,0x5100,"HFS","CS");
 
    // Modality : if missing we set it to 'OTher'
-   CheckMandatoryEntry(0x0008,0x0060,"OT");
+   CheckMandatoryEntry(0x0008,0x0060,"OT","CS");
 
    // Manufacturer : if missing we set it to 'GDCM Factory'
-   CheckMandatoryEntry(0x0008,0x0070,"GDCM Factory");
+   CheckMandatoryEntry(0x0008,0x0070,"GDCM Factory","LO");
 
    // Institution Name : if missing we set it to 'GDCM Hospital'
-   CheckMandatoryEntry(0x0008,0x0080,"GDCM Hospital");
+   CheckMandatoryEntry(0x0008,0x0080,"GDCM Hospital","LO");
 
    // Patient's Name : if missing, we set it to 'GDCM^Patient'
-   CheckMandatoryEntry(0x0010,0x0010,"GDCM^Patient");
+   CheckMandatoryEntry(0x0010,0x0010,"GDCM^Patient","PN");
 
    // Patient ID
-   CheckMandatoryEntry(0x0010,0x0020,"");
+   CheckMandatoryEntry(0x0010,0x0020,"","LO");
 
    // Patient's Birth Date : 'type 2' entry -> must exist, value not mandatory
-   CheckMandatoryEntry(0x0010,0x0030,"");
+   CheckMandatoryEntry(0x0010,0x0030,"","DA");
 
    // Patient's Sex :'type 2' entry -> must exist, value not mandatory
-   CheckMandatoryEntry(0x0010,0x0040,"");
+   CheckMandatoryEntry(0x0010,0x0040,"","CS");
 
    // Referring Physician's Name :'type 2' entry -> must exist, value not mandatory
-   CheckMandatoryEntry(0x0008,0x0090,"");
+   CheckMandatoryEntry(0x0008,0x0090,"","PN");
 
  /*
    // Deal with element 0x0000 (group length) of each group.
@@ -1688,29 +1704,32 @@ void FileHelper::CheckMandatoryElements()
 
 } 
 
-void FileHelper::CheckMandatoryEntry(uint16_t group,uint16_t elem,std::string value)
+void FileHelper::CheckMandatoryEntry(uint16_t group,uint16_t elem,std::string value,const VRKey &vr )
 {
    DataEntry *entry = FileInternal->GetDataEntry(group,elem);
    if ( !entry )
    {
-      entry = DataEntry::New(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem));
+      //entry = DataEntry::New(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem));
+      entry = DataEntry::New(group,elem,vr);
       entry->SetString(value);
       Archive->Push(entry);
       entry->Delete();
-   }
+   }    
 }
 
-void FileHelper::SetMandatoryEntry(uint16_t group,uint16_t elem,std::string value)
+/// \todo : what is it used for ? (FileHelper::SetMandatoryEntry) 
+void FileHelper::SetMandatoryEntry(uint16_t group,uint16_t elem,std::string value,const VRKey &vr)
 {
-   DataEntry *entry = DataEntry::New(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem));
+   //DataEntry *entry = DataEntry::New(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem));
+   DataEntry *entry = DataEntry::New(group,elem,vr);
    entry->SetString(value);
    Archive->Push(entry);
    entry->Delete();
 }
 
-void FileHelper::CopyMandatoryEntry(uint16_t group,uint16_t elem,std::string value)
+void FileHelper::CopyMandatoryEntry(uint16_t group,uint16_t elem,std::string value,const VRKey &vr)
 {
-   DataEntry *entry = CopyDataEntry(group,elem);
+   DataEntry *entry = CopyDataEntry(group,elem,vr);
    entry->SetString(value);
    Archive->Push(entry);
    entry->Delete();
index 86bf7c61024bd7f8b1db7b771cafb32aac522345..fe5f725fd54a0a89b49379dd31fc3dda81472ccb 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFileHelper.h,v $
   Language:  C++
-  Date:      $Date: 2006/03/29 16:09:48 $
-  Version:   $Revision: 1.41 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  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
@@ -21,6 +21,7 @@
 
 #include "gdcmDebug.h"
 #include "gdcmRefCounter.h"
+#include "gdcmVRKey.h"
 #include "gdcmFile.h"
 
 namespace gdcm 
@@ -191,11 +192,14 @@ protected:
    void RestoreWriteOfLibido();
 
    DataEntry *CopyDataEntry(uint16_t group, uint16_t elem, 
-                               const TagName &vr = GDCM_VRUNKNOWN);
+                               const VRKey &vr = GDCM_VRUNKNOWN);
    void CheckMandatoryElements();
-   void CheckMandatoryEntry(uint16_t group, uint16_t elem, std::string value);
-   void SetMandatoryEntry(uint16_t group, uint16_t elem, std::string value);
-   void CopyMandatoryEntry(uint16_t group, uint16_t elem, std::string value);
+   void CheckMandatoryEntry(uint16_t group, uint16_t elem, std::string value,
+                               const VRKey &vr = GDCM_VRUNKNOWN);
+   void SetMandatoryEntry(uint16_t group, uint16_t elem, std::string value,
+                               const VRKey &vr = GDCM_VRUNKNOWN);
+   void CopyMandatoryEntry(uint16_t group, uint16_t elem, std::string value,
+                               const VRKey &vr = GDCM_VRUNKNOWN);
    void RestoreWriteMandatory();
 
 private:
index 5798178fc17494c1ee0a8e48bfea5851f4b29b75..edbcf2d8b8d41281949b2a8f3a05dad8b31c74e9 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmMacro.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 15:20:34 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #define GDCMMACRO_H
 
 //-----------------------------------------------------------------------------
-#define gdcmTypeMacro(type) \
-   private : \
+#define gdcmTypeMacro(type)               \
+   private :                              \
       type(type &); /* Not implemented */ \
       type &operator=(type &) /* Not implemented */
 
-#define gdcmNewMacro(type) \
-   public : \
+#define gdcmNewMacro(type)                \
+   public :                               \
       static type *New() {return new type(); } /* Not implemented */
 
 //-----------------------------------------------------------------------------
index cafb784997905b96918f948b6a49ba5f778abc1e..bb036b7f5a5462ffb133fbbcc071badf76551e77 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmRefCounter.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 15:20:34 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.10 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -20,6 +20,8 @@
 #define GDCMREFCOUNTER_H
 
 #include "gdcmBase.h"
+//#include "gdcmDebug.h"
+#include <typeinfo>
 
 namespace gdcm 
 {
@@ -47,9 +49,10 @@ public:
    /// \remarks It decrements the reference counting
    void Unregister()
    {
+//std::cout <<"================Unreg " << typeid(*this).name() << std::endl;
       RefCount--;
       if(RefCount<=0)
-         delete this;
+        delete this;
    }
    /// \brief Get the reference counting
    /// \return Reference count
index 5e7113f6219f93181685010648a23a0c3811cd1d..9ce89bbc3e3e8196e922b6c2fed20e669f48b9c1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/02/16 20:06:15 $
-  Version:   $Revision: 1.65 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.66 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 namespace gdcm 
 {
 //-----------------------------------------------------------------------------
+// Constructor / Destructor
+
 // Constructor / Destructor
 /**
  * \brief   Constructor from a given SeqEntry
  */
-SeqEntry::SeqEntry( DictEntry *e ) 
-             : DocEntry(e)
+SeqEntry::SeqEntry( uint16_t group,uint16_t elem ) 
+             : DocEntry(group, elem, "SQ")
 {
    Length       = 0;
    ReadLength   = 0xffffffff;
@@ -51,7 +53,8 @@ SeqEntry::SeqEntry( DictEntry *e )
  * @param   depth depth level of the current Seq entry
  */
 SeqEntry::SeqEntry( DocEntry *e, int depth )
-             : DocEntry( e->GetDictEntry() )
+             //: DocEntry( e->GetDictEntry() )
+            : DocEntry( e->GetGroup(), e->GetElement(), e->GetVR() )
 {
    Length       = 0;
    ReadLength   = 0xffffffff;
index 3e9c8c8379b2103d30146df5cf44f35f26396237..a54e3b34ab1608e5d3d8a3357e8839e7c6653da1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.h,v $
   Language:  C++
-  Date:      $Date: 2006/02/16 20:06:15 $
-  Version:   $Revision: 1.40 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.41 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -43,10 +43,13 @@ class GDCM_EXPORT SeqEntry : public DocEntry
 
 public:
 /// \brief Contructs a SeqEntry with a RefCounter from DictEntry
-   static SeqEntry *New(DictEntry *e) {return new SeqEntry(e);}
+   //static SeqEntry *New(DictEntry *e) {return new SeqEntry(e);}
 /// \brief Contructs a SeqEntry with a RefCounter from DocEntry
    static SeqEntry *New(DocEntry *d, int depth) {return new SeqEntry(d,depth);}
-
+/// \brief Contructs a SeqEntry with a RefCounter from elementary values
+   static SeqEntry *New(uint16_t group,uint16_t elem, VRKey const &vr = GDCM_VRUNKNOWN) 
+                           {return new SeqEntry(group,elem);}
+   
    void Print(std::ostream &os = std::cout, std::string const &indent = "" ); 
    void WriteContent(std::ofstream *fp, FileType filetype);
    uint32_t ComputeFullLength();
@@ -76,8 +79,9 @@ public:
 protected:
 
 private:
-   SeqEntry( DictEntry *e);
+   //SeqEntry( DictEntry *e);
    SeqEntry( DocEntry *d, int depth );
+   SeqEntry( uint16_t group, uint16_t elem );
    ~SeqEntry();
 
 // Variables
index 9cd3df5f0fa4dd535d5cd0093ae25ba72fabbf36..f52fefd90e598520b93ede457cacd33619b57fcb 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSerieHelper.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/03/30 17:19:24 $
-  Version:   $Revision: 1.50 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.51 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #include "gdcmSerieHelper.h"
 #include "gdcmDirList.h"
 #include "gdcmFile.h"
-#include "gdcmDictEntry.h" // for TranslateToKey
+//#include "gdcmDictEntry.h" // for TranslateToKey : no more !
 #include "gdcmDebug.h"
 #include "gdcmUtil.h"
 
index 2d32f44359ac69c41166b06d91415d1c45372d70..d569db44a2c8ee245229433812eefe544581c5b6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmTagKey.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/08 09:35:44 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -32,7 +32,7 @@ namespace gdcm
 class TagKey
 {
 public :
-   TagKey(uint16_t gr, uint16_t elt) { tag[0] = gr;tag[1] = elt;}
+   TagKey(uint16_t group, uint16_t elem) { tag[0] = group;tag[1] = elem;}
    TagKey() { tag[0] = tag[1] = 0x0000;}
 
    friend std::ostream& operator<<(std::ostream& _os, const TagKey &_val);
@@ -43,13 +43,18 @@ public :
       sprintf(res,"%04x|%04x",tag[0],tag[1]);
       return std::string(res);
    }
-
+   ///\brief sets the Group Number for the TagKey
    void SetGroup(uint16_t group) { tag[0] = group; }
    uint16_t GetGroup() const { return tag[0]; }
 
-   void SetElement(uint16_t elem) { tag[1] = elem; }
+   ///\brief sets the Element Number for the TagKey
+   void SetElement(uint16_t elem) { tag[1] = elem; }   
    uint16_t GetElement() const { return tag[1]; }
 
+   ///\brief sets the Group Number and Element Number for the TagKey
+   void SetGroupElem(uint16_t group, uint16_t elem) 
+                               { tag[0] = group;tag[1] = elem; }
+   
    TagKey &operator=(const TagKey &_val)
    {
       tag[0] = _val.tag[0];