]> Creatis software - gdcm.git/commitdiff
Add the GetEntryForcedAsciiValue method to deal with Private Implicit VR Tags,
authorjpr <jpr>
Tue, 6 Sep 2005 15:28:49 +0000 (15:28 +0000)
committerjpr <jpr>
Tue, 6 Sep 2005 15:28:49 +0000 (15:28 +0000)
 stored as BinEntries when they aren't

src/gdcmCommon.h
src/gdcmDocEntrySet.cxx
src/gdcmDocEntrySet.h
src/gdcmUtil.cxx

index b9e08b72f125a4dc058595307581c39e4684402d..03c4ad3dc96d6691534a8573e30277f5c26ae92e 100644 (file)
@@ -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
index 666b72a100c506ae9fc422eb4a208d88980e14be..a054d86e7f990360c22b91aa1d123403f9bdb4fc 100644 (file)
@@ -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<ValEntry *>(d))
+      return v->GetValue();
+
+   if (BinEntry *b = dynamic_cast<BinEntry *>(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 
index 33106012bd679481ac2619eb246b13b639cc5883..81425d0e9f5db6b199088340ba12bf9fb2230800 100644 (file)
@@ -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)
index 224c9d5d84df101fb044e01bb41a54569d4bbf02..c836cb4c75dacf14991d265e93231a5badb59b39 100644 (file)
@@ -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<s.size(); i++)
    {
-      std::cout<< std::endl << i << " : " << (unsigned char)s[i] << std::endl;
+      //std::cout<< std::endl << i << " : " << (unsigned char)s[i] << std::endl;
       if (!isprint((unsigned char)s[i]) )
       {
          return false;
@@ -268,7 +268,6 @@ std::string Util::CreateCleanString(uint8_t *s, int l)
       }
    }
 
-
    return str;
 }
 /**