]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOTreeAttributeDescriptor.cpp
correct sscan_f problems.
[creaImageIO.git] / src2 / creaImageIOTreeAttributeDescriptor.cpp
index 13616ce47fe574973d642066e3eb508a44e4129a..86fb30a8e8a8afee9da74efe4b414fbfde026672 100644 (file)
@@ -69,7 +69,7 @@ namespace creaImageIO
       GDCM_NAME_SPACE::DictEntry* entry =
        GDCM_NAME_SPACE::Global::GetDicts()
        ->GetDefaultPubDict()->GetEntry(mGroup,mElement);
-
+         
       if (entry)
        {
          mName = entry->GetName();
@@ -100,12 +100,17 @@ 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);
-         GimmickMessage(5,"GetDicomGroupElementFromKey '"<<g<<"' : "
-                        <<group<<"|"<<elem<<std::endl);
+         std::string e = key.substr(6,4);
+         std::stringstream val;
+         val <<  std::dec << g.c_str() ;
+         val >> std::hex >> group;
+         val.clear();
+         val << std::dec << e.c_str();
+         val >> std::hex >> elem;
+         //sscanf_s(key.c_str(),"D%04x_%04x ",&group,&elem);  
+         GimmickDebugMessage(3,"GetDicomGroupElementFromKey '"<<key<<"' : "                     <<group<<"|"<<elem<<std::endl);
        }
       else 
        { 
@@ -114,7 +119,84 @@ 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
+         {
+                 
+               
+                 // Retrieve the name from gdcm dict
+               GDCM_NAME_SPACE::DictEntry* entry =
+               GDCM_NAME_SPACE::Global::GetDicts()
+               ->GetDefaultPubDict()->GetEntry(GetGroup(),GetElement());
+
+               if (entry==0) 
+               {
+                       typ = 2;
+                       return;
+               }
+               std::string type = entry->GetVR().str();
+               GimmickDebugMessage(3,"VR Value is "<<type<<"!"<<std::endl);
+               if(type=="AS" ||
+               type=="DA" ||
+               type=="FL" ||
+               type=="FD" ||
+               type=="IS" ||
+               type=="SL" ||
+               type=="SS" ||
+               type=="UI" ||
+               type=="US" ||
+               type=="SH")
+               {
+                       // Numerical 
+                       typ = 1;
+               }
+               else
+               {
+                       // String
+                       typ = 2;
+               }
+               
+         }
+         //=====================================================================
 
   } // EO namespace tree