From 8629d8b19caf99c82edfc9985fe5ea1ba862b9fd Mon Sep 17 00:00:00 2001 From: jpr Date: Thu, 5 Feb 2009 09:50:09 +0000 Subject: [PATCH] add bool DataEntry::IsNumerical(); bool DataEntry::GetNumerical(std::vector &valueVector); to avoid people to re-progrm them each time --- src/gdcmDataEntry.cxx | 97 ++++++++++++++++++++++++++++++++++++++++++- src/gdcmDataEntry.h | 9 ++-- 2 files changed, 101 insertions(+), 5 deletions(-) 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 &valueVector); + /// \brief Sets SelfArea void SetSelfArea(bool area) { SelfArea = area; } /// \brief True if Entry owns its BinArea -- 2.45.0