]> Creatis software - gdcm.git/commitdiff
* Preparation of writing a gdcmHeader iterator: generalisation of gdcmTagKey
authorfrog <frog>
Mon, 13 Sep 2004 12:10:52 +0000 (12:10 +0000)
committerfrog <frog>
Mon, 13 Sep 2004 12:10:52 +0000 (12:10 +0000)
    - The following is the doxygen comment of the typedef declaration
      of gdcmagKey in src/gdcmCommon.h:
           gdcmTagKey is made to old an "universal" (as in URL, Universal
           Ressource Locator)  key to a gdcmDocEntry i.e. a dicom tag.
           A dicom tag allways has a group and an element, but a set of tags
           embeded in various (optionally nested) sequences and sharing
           the same group and element all share the same (group, element)
           "identifier". Hence the (group, element) cannot be used as an
           identifier (in gdcm we shall refer to a "TagKey") of a tag.
           In order to construct a proper tag identifier (i.e. a key) we
           consider the following definition of a TagKey:
           - let Group, Element be the string representation of the
             group and element dicom tag members,
           - let ItemNumber be the string representation of the integer
             index of the considered item number of a sequence,
           Let the key of a tag embeded in a sequence, noted SeqTag, be
           the form:
              /ItemNumber#Group|Element
           where "/", "#" and "|" are characters acting as separators.
           Then the general form of a gdcmTagKey is given by:
              Group|Element<SeqTag>
           where <SeqTag> means NO or many instances of SeqTag.
           Hence the gdcmTagKey of a tag not "leaving" in a sequence is the
           string e.g.
               0028|1201
           but the gdcmTagKey of a tag "embeded" is the first item of
           a sequence, itself nested in the third item of a sequence is the
           string e.g.
               0004|1220/2#0008|0082/0#0008|0090
    - src/gdcmDocEntry.h: added a new Key (of type gdcmTagKey) member, in
      order to hold the new sequence compatible key. Previously, the
      GetKey() method would look in the underlying gdcmDictEntry.
    - src/gdcmDocEntry.cxx:
      -- constructor now copies the underlying DictEntry key, in the local
         Key member.
      -- ::Print: displays the member Key, instead of the (group, element).
    - src/gdcmCommon.h: added some comments on typedef gdcmTagKey.
    - src/gdcmDocEntrySet.h:xi
      -- ::ParseDES() now setups the gdcmTagKey of the sequence it is parsing.
      -- now has a new BaseTagKey member.
      -- STYLE.
  * src/gdcmValEntry.[h|cxx], src/gdcmBinEntry.[h|cxx]: the member VoidArea,
    previously a member of gdcmValEntry, moved to gdcmBinEntry were is
    truly belongs.
    This poses the problem with the semantics of the following lines
       LoadEntryVoidArea(0x0028,0x1201);  // R    LUT
       LoadEntryVoidArea(0x0028,0x1202);  // G    LUT
       LoadEntryVoidArea(0x0028,0x1203);  // B    LUT
    in gdcmDocument::gdcmDocument(std::string const & ). Please refer
    to the long FIXME note for what the problem is. Nevertheless in
    order to get things working the dicom dictionary was altered !
    Please fix things urgently...
  * Dicts/dicomV3.dic WRONGLY altered (this means we introduced a uncorrect
    information), see above note on moving the member VoidArea. Nevertheless
    the following entries previously correctly set as US are now inproperly
    set to OW:
      0028 1201 OW IMG Red Palette Color Lookup Table Data
      0028 1202 OW IMG Green Palette Color Lookup Table Data
      0028 1203 OW IMG Blue Palette Color Lookup Table Data
  * src/gdcmDocEntry.[h|cxx], src/gdcmSeqEntry.h: SQDepthLevel member
    of gdcmDocEntry moved to gdcmSeqEntry.
  * src/gdcmSeqEntry.cxx: STYLE.

14 files changed:
ChangeLog
Dicts/dicomV3.dic
TODO
src/gdcmBinEntry.cxx
src/gdcmBinEntry.h
src/gdcmCommon.h
src/gdcmDocEntry.cxx
src/gdcmDocEntry.h
src/gdcmDocEntrySet.h
src/gdcmDocument.cxx
src/gdcmSeqEntry.cxx
src/gdcmSeqEntry.h
src/gdcmValEntry.cxx
src/gdcmValEntry.h

index b63416ecf6bd5525393556519a6ac7ab2acd2538..36d6ee4f742ca1f9fe43f3f38c4a02de614bb627 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,68 @@
+2004-09-13 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
+  * Preparation of writing a gdcmHeader iterator: generalisation of gdcmTagKey
+    - The following is the doxygen comment of the typedef declaration
+      of gdcmagKey in src/gdcmCommon.h:
+           gdcmTagKey is made to old an "universal" (as in URL, Universal
+           Ressource Locator)  key to a gdcmDocEntry i.e. a dicom tag.
+           A dicom tag allways has a group and an element, but a set of tags
+           embeded in various (optionally nested) sequences and sharing
+           the same group and element all share the same (group, element)
+           "identifier". Hence the (group, element) cannot be used as an
+           identifier (in gdcm we shall refer to a "TagKey") of a tag.
+           In order to construct a proper tag identifier (i.e. a key) we
+           consider the following definition of a TagKey:
+           - let Group, Element be the string representation of the
+             group and element dicom tag members,
+           - let ItemNumber be the string representation of the integer
+             index of the considered item number of a sequence,
+           Let the key of a tag embeded in a sequence, noted SeqTag, be
+           the form:
+              /ItemNumber#Group|Element
+           where "/", "#" and "|" are characters acting as separators.
+           Then the general form of a gdcmTagKey is given by:
+              Group|Element<SeqTag>
+           where <SeqTag> means NO or many instances of SeqTag.
+           Hence the gdcmTagKey of a tag not "leaving" in a sequence is the
+           string e.g.
+               0028|1201
+           but the gdcmTagKey of a tag "embeded" is the first item of
+           a sequence, itself nested in the third item of a sequence is the
+           string e.g.
+               0004|1220/2#0008|0082/0#0008|0090
+    - src/gdcmDocEntry.h: added a new Key (of type gdcmTagKey) member, in
+      order to hold the new sequence compatible key. Previously, the 
+      GetKey() method would look in the underlying gdcmDictEntry.
+    - src/gdcmDocEntry.cxx:
+      -- constructor now copies the underlying DictEntry key, in the local
+         Key member.
+      -- ::Print: displays the member Key, instead of the (group, element).
+    - src/gdcmCommon.h: added some comments on typedef gdcmTagKey.
+    - src/gdcmDocEntrySet.h:xi
+      -- ::ParseDES() now setups the gdcmTagKey of the sequence it is parsing.
+      -- now has a new BaseTagKey member.
+      -- STYLE.
+  * src/gdcmValEntry.[h|cxx], src/gdcmBinEntry.[h|cxx]: the member VoidArea,
+    previously a member of gdcmValEntry, moved to gdcmBinEntry were is
+    truly belongs.
+    This poses the problem with the semantics of the following lines
+       LoadEntryVoidArea(0x0028,0x1201);  // R    LUT
+       LoadEntryVoidArea(0x0028,0x1202);  // G    LUT
+       LoadEntryVoidArea(0x0028,0x1203);  // B    LUT
+    in gdcmDocument::gdcmDocument(std::string const & ). Please refer
+    to the long FIXME note for what the problem is. Nevertheless in
+    order to get things working the dicom dictionary was altered !
+    Please fix things urgently...
+  * Dicts/dicomV3.dic WRONGLY altered (this means we introduced a uncorrect
+    information), see above note on moving the member VoidArea. Nevertheless
+    the following entries previously correctly set as US are now inproperly
+    set to OW:
+      0028 1201 OW IMG Red Palette Color Lookup Table Data
+      0028 1202 OW IMG Green Palette Color Lookup Table Data
+      0028 1203 OW IMG Blue Palette Color Lookup Table Data
+  * src/gdcmDocEntry.[h|cxx], src/gdcmSeqEntry.h: SQDepthLevel member
+    of gdcmDocEntry moved to gdcmSeqEntry.
+  * src/gdcmSeqEntry.cxx: STYLE.
+
 2004-08-04 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
   * Test/TestAllEntryVerify.cxx minor fix and added comments.
 
index e5657fd3571efc441af07a256505828a9f7a5fa6..1e6c3cd0e0eee7b397631f5b3c26abe960c1974a 100644 (file)
 0028 1103 US IMG Blue Palette Color Lookup Table Descriptor
 0028 1199 UI IMG Palette Color Lookup Table UID
 0028 1200 US IMG Gray Lookup Table Data (RET)
-0028 1201 US IMG Red Palette Color Lookup Table Data
-0028 1202 US IMG Green Palette Color Lookup Table Data
-0028 1203 US IMG Blue Palette Color Lookup Table Data
+0028 1201 OW IMG Red Palette Color Lookup Table Data
+0028 1202 OW IMG Green Palette Color Lookup Table Data
+0028 1203 OW IMG Blue Palette Color Lookup Table Data
 0028 1221 OW IMG Segmented Red Palette Color Lookup Table Data
 0028 1222 OW IMG Segmented Green Palette Color Lookup Table Data
 0028 1223 OW IMG Segmented Blue Palette Color Lookup Table Data
diff --git a/TODO b/TODO
index a891bf9fcdd288ed1d9f5bb6c3badd5519682e23..4673dc1063c90d5278d3adcf3dd985b463d3a451 100644 (file)
--- a/TODO
+++ b/TODO
@@ -16,6 +16,7 @@ Convert the C-like IO to C++ IO:
         binary IO are available at
         http://www.angelfire.com/country/aldev0/cpphowto/cpp_BinaryFileIO.html
 -----------------------------------------------------------------------------
+* Clean up src/gdcmValEntry.[h|cxx] from VoidArea
 * vtk/vtkGdcmHeader.cxx: if speed becomes a concern some changes can
   be made at the cost of memory consumption (refer to header of 
   vtk/vtkGdcmHeader.cxx)
index cee3120fdf2c134707c6ba9c6868bcd51b90c8ab..a010ff7217f4cd08d523ad3df22729ae78b87da2 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmBinEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/10 14:32:04 $
-  Version:   $Revision: 1.25 $
+  Date:      $Date: 2004/09/13 12:10:53 $
+  Version:   $Revision: 1.26 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -28,7 +28,7 @@
  */
 gdcmBinEntry::gdcmBinEntry(gdcmDictEntry* e) : gdcmValEntry(e)
 {
-   VoidArea = NULL;
+   VoidArea = 0;
 }
 
 /**
@@ -42,7 +42,8 @@ gdcmBinEntry::gdcmBinEntry(gdcmDocEntry* e) : gdcmValEntry(e->GetDictEntry())
    ImplicitVR   = e->IsImplicitVR();
    Offset       = e->GetOffset();
    PrintLevel   = e->GetPrintLevel();
-   SQDepthLevel = e->GetDepthLevel();
+   //FIXME
+   //SQDepthLevel = e->GetDepthLevel();
 
    VoidArea = 0; // let's be carefull !
 }
@@ -119,7 +120,7 @@ void gdcmBinEntry::Write(FILE *fp, FileType filetype)
 
 
 /// \brief Sets the value (non string) of the current Dicom Header Entry
-void gdcmBinEntry::SetVoidArea(void* area)  
+void gdcmBinEntry::SetVoidArea( void* area )  
 { 
    if (VoidArea)
       free(VoidArea);
index 8ba66fdd57d88d871e6f0857ab80f2fcdf1a487c..bbc8451d3eea29d798f4d58a4528018d12cc0845 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmBinEntry.h,v $
   Language:  C++
-  Date:      $Date: 2004/09/10 14:32:04 $
-  Version:   $Revision: 1.16 $
+  Date:      $Date: 2004/09/13 12:10:53 $
+  Version:   $Revision: 1.17 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -45,8 +45,8 @@ public:
 
    /// \brief Returns the area value of the current Dicom Header Entry
    ///  when it's not string-translatable (e.g : a LUT table)         
-   void* GetVoidArea()  { return VoidArea; };
-   void SetVoidArea(void* area);
+   void* GetVoidArea()  { return VoidArea; }
+   void  SetVoidArea( void* area );
          
 protected:
 
@@ -55,8 +55,8 @@ private:
 // Variables
    
    /// \brief unsecure memory area to hold 'non string' values 
-   /// (ie : Lookup Tables, overlays, icons)   
-  // void *VoidArea;
+   ///       (ie : Lookup Tables, overlays, icons)   
+   void *VoidArea;
 
 };
 
index e36b21e30046509d25b1d6cbaf7cb2f15dd04b92..08bf07a0904252ba23d3fdf3b2169f5783a5487f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmCommon.h,v $
   Language:  C++
-  Date:      $Date: 2004/09/09 17:49:24 $
-  Version:   $Revision: 1.30 $
+  Date:      $Date: 2004/09/13 12:10:53 $
+  Version:   $Revision: 1.31 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -96,6 +96,33 @@ const std::string GDCM_BINLOADED = "gdcm::Binary data loaded";
 const std::string GDCM_NOTLOADED = "gdcm::NotLoaded";
 const std::string GDCM_UNREAD    = "gdcm::UnRead";
 
+/// \brief gdcmTagKey is made to old an "universal" (as in URL, Universal
+///        Ressource Locator)  key to a gdcmDocEntry i.e. a dicom tag.
+///        A dicom tag allways has a group and an element, but a set of tags
+///        embeded in various (optionally nested) sequences and sharing
+///        the same group and element all share the same (group, element)
+///        "identifier". Hence the (group, element) cannot be used as an
+///        identifier (in gdcm we shall refer to a "TagKey") of a tag.
+///        In order to construct a proper tag identifier (i.e. a key) we
+///        consider the following definition of a TagKey:
+///        - let Group, Element be the string representation of the
+///          group and element dicom tag members,
+///        - let ItemNumber be the string representation of the integer
+///          index of the considered item number of a sequence,
+///        Let the key of a tag embeded in a sequence, noted SeqTag, be
+///        the form:
+///           /ItemNumber#Group|Element
+///        where "/", "#" and "|" are characters acting as separators.
+///        Then the general form of a gdcmTagKey is given by:
+///           Group|Element<SeqTag>
+///        where <SeqTag> means NO or many instances of SeqTag.
+///        Hence the gdcmTagKey of a tag not "leaving" in a sequence is the
+///        string e.g. 
+///            0028|1201
+///        but the gdcmTagKey of a tag "embeded" is the first item of
+///        a sequence, itself nested in the third item of a sequence is the
+///        string e.g.
+///            0004|1220/2#0008|0082/0#0008|0090
 typedef std::string gdcmTagKey;
 typedef std::string TagName;
 
index 54c7ed04a629726e3e8d8c184bfe8ea2822586ea..5f313486e8e6065d719c6daaaca6605c57ba9bf6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/09 17:49:24 $
-  Version:   $Revision: 1.18 $
+  Date:      $Date: 2004/09/13 12:10:53 $
+  Version:   $Revision: 1.19 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -37,6 +37,7 @@ gdcmDocEntry::gdcmDocEntry(gdcmDictEntry* in)
 {
    ImplicitVR = false;
    DictEntry  = in;
+   SetKey( in->GetKey( ) );
    Offset     = 0 ; // To avoid further missprinting
 }
 
@@ -58,14 +59,13 @@ void gdcmDocEntry::Print(std::ostream & os)
    std::string d2, vr;
    std::ostringstream s;
    uint32_t lgth;
-   char greltag[10];  //group element tag
 
    g  = GetGroup();
    e  = GetElement();
    o  = GetOffset();
    vr = GetVR();
-   sprintf(greltag,"%04x|%04x ",g,e);           
-   s << greltag ;
+
+   s << GetKey();
        
    if (PrintLevel >= 2)
    {
index e3162589e57a68774a59f470a2d04284e93f97a8..734a9f8333ffa06a827c0f7f255dda8ab4160d6b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.h,v $
   Language:  C++
-  Date:      $Date: 2004/09/03 20:27:44 $
-  Version:   $Revision: 1.19 $
+  Date:      $Date: 2004/09/13 12:10:53 $
+  Version:   $Revision: 1.20 $
                                                                                 
   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,10 @@ public:
    uint16_t      GetElement()   { return DictEntry->GetElement();};
 
    /// Returns the 'key' of the current Dicom Header Entry
-   std::string  GetKey()       { return DictEntry->GetKey();    };
+   void  SetKey( gdcmTagKey key ) { Key = key; }
+
+   /// Returns the 'key' of the current Dicom Header Entry
+   std::string GetKey() { return Key; }
 
    /// \brief Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom
    /// Dictionnary of the current Dicom Header Entry
@@ -132,14 +135,6 @@ public:
    bool IsItemDelimitor();
    bool IsSequenceDelimitor();   
 
-   /// \brief Gets the depth level of a Dicom header entry embedded in
-   ///        a SeQuence
-   int GetDepthLevel() { return SQDepthLevel; }
-
-   /// \brief Sets the depth level of a Dicom header entry embedded in
-   ///        a SeQuence
-   void SetDepthLevel(int depth) { SQDepthLevel = depth; }
-
 private:
    // FIXME: In fact we should be more specific and use :
    // friend gdcmDocEntry * gdcmHeader::ReadNextElement(void);
@@ -170,9 +165,10 @@ protected:
 
    /// How many details are to be printed (value : 0,1,2)      
    int PrintLevel;
-   
-   /// Gives the depth level of elements inside SeQuences   
-   int SQDepthLevel;
+
+   /// \brief Generalized key (i.e. a gdcmBaseTagKey prepending a gdcmTagKey)
+   ///        of this gdcmDocEntry
+   gdcmTagKey Key;
 };
 
 //-----------------------------------------------------------------------------
index 26fd1269a2f10101cb739999c41df4ff795aa95d..982e02862d21f1983e7e7d974d4e9a936d668037 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntrySet.h,v $
   Language:  C++
-  Date:      $Date: 2004/08/26 15:29:52 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2004/09/13 12:10:53 $
+  Version:   $Revision: 1.16 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -22,6 +22,7 @@
 #include "gdcmException.h"
 #include "gdcmDocEntry.h"
  
+typedef std::string gdcmBaseTagKey;
 //-----------------------------------------------------------------------------
 
 class GDCM_EXPORT gdcmDocEntrySet
@@ -48,6 +49,9 @@ public:
    /// SeQuence
    void SetDepthLevel(int depth) { SQDepthLevel = depth; }
 
+   void           SetBaseTagKey( gdcmBaseTagKey key ) { BaseTagKey = key; }
+   gdcmBaseTagKey GetBaseTagKey( ) { return BaseTagKey; }
+
    virtual gdcmDocEntry* GetDocEntryByNumber(uint16_t group,
                                              uint16_t element) = 0;
    gdcmDocEntry *GetDocEntryByName(std::string const & name);
@@ -78,6 +82,10 @@ protected:
 
    /// Gives the depth level of the element set inside SeQuences   
    int SQDepthLevel;
+
+   /// \brief A TagKey of a gdcmDocEntry nested in a sequence is prepended
+   ///        with this BaseTagKey.
+   gdcmBaseTagKey BaseTagKey;
 private:
 };
 
index cdcdd9cb1b69e1b335a8fd568573075c8f76e8d2..9976959e156995dc10708b731ed4b5cd920a26ac 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/13 07:49:36 $
-  Version:   $Revision: 1.75 $
+  Date:      $Date: 2004/09/13 12:10:53 $
+  Version:   $Revision: 1.76 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -109,8 +109,7 @@ gdcmDocument::gdcmDocument( std::string const & filename )
    
    SQDepthLevel = 0;
    
-   long l = ParseDES( this, beg, lgt, false); // le Load sera fait a la volee
-   (void)l; //is l used anywhere ?
+   (void)ParseDES( this, beg, lgt, false); // le Load sera fait a la volee
 
    rewind(Fp);
    
@@ -120,13 +119,31 @@ gdcmDocument::gdcmDocument( std::string const & filename )
    if( PhotometricInterpretation == "PALETTE COLOR " )
    {
       LoadEntryVoidArea(0x0028,0x1200);  // gray LUT   
+      /// FIXME FIXME FIXME
+      /// The tags refered by the three following lines used to be CORRECTLY
+      /// defined as having an US Value Representation in the public
+      /// dictionnary. BUT the semantics implied by the three following
+      /// lines state that the corresponding tag contents are in fact
+      /// the ones of a gdcmBinEntry.
+      /// In order to fix things "Quick and Dirty" the dictionnary was
+      /// altered on PURPOUS but now contains a WRONG value.
+      /// In order to fix things and restore the dictionary to its
+      /// correct value, one needs to decided of the semantics by deciding
+      /// wether the following tags are either:
+      /// - multivaluated US, and hence loaded as gdcmValEntry, but afterwards
+      ///   also used as gdcmBinEntry, which requires the proper conversion,
+      /// - OW, and hence loaded as gdcmBinEntry, but afterwards also used
+      ///   as gdcmValEntry, which requires the proper conversion.
       LoadEntryVoidArea(0x0028,0x1201);  // R    LUT
       LoadEntryVoidArea(0x0028,0x1202);  // G    LUT
       LoadEntryVoidArea(0x0028,0x1203);  // B    LUT
       
-      LoadEntryVoidArea(0x0028,0x1221);  // Segmented Red   Palette Color LUT Data
-      LoadEntryVoidArea(0x0028,0x1222);  // Segmented Green Palette Color LUT Data
-      LoadEntryVoidArea(0x0028,0x1223);  // Segmented Blue  Palette Color LUT Data
+      // Segmented Red   Palette Color LUT Data
+      LoadEntryVoidArea(0x0028,0x1221);
+      // Segmented Green Palette Color LUT Data
+      LoadEntryVoidArea(0x0028,0x1222);
+      // Segmented Blue  Palette Color LUT Data
+      LoadEntryVoidArea(0x0028,0x1223);
    } 
    //FIXME later : how to use it?
    LoadEntryVoidArea(0x0028,0x3006);  //LUT Data (CTX dependent) 
@@ -1017,7 +1034,7 @@ void * gdcmDocument::GetEntryVoidAreaByNumber(uint16_t group, uint16_t elem)
  * @param group   group number of the Entry 
  * @param elem  element number of the Entry
  */
-void *gdcmDocument::LoadEntryVoidArea(uint16_t group, uint16_t elem)
+voidgdcmDocument::LoadEntryVoidArea(uint16_t group, uint16_t elem)
 {
    gdcmDocEntry *docElement = GetDocEntryByNumber(group, elem);
    if ( !docElement )
@@ -1040,7 +1057,10 @@ void *gdcmDocument::LoadEntryVoidArea(uint16_t group, uint16_t elem)
       return NULL;
    }
    /// \TODO Drop any already existing void area! JPR
-   SetEntryVoidAreaByNumber(a, group, elem);
+   if( !SetEntryVoidAreaByNumber( a, group, elem ) );
+   {
+      dbg.Verbose(0, "gdcmDocument::LoadEntryVoidArea setting failed.");
+   }
 
    return a;
 }
@@ -1083,15 +1103,16 @@ bool gdcmDocument::SetEntryVoidAreaByNumber(void * area,
                                             uint16_t group, 
                                             uint16_t element) 
 {
-   gdcmTagKey key = gdcmDictEntry::TranslateToKey(group, element);
-   if ( !TagHT.count(key))
+   gdcmDocEntry* currentEntry = GetDocEntryByNumber(group, element);
+   if ( !currentEntry )
    {
       return false;
    }
-
-   // This was for multimap ?
-   (( gdcmBinEntry *)( ((TagHT.equal_range(key)).first)->second ))->SetVoidArea(area);
-      
+   if ( gdcmBinEntry* binEntry = dynamic_cast<gdcmBinEntry*>(currentEntry) )
+   {
+      binEntry->SetVoidArea( area );
+      return true;
+   }
    return true;
 }
 
@@ -1296,7 +1317,6 @@ long gdcmDocument::ParseDES(gdcmDocEntrySet *set,
                             bool delim_mode)
 {
    gdcmDocEntry *newDocEntry = 0;
-   gdcmValEntry *newValEntry = 0;
    unsigned long l = 0;
    
    int depth = set->GetDepthLevel();
@@ -1319,11 +1339,12 @@ long gdcmDocument::ParseDES(gdcmDocEntrySet *set,
          if ( gdcmGlobal::GetVR()->IsVROfGdcmStringRepresentable(vr) )
          {
             /////// ValEntry
-            newValEntry = new gdcmValEntry(newDocEntry->GetDictEntry());
-            newValEntry->Copy(newDocEntry);
-            newValEntry->SetDepthLevel(depth);
-            set->AddEntry(newValEntry);
-            LoadDocEntry(newValEntry);
+            gdcmValEntry* newValEntry =
+               new gdcmValEntry( newDocEntry->GetDictEntry() );
+            newValEntry->Copy( newDocEntry );
+            newValEntry->SetKey( set->GetBaseTagKey() + newValEntry->GetKey() );
+            set->AddEntry( newValEntry );
+            LoadDocEntry( newValEntry );
             if (newValEntry->IsItemDelimitor())
             {
                break;
@@ -1343,10 +1364,12 @@ long gdcmDocument::ParseDES(gdcmDocEntrySet *set,
             }
 
             ////// BinEntry or UNKOWN VR:
-            gdcmBinEntry *bn = new gdcmBinEntry(newDocEntry->GetDictEntry());
-            bn->Copy(newDocEntry);
-            set->AddEntry(bn);
-            LoadDocEntry(bn);
+            gdcmBinEntry* newBinEntry =
+               new gdcmBinEntry( newDocEntry->GetDictEntry() );
+            newBinEntry->Copy( newDocEntry );
+            newBinEntry->SetKey( set->GetBaseTagKey() + newBinEntry->GetKey() );
+            set->AddEntry( newBinEntry );
+            LoadDocEntry( newBinEntry );
          }
 
          if (newDocEntry->GetGroup()   == 0x7fe0 && 
@@ -1387,20 +1410,21 @@ long gdcmDocument::ParseDES(gdcmDocEntrySet *set,
             }
          }
          // no other way to create it ...
-         gdcmSeqEntry *sq = new gdcmSeqEntry(newDocEntry->GetDictEntry(),
-                                             set->GetDepthLevel());
-         sq->Copy(newDocEntry);
-         sq->SetDelimitorMode(delim_mode);
-         sq->SetDepthLevel(depth);
+         gdcmSeqEntry* newSeqEntry =
+            new gdcmSeqEntry( newDocEntry->GetDictEntry(),
+                              set->GetDepthLevel() );
+         newSeqEntry->Copy( newDocEntry );
+         newSeqEntry->SetDelimitorMode( delim_mode );
+         newSeqEntry->SetDepthLevel( depth );
+         newSeqEntry->SetKey( set->GetBaseTagKey() + newSeqEntry->GetKey() );
 
          if ( l != 0 )
          {  // Don't try to parse zero-length sequences
-            long lgt = ParseSQ( sq, 
-                                newDocEntry->GetOffset(),
-                                l, delim_mode);
-            (void)lgt;  //not used...
+            (void)ParseSQ( newSeqEntry, 
+                           newDocEntry->GetOffset(),
+                           l, delim_mode);
          }
-         set->AddEntry(sq);
+         set->AddEntry( newSeqEntry );
          if ( !delim_mode && (ftell(Fp)-offset) >= l_max)
          {
             break;
@@ -1415,17 +1439,15 @@ long gdcmDocument::ParseDES(gdcmDocEntrySet *set,
  * \brief   Parses a Sequence ( SeqEntry after SeqEntry)
  * @return  parsed length for this level
  */ 
-long gdcmDocument::ParseSQ(gdcmSeqEntry *set,
-                           long offset, long l_max, bool delim_mode)
+long gdcmDocument::ParseSQ( gdcmSeqEntry* seqEntry,
+                            long offset, long l_max, bool delim_mode)
 {
    int SQItemNumber = 0;
    bool dlm_mod;
-   //int depth = set->GetDepthLevel();
-   //(void)depth; //not used
 
    while (true)
    {
-      gdcmDocEntry *newDocEntry = ReadNextDocEntry();   
+      gdcmDocEntrynewDocEntry = ReadNextDocEntry();   
       if ( !newDocEntry )
       {
          // FIXME Should warn user
@@ -1435,7 +1457,7 @@ long gdcmDocument::ParseSQ(gdcmSeqEntry *set,
       {
          if ( newDocEntry->IsSequenceDelimitor() )
          {
-            set->SetSequenceDelimitationItem( newDocEntry );
+            seqEntry->SetSequenceDelimitationItem( newDocEntry );
             break;
          }
       }
@@ -1444,8 +1466,13 @@ long gdcmDocument::ParseSQ(gdcmSeqEntry *set,
           break;
       }
 
-      gdcmSQItem *itemSQ = new gdcmSQItem(set->GetDepthLevel());
-      itemSQ->AddEntry(newDocEntry);
+      gdcmSQItem *itemSQ = new gdcmSQItem( seqEntry->GetDepthLevel() );
+      std::ostringstream newBase;
+      newBase << seqEntry->GetKey()
+              << "/"
+              << SQItemNumber
+              << "#";
+      itemSQ->SetBaseTagKey( newBase.str() );
       unsigned int l = newDocEntry->GetReadLength();
       
       if ( l == 0xffffffff )
@@ -1457,12 +1484,11 @@ long gdcmDocument::ParseSQ(gdcmSeqEntry *set,
          dlm_mod = false;
       }
    
-      int lgr = ParseDES(itemSQ, newDocEntry->GetOffset(), l, dlm_mod);
-      (void)lgr;  //FIXME not used
+      (void)ParseDES(itemSQ, newDocEntry->GetOffset(), l, dlm_mod);
       
-      set->AddEntry(itemSQ, SQItemNumber); 
+      seqEntry->AddEntry( itemSQ, SQItemNumber ); 
       SQItemNumber++;
-      if ( !delim_mode && (ftell(Fp)-offset) >= l_max)
+      if ( !delim_mode && ( ftell(Fp) - offset ) >= l_max )
       {
          break;
       }
@@ -1554,7 +1580,6 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry)
    if ( IsDocEntryAnInteger(entry) )
    {   
       uint32_t NewInt;
-      //std::ostringstream s; //shadow previous declaration
       int nbInt;
       // When short integer(s) are expected, read and convert the following 
       // n *two characters properly i.e. consider them as short integers as
index ca6e13055ef178074d8f2930b5f2ca2f5fdeac88..d31c2b10b38e93632fb8ae9f0a75043113bcd2e4 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/08/31 14:24:47 $
-  Version:   $Revision: 1.26 $
+  Date:      $Date: 2004/09/13 12:10:53 $
+  Version:   $Revision: 1.27 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 gdcmSeqEntry::gdcmSeqEntry(gdcmDictEntry* e, int depth) 
              : gdcmDocEntry(e)
 {
-   delimitor_mode = false;
-   seq_term  = NULL;
-   SQDepthLevel = depth;
    UsableLength = 0;
    ReadLength = 0xffffffff;
+   SQDepthLevel = depth;
+
+   delimitor_mode = false;
+   seq_term  = NULL;
 }
 
 /**
@@ -45,15 +46,17 @@ gdcmSeqEntry::gdcmSeqEntry(gdcmDictEntry* e, int depth)
  * @param   e Pointer to existing Doc entry
  * @param   depth depth level of the current Seq entry
   */
-gdcmSeqEntry::gdcmSeqEntry(gdcmDocEntry* e, int depth) : gdcmDocEntry(e->GetDictEntry())
+gdcmSeqEntry::gdcmSeqEntry( gdcmDocEntry* e, int depth )
+             : gdcmDocEntry( e->GetDictEntry() )
 {
    this->UsableLength = 0;
    this->ReadLength   = 0xffffffff;
+   SQDepthLevel = depth;
+
    this->ImplicitVR   = e->IsImplicitVR();
    this->Offset       = e->GetOffset();
-   //this->printLevel   = e->GetPrintLevel(); // no longer exists ?!?
-   this->SQDepthLevel = depth;
 }
+
 /**
  * \brief   Canonical destructor.
  */
@@ -66,11 +69,11 @@ gdcmSeqEntry::~gdcmSeqEntry() {
       delete seq_term;
 }
 
-/*
+/**
  * \brief   canonical Printer
  */
-void gdcmSeqEntry::Print(std::ostream &os){
-
+void gdcmSeqEntry::Print(std::ostream &os)
+{
    // First, Print the Dicom Element itself.
    SetPrintLevel(2);   
    gdcmDocEntry::Print(os);
@@ -119,8 +122,8 @@ void gdcmSeqEntry::Write(FILE *fp, FileType filetype)
       (*cc)->Write(fp, filetype);
    }
    
-    //we force the writting of a Sequence Delimitation item
-    // because we wrote the Sequence as a 'no Length' sequence
+   // we force the writting of a Sequence Delimitation item
+   // because we wrote the Sequence as a 'no Length' sequence
    fwrite ( &seq_term_gr,(size_t)2 ,(size_t)1 ,fp);
    fwrite ( &seq_term_el,(size_t)2 ,(size_t)1 ,fp);
    fwrite ( &seq_term_lg,(size_t)4 ,(size_t)1 ,fp); 
@@ -129,22 +132,21 @@ void gdcmSeqEntry::Write(FILE *fp, FileType filetype)
 //-----------------------------------------------------------------------------
 // Public
 
- /// \brief   adds the passed ITEM to the ITEM chained List for this SeQuence.      
-void gdcmSeqEntry::AddEntry(gdcmSQItem *sqItem, int itemNumber) {
+/// \brief   adds the passed ITEM to the ITEM chained List for this SeQuence.
+void gdcmSeqEntry::AddEntry(gdcmSQItem *sqItem, int itemNumber)
+{
    sqItem->SetSQItemNumber(itemNumber);
    items.push_back(sqItem);
 }
 
-/// \brief Sets the depth level of a Sequence Entry embedded in a SeQuence 
-void gdcmSeqEntry::SetDepthLevel(int depth) {
-   SQDepthLevel = depth;
-}
-
-/// \brief return a pointer to the SQItem referenced by its ordinal number
-/// (returns the first one if ordinal number is <0
-///  returns the last  one if ordinal number is > item number
-
-gdcmSQItem *gdcmSeqEntry::GetSQItemByOrdinalNumber(int nb) {
+/**
+ * \brief return a pointer to the SQItem referenced by its ordinal number.
+ *        Returns the first item when argument is negative.
+ *        Returns the last item when argument is bigget than the total
+ *        item number.
+ */
+gdcmSQItem *gdcmSeqEntry::GetSQItemByOrdinalNumber(int nb)
+{
    if (nb<0)
       return (*(items.begin()));
    int count = 0 ;
index 61c7d8b6b1ac4b6f16157f5d008be357efb267ee..a0b0d67b2a8491a7bdc03766a2279b41144faddd 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.h,v $
   Language:  C++
-  Date:      $Date: 2004/08/26 15:29:53 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2004/09/13 12:10:53 $
+  Version:   $Revision: 1.16 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -50,8 +50,11 @@ public:
    void AddEntry(gdcmSQItem *it, int itemNumber);
    gdcmSQItem *GetSQItemByOrdinalNumber(int itemNumber);
 
-   void SetDepthLevel(int depth);
-         
+   /// Gets the depth level
+   int GetDepthLevel() { return SQDepthLevel; }
+                                                                                
+   /// Sets the depth level of a Sequence Entry embedded in a SeQuence
+   void SetDepthLevel(int depth) { SQDepthLevel = depth; }
 protected:
 
 private:
@@ -65,6 +68,9 @@ private:
    
    /// sequence terminator item 
    gdcmDocEntry *seq_term;
+
+   /// Gives the depth level of elements inside SeQuences
+   int SQDepthLevel;
 };
 
 //-----------------------------------------------------------------------------
index c1018fcaa2a235a3e3795d6018cb29549e4600b1..82d2743610880317549e47ab8f1de5b6bbe6a8d1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmValEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/10 18:54:39 $
-  Version:   $Revision: 1.24 $
+  Date:      $Date: 2004/09/13 12:10:53 $
+  Version:   $Revision: 1.25 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
  */
 gdcmValEntry::gdcmValEntry(gdcmDictEntry* e) : gdcmDocEntry(e)
 {
-   VoidArea = NULL; // will be in BinEntry ?
 }
 
 /**
  * \brief   Constructor from a given gdcmDocEntry
  * @param   e Pointer to existing Doc entry
  */
-gdcmValEntry::gdcmValEntry(gdcmDocEntry* e) : gdcmDocEntry(e->GetDictEntry())
+gdcmValEntry::gdcmValEntry(gdcmDocEntry* e)
+             : gdcmDocEntry(e->GetDictEntry())
 {
    UsableLength = e->GetLength();
    ReadLength   = e->GetReadLength();
    ImplicitVR   = e->IsImplicitVR();
    Offset       = e->GetOffset();
    PrintLevel   = e->GetPrintLevel();
-   SQDepthLevel = e->GetDepthLevel();
-
-   VoidArea = NULL; // will be in BinEntry ?
 }
 
 
@@ -57,11 +54,6 @@ gdcmValEntry::gdcmValEntry(gdcmDocEntry* e) : gdcmDocEntry(e->GetDictEntry())
  */
 gdcmValEntry::~gdcmValEntry ()
 {
-   if (!VoidArea)  // will be in BinEntry
-   {
-      free(VoidArea);
-      VoidArea = NULL; // let's be carefull !
-   }
 }
 
 //-----------------------------------------------------------------------------
index f2811f75135772db71d9446a16f5c3402b9bee2e..4abc7eff65faf86ac98fe9d291fe4d64663c9b7b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmValEntry.h,v $
   Language:  C++
-  Date:      $Date: 2004/09/03 20:27:44 $
-  Version:   $Revision: 1.21 $
+  Date:      $Date: 2004/09/13 12:10:53 $
+  Version:   $Revision: 1.22 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -45,15 +45,10 @@ public:
    /// Sets the value (string) of the current Dicom Document Entry
    void SetValue(std::string const & val) { Value = val; };
 
-   /// Sets the value (void *) of the current Dicom Document Entry
-   void SetVoidArea(void * val) { VoidArea = val; };
-
    virtual void Print(std::ostream &os = std::cout); 
    virtual void Write(FILE *fp, FileType filetype);
 
 protected:
-   /// \brief for 'non string' values. Will be move to gdcmBinEntry, later
-   void* VoidArea;  // clean it out later
    
 private:
 // Members :