From 93748f382dadb5c9240c4156ce7bbe9dcc8da44f Mon Sep 17 00:00:00 2001 From: regrain Date: Thu, 20 Jan 2005 17:15:53 +0000 Subject: [PATCH] * 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. -- BeNours --- ChangeLog | 7 +++- src/gdcmCommon.h | 13 ++++++- src/gdcmDefaultDicts.cxx.in | 77 ++++++++++++++++++++++--------------- src/gdcmDicomDirElement.cxx | 72 +++++++++++++++++++--------------- src/gdcmDicomDirElement.h | 8 ++-- 5 files changed, 109 insertions(+), 68 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6956bf1d..3bf409f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ +2005-01-20 Benoit Regrain + * 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 * 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) diff --git a/src/gdcmCommon.h b/src/gdcmCommon.h index c5cbc8dc..2d9f5f9e 100644 --- a/src/gdcmCommon.h +++ b/src/gdcmCommon.h @@ -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 diff --git a/src/gdcmDefaultDicts.cxx.in b/src/gdcmDefaultDicts.cxx.in index 6c3c53d5..58649c6e 100644 --- a/src/gdcmDefaultDicts.cxx.in +++ b/src/gdcmDefaultDicts.cxx.in @@ -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 diff --git a/src/gdcmDicomDirElement.cxx b/src/gdcmDicomDirElement.cxx index 0fe6edb7..47e0750e 100644 --- a/src/gdcmDicomDirElement.cxx +++ b/src/gdcmDicomDirElement.cxx @@ -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 : " + <> 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; } diff --git a/src/gdcmDicomDirElement.h b/src/gdcmDicomDirElement.h index e7c3defb..2e0b9c41 100644 --- a/src/gdcmDicomDirElement.h +++ b/src/gdcmDicomDirElement.h @@ -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 -- 2.48.1