From: jpr Date: Tue, 6 Sep 2005 15:28:49 +0000 (+0000) Subject: Add the GetEntryForcedAsciiValue method to deal with Private Implicit VR Tags, X-Git-Tag: Version1.2.bp~124 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=583bf29bb8a93d0cba3ba7dfea643e322c4293b5;p=gdcm.git Add the GetEntryForcedAsciiValue method to deal with Private Implicit VR Tags, stored as BinEntries when they aren't --- diff --git a/src/gdcmCommon.h b/src/gdcmCommon.h index b9e08b72..03c4ad3d 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/09/05 08:28:02 $ - Version: $Revision: 1.90 $ + Date: $Date: 2005/09/06 15:28:49 $ + Version: $Revision: 1.91 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -120,7 +120,8 @@ GDCM_EXPORT extern const std::string GDCM_UNFOUND; GDCM_EXPORT extern const std::string GDCM_BINLOADED; GDCM_EXPORT extern const std::string GDCM_NOTLOADED; GDCM_EXPORT extern const std::string GDCM_UNREAD; - +GDCM_EXPORT extern const std::string GDCM_NOTASCII; +; /// \brief TagKey is made to hold the standard Dicom Tag /// (Group number, Element number) /// Instead of using the two '16 bits integers' as the Hask Table key, we diff --git a/src/gdcmDocEntrySet.cxx b/src/gdcmDocEntrySet.cxx index 666b72a1..a054d86e 100644 --- a/src/gdcmDocEntrySet.cxx +++ b/src/gdcmDocEntrySet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.cxx,v $ Language: C++ - Date: $Date: 2005/08/24 12:09:13 $ - Version: $Revision: 1.58 $ + Date: $Date: 2005/09/06 15:28:49 $ + Version: $Revision: 1.59 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -25,6 +25,7 @@ #include "gdcmSeqEntry.h" #include "gdcmValEntry.h" #include "gdcmBinEntry.h" +#include "gdcmUtil.h" namespace gdcm { @@ -41,7 +42,7 @@ DocEntrySet::DocEntrySet() * @param group Group number of the searched tag. * @param elem Element number of the searched tag. * @return Corresponding element value when it exists, - * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. + * and the string GDCM_UNFOUND otherwise. */ std::string DocEntrySet::GetEntryValue(uint16_t group, uint16_t elem) { @@ -65,6 +66,34 @@ void *DocEntrySet::GetEntryBinArea(uint16_t group, uint16_t elem) return 0; } +/** + * \brief Return the value of the BinEntry if it's "std::string representable" + * @param group Group number of the searched tag. + * @param elem Element number of the searched tag. + * @return Corresponding element value when it's "std::string representable" + * and the string GDCM_NOTASCII otherwise. + */ +std::string DocEntrySet::GetEntryForcedAsciiValue(uint16_t group, uint16_t elem) +{ + DocEntry *d = GetDocEntry(group,elem); + if ( !d ) + return GDCM_UNFOUND; + + if (ValEntry *v = dynamic_cast(d)) + return v->GetValue(); + + if (BinEntry *b = dynamic_cast(d)) + { + uint8_t *a = b->GetBinArea(); + if (!b) + return GDCM_NOTLOADED; + // TODO : unify those two methods. + if (Util::IsCleanArea(a, b->GetLength()) ) + return Util::CreateCleanString(a, b->GetLength()); + } + return GDCM_NOTASCII; +} + /** * \brief Searches within Header Entries (Dicom Elements) parsed with * the public and private dictionaries diff --git a/src/gdcmDocEntrySet.h b/src/gdcmDocEntrySet.h index 33106012..81425d0e 100644 --- a/src/gdcmDocEntrySet.h +++ b/src/gdcmDocEntrySet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.h,v $ Language: C++ - Date: $Date: 2005/09/02 07:10:03 $ - Version: $Revision: 1.55 $ + Date: $Date: 2005/09/06 15:28:49 $ + Version: $Revision: 1.56 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -81,10 +81,11 @@ public: virtual DocEntry *GetNextEntry()=0; virtual std::string GetEntryValue(uint16_t group, uint16_t elem); - virtual void *GetEntryBinArea(uint16_t group, uint16_t elem); + virtual void *GetEntryBinArea(uint16_t group, uint16_t elem); + virtual int GetEntryLength(uint16_t group, uint16_t elem); virtual std::string GetEntryVR(uint16_t group, uint16_t elem); - + virtual std::string GetEntryForcedAsciiValue(uint16_t group, uint16_t elem); /// \brief Gets any type of DocEntry, identified by its (group,elem) virtual DocEntry *GetDocEntry(uint16_t group, uint16_t elem) = 0; /// \brief Gets a ValEntry, identified by its (group, elem) diff --git a/src/gdcmUtil.cxx b/src/gdcmUtil.cxx index 224c9d5d..c836cb4c 100644 --- a/src/gdcmUtil.cxx +++ b/src/gdcmUtil.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmUtil.cxx,v $ Language: C++ - Date: $Date: 2005/08/31 16:24:19 $ - Version: $Revision: 1.162 $ + Date: $Date: 2005/09/06 15:28:49 $ + Version: $Revision: 1.163 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -189,7 +189,7 @@ bool Util::IsCleanString(std::string const &s) std::cout<< std::endl << s << std::endl; for(unsigned int i=0; i