X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDataEntry.cxx;h=78f186c59b3f9f45ac7c13143ba78e09a5917367;hb=76ac46b16fd92d0fb444f786d4946424d9029315;hp=ca55ae56e4811ac118fb79dbac28ba39c2ff59a2;hpb=2fc611bb9b521a14111cfe86ece302361815dd48;p=gdcm.git diff --git a/src/gdcmDataEntry.cxx b/src/gdcmDataEntry.cxx index ca55ae56..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: 2007/09/28 14:16:09 $ - Version: $Revision: 1.50 $ + 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 @@ -30,6 +30,8 @@ #include // for atof #include // for isdigit #endif +#include // memcpy +#include // atof // Could be defined like MAX_SIZE_LOAD_ELEMENT_VALUE #define GDCM_MAX_LENGTH_TO_CONVERT_TO_HEXA 8 @@ -71,7 +73,7 @@ DataEntry::DataEntry(DocEntry *e) { Flag = FLAG_NONE; BinArea = 0; - + SelfArea = true; Copy(e); @@ -83,7 +85,6 @@ DataEntry::DataEntry(DocEntry *e) DataEntry::~DataEntry () { DeleteBinArea(); - } //----------------------------------------------------------------------------- @@ -128,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