]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOTreeAttributeDescriptor.cpp
*** empty log message ***
[creaImageIO.git] / src2 / creaImageIOTreeAttributeDescriptor.cpp
index 54c56b87e2308f22d5d77c15ea97bcd170a72a0c..231b045e003bc715a518e594e10ab3cbb226be2f 100644 (file)
@@ -100,12 +100,9 @@ namespace creaImageIO
       if ( (key.size()==10) &&
           (key[0] == 'D') &&
           (key[5] == '_') )
-       {
-         std::string g = key.substr(1,4);
-         sscanf(key.c_str(),"D %04x _ %04x ",&group,&elem);  
-         sscanf(g.c_str(),"%04x",&group);
-         GimmickDebugMessage(3,"GetDicomGroupElementFromKey '"<<g<<"' : "
-                        <<group<<"|"<<elem<<std::endl);
+         {
+        sscanf_s(key.c_str(),"D%04hx_%04hx ",&group,&elem);  
+         GimmickDebugMessage(3,"GetDicomGroupElementFromKey '"<<key<<"' : "                     <<group<<"|"<<elem<<std::endl);
        }
       else 
        { 
@@ -115,6 +112,43 @@ namespace creaImageIO
       return;
     }
 
+       //=====================================================================
+       /// test if the type is a date
+       bool AttributeDescriptor::isDateEntry() const
+       {
+                
+               bool btest = false;
+               // Retrieve the name from gdcm dict
+               GDCM_NAME_SPACE::DictEntry* entry =     GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->GetEntry(GetGroup(),GetElement());
+               if(     entry != 0)
+               {
+                       if( entry->GetVR().str() == "DA" )
+                       {
+                               btest = true;
+                       }
+               }
+               return btest;
+       }
+
+       //=====================================================================
+       /// test if the type is a time
+       bool AttributeDescriptor::isTimeEntry() const
+       {
+                
+               bool btest = false;
+               // Retrieve the name from gdcm dict
+               GDCM_NAME_SPACE::DictEntry* entry =     GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->GetEntry(GetGroup(),GetElement());
+               if(     entry != 0)
+               {
+                       if( entry->GetVR().str() == "TM" )
+                       {
+                               btest = true;
+                       }
+               }
+               return btest;
+       }
+
+
     //=====================================================================
        /// Decodes the type of the attribute
      void AttributeDescriptor::DecodeType(unsigned int& typ) const
@@ -146,15 +180,11 @@ namespace creaImageIO
                {
                        // Numerical 
                        typ = 1;
-//                     type="1";
-//                      sscanf(type.c_str(),"%u",&typ);
                }
                else
                {
                        // String
                        typ = 2;
-                       //                      type="2";
-//                      sscanf(type.c_str(),"%u",&typ);
                }
                
          }