]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOTreeAttributeDescriptor.cpp
Clean-Up with Juan Sebastien
[creaImageIO.git] / src2 / creaImageIOTreeAttributeDescriptor.cpp
index 5a3e5b47f6559dd09c95709b3a611c89ce320a40..c6a694f8cff678e267d621f9da6a8d7585e4c902 100644 (file)
@@ -60,18 +60,16 @@ namespace creaImageIO
       //GDCM_NAME_SPACE::TagKey tag(group,element);
       char ctag[12];
       sprintf(ctag,"D%04x_%04x",group,element);
-      std::string tag(ctag);
+      mKey = ctag;
 
-      GimmickDebugMessage(3,"AttributeDescriptor : '"<<tag
+      GimmickDebugMessage(3,"AttributeDescriptor : '"<<mKey
                          <<"' ["<<flags<<"]"<<std::endl);
 
-      mKey = "D" + tag;
-
       // Retrieve the name from gdcm dict
       GDCM_NAME_SPACE::DictEntry* entry =
        GDCM_NAME_SPACE::Global::GetDicts()
        ->GetDefaultPubDict()->GetEntry(mGroup,mElement);
-
+         
       if (entry)
        {
          mName = entry->GetName();
@@ -80,7 +78,7 @@ namespace creaImageIO
        }
       else
        {
-         GimmickMessage(1,"!! WARNING : tag '"<<tag
+         GimmickMessage(1,"!! WARNING : tag '"<<mKey
                         <<"' is not in DICOM dictionnary ! "
                         <<"Considering it as a user attribute"
                         << std::endl);
@@ -103,11 +101,97 @@ namespace creaImageIO
           (key[0] == 'D') &&
           (key[5] == '_') )
        {
-         sscanf(key.c_str(),"D%04x_%04x",&group,&elem);
+         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);
+       }
+      else 
+       { 
+         GimmickMessage(5,"GetDicomGroupElementFromKey '"<<key<<"' : "
+                        <<" not a DICOM key format"<<std::endl);
        }
       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