X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDataEntry.cxx;h=78f186c59b3f9f45ac7c13143ba78e09a5917367;hb=76ac46b16fd92d0fb444f786d4946424d9029315;hp=833be232f3c7efc3d1f29f4f3fad5c568ca0987c;hpb=5b6a7b2ed61205e0b2a80a7fa4878976a78edf15;p=gdcm.git diff --git a/src/gdcmDataEntry.cxx b/src/gdcmDataEntry.cxx index 833be232..78f186c5 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: 2011/03/29 07:36:00 $ + Version: $Revision: 1.57 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -73,7 +73,7 @@ DataEntry::DataEntry(DocEntry *e) { Flag = FLAG_NONE; BinArea = 0; - + SelfArea = true; Copy(e); @@ -85,7 +85,6 @@ DataEntry::DataEntry(DocEntry *e) DataEntry::~DataEntry () { DeleteBinArea(); - } //----------------------------------------------------------------------------- @@ -130,6 +129,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