X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDataEntry.cxx;h=fc36ec5666dcf64eeb30580d350c382d17e81519;hb=8629d8b19caf99c82edfc9985fe5ea1ba862b9fd;hp=833be232f3c7efc3d1f29f4f3fad5c568ca0987c;hpb=fc4f7706c78baf3f60474c06d871b82db221f37b;p=gdcm.git diff --git a/src/gdcmDataEntry.cxx b/src/gdcmDataEntry.cxx index 833be232..fc36ec56 100644 --- a/src/gdcmDataEntry.cxx +++ b/src/gdcmDataEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDataEntry.cxx,v $ Language: C++ - Date: $Date: 2008/04/10 12:15:35 $ - Version: $Revision: 1.54 $ + Date: $Date: 2009/02/05 09:50:09 $ + Version: $Revision: 1.55 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -130,6 +130,99 @@ void DataEntry::CopyBinArea( uint8_t *area, uint32_t length ) } } +/** + * \brief Checks wether the current DataEntry contains number(s) + */ + +bool DataEntry::IsNumerical() +{ + const VRKey &vr = GetVR(); + + return + vr == "DS" || + vr == "FL" || + vr == "FD" || + vr == "IS" || + vr == "SH" || + vr == "SL" || + vr == "SS" || + vr == "UI" || + vr == "UL" || + vr == "US" ; +} + +/** + * \brief Gets a std::vector of 'double' holding the value(s) of any 'numerical' DataEntry + * @param valueVector std::vector double of value(s) + * \return false if VR not "a 'numerical" one + */ + bool DataEntry::GetNumerical(std::vector &valueVector) + { + valueVector.clear(); + + if (!IsNumerical()) // never trust a user ! + return false; + + const VRKey &vr = GetVR(); + int loop; + if (vr == "IS" || vr == "DS") + { + /// \todo rewrite the whole method, in order *not to use* std::string ! + std::vector tokens; + + Util::Tokenize ( GetString().c_str(), tokens, "\\" ); + + int nbValues= tokens.size(); + if (nbValues == 0) + return false; + + if (vr == "DS") + for (loop=0; loop