]> Creatis software - gdcm.git/commitdiff
* gdcmDicomDirElement.[h|cxx] : change the AddEntry method. Now, it gets a
authorregrain <regrain>
Thu, 20 Jan 2005 17:15:53 +0000 (17:15 +0000)
committerregrain <regrain>
Thu, 20 Jan 2005 17:15:53 +0000 (17:15 +0000)
     type and not a string. So, there remove problems on the format of the
     string.
   -- BeNours

ChangeLog
src/gdcmCommon.h
src/gdcmDefaultDicts.cxx.in
src/gdcmDicomDirElement.cxx
src/gdcmDicomDirElement.h

index 6956bf1dfa5b64fc6dc665414c4293fb8f863b7c..3bf409f0f52a4aed3cecd75f0bf536b575e96c59 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
+2005-01-20 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+   * gdcmDicomDirElement.[h|cxx] : change the AddEntry method. Now, it gets a
+     type and not a string. So, there remove problems on the format of the
+     string.
+
 2005-01-20 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
    * src/gdcmDicomDirObject.h : set the FillObject method in protected.
-     Thus, DicomDirXXX are created with a flad that indicates if the created 
+     Thus, DicomDirXXX are created with a flad that indicates if the created
      object is empty or not (when not empty, the DicomDirElement is used to
      fill the object)
 
index c5cbc8dc01a8b8a7aaa21cd6523bceabd50a3c71..2d9f5f9e416114cbeec03d67fcd7fd55a32a82a4 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmCommon.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/20 11:39:49 $
-  Version:   $Revision: 1.51 $
+  Date:      $Date: 2005/01/20 17:15:53 $
+  Version:   $Revision: 1.52 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -125,6 +125,15 @@ enum FileType {
    ACR,
    ACR_LIBIDO
 };
+
+enum DicomDirType {
+   DD_UNKNOWN = 0,
+   DD_META,
+   DD_PATIENT,
+   DD_STUDY,
+   DD_SERIE,
+   DD_IMAGE
+};
 } //namespace gdcm
 //-----------------------------------------------------------------------------
 #endif
index 6c3c53d571ca025a73f463d5630771decb7e5164..58649c6e7a7642a3a37ed721bdacd957d3d17ab0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDefaultDicts.cxx.in,v $
   Language:  C++
-  Date:      $Date: 2005/01/07 12:29:17 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2005/01/20 17:15:54 $
+  Version:   $Revision: 1.6 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -30,11 +30,11 @@ namespace gdcm
 
 typedef struct
 {
-  uint16_t group;
-  uint16_t element;
-  const char *vr;
-  const char *vm;
-  const char *name;
+   uint16_t group;
+   uint16_t element;
+   const char *vr;
+   const char *vm;
+   const char *name;
 } DICT_ENTRY;
 
 static DICT_ENTRY datadir[] = {
@@ -43,14 +43,14 @@ static DICT_ENTRY datadir[] = {
 
 void FillDefaultDataDict(Dict *d)
 {
-  unsigned int i = 0;
-  DICT_ENTRY n = datadir[i];
-  while( n.name != 0 )
-    {
-    const DictEntry e( n.group, n.element, n.vr, n.vm, n.name);
-    d->AddNewEntry( e );
-    n = datadir[++i];
-    }
+   unsigned int i = 0;
+   DICT_ENTRY n = datadir[i];
+   while( n.name != 0 )
+   {
+      const DictEntry e( n.group, n.element, n.vr, n.vm, n.name);
+      d->AddNewEntry( e );
+      n = datadir[++i];
+   }
 }
 
 void FillDefaultTSDict(TSHT & ts)
@@ -65,29 +65,44 @@ void FillDefaultVRDict(VRHT & vr)
 
 typedef struct
 {
-  const char *type;
-  unsigned short group;
-  unsigned short element;
-  const char *value;
+   const char *type;
+   unsigned short group;
+   unsigned short element;
+   const char *value;
 } ELEMENT;
 
-static ELEMENT dataelement[] = {
+static ELEMENT dataElement[] = {
 @DICOM_DIR_DICTIONARY@
 };
 
 void FillDefaultDIRDict(DicomDirElement *dde)
 {
-  unsigned int i = 0;
-  ELEMENT e = dataelement[i];
-  Element elem;
-  while( e.type != 0 )
-    {
-    elem.Group = e.group;
-    elem.Elem  = e.element;
-    elem.Value = e.value;
-    dde->AddNewEntry( e.type, elem);
-    e = dataelement[++i];
-    }
+   unsigned int i = 0;
+   ELEMENT e = dataElement[i];
+   Element elem;
+   DicomDirType type;
+
+   while( e.type != 0 )
+   {
+      if( e.type == "metaElem" )
+         type = DD_META;
+      else if( e.type == "patientElem" )
+         type = DD_PATIENT;
+      else if( e.type == "studyElem" )
+         type = DD_STUDY;
+      else if( e.type == "serieElem" )
+         type = DD_SERIE;
+      else if( e.type == "imageElem" )
+         type = DD_IMAGE;
+      else
+         type = DD_UNKNOWN;
+
+      elem.Group = e.group;
+      elem.Elem  = e.element;
+      elem.Value = e.value;
+      dde->AddNewEntry( type, elem);
+      e = dataElement[++i];
+   }
 }
 
 } //end gdcm namespace
index 0fe6edb7ddfb451c20f3fa7a52732ff185b58d7e..47e0750e1a4ed41f5285cdc4ba8372d4a58ebdc0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirElement.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/20 11:40:14 $
-  Version:   $Revision: 1.29 $
+  Date:      $Date: 2005/01/20 17:15:54 $
+  Version:   $Revision: 1.30 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -47,18 +47,34 @@ DicomDirElement::DicomDirElement()
    else
    {
       char buff[1024];
-      std::string type;
+      std::string strType;
       Element elem;
+      DicomDirType type;
 
       while (!from.eof())
       {
          from >> std::ws;
          from.getline(buff, 1024, ' ');
-         type = buff;
+         strType = buff;
+
+         if( strType == "metaElem" )
+            type = DD_META;
+         else if( strType == "patientElem" )
+            type = DD_PATIENT;
+         else if( strType == "studyElem" )
+            type = DD_STUDY;
+         else if( strType == "serieElem" )
+            type = DD_SERIE;
+         else if( strType == "imageElem" )
+            type = DD_IMAGE;
+         else
+         {
+            gdcmVerboseMacro("Unknown type found in the file : "
+                             <<filename.c_str());
+            type = DD_UNKNOWN;
+         }
 
-         if( type == "metaElem"  || type == "patientElem" || 
-             type == "studyElem" || type == "serieElem"   || 
-             type == "imageElem" )
+         if( type!=DD_UNKNOWN )
          {
             from >> std::hex >> elem.Group >> elem.Elem;
 
@@ -147,32 +163,28 @@ void DicomDirElement::Print(std::ostream &os)
  * @param type type
  * @param elem elem
  */
-bool DicomDirElement::AddNewEntry(std::string const &type, 
+bool DicomDirElement::AddNewEntry(DicomDirType type, 
                                   Element const &elem)
 {
-   if( type == "metaElem" )
-   {
-      DicomDirMetaList.push_back(elem);
-   }
-   else if( type == "patientElem" )
-   {
-      DicomDirPatientList.push_back(elem);
-   }
-   else if( type == "studyElem" )
-   {
-      DicomDirStudyList.push_back(elem);
-   }
-   else if( type == "serieElem" )
-   {
-      DicomDirSerieList.push_back(elem);
-   }
-   else if( type == "imageElem" )
-   {
-      DicomDirImageList.push_back(elem);
-   }
-   else
+   switch( type )
    {
-     return false;
+      case DD_META :
+         DicomDirMetaList.push_back(elem);
+         break;
+      case DD_PATIENT :
+         DicomDirPatientList.push_back(elem);
+         break;
+      case DD_STUDY :
+         DicomDirStudyList.push_back(elem);
+         break;
+      case DD_SERIE :
+         DicomDirSerieList.push_back(elem);
+         break;
+      case DD_IMAGE :
+         DicomDirImageList.push_back(elem);
+         break;
+      default :
+         return false;
    }
    return true;
 }
index e7c3defb15d4914d2933a71c8448b871cd04269c..2e0b9c410c466842caa31b8671389f48f094ddb2 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirElement.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/20 11:40:14 $
-  Version:   $Revision: 1.20 $
+  Date:      $Date: 2005/01/20 17:15:54 $
+  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
@@ -27,7 +27,7 @@ namespace gdcm
 {
 
 //-----------------------------------------------------------------------------
-typedef struct
+GDCM_EXPORT typedef struct
 {
    /// DicomGroup number
    unsigned short int Group;
@@ -102,7 +102,7 @@ public:
       { return DicomDirImageList; };
 
    // Public method to add an element
-   bool AddNewEntry(std::string const &type, Element const &elem);
+   bool AddNewEntry(DicomDirType type, Element const &elem);
 
 private:
    /// Elements chained list, related to the MetaElements of DICOMDIR