From: malaterre Date: Fri, 21 Oct 2005 14:09:41 +0000 (+0000) Subject: ENH: Adding IsValueCountValid. Should save a lot of time for dev, since we you really... X-Git-Tag: OpenJPEG.Version1.2~258 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=4331b970c740503e6827e72a172101a86d630907;p=gdcm.git ENH: Adding IsValueCountValid. Should save a lot of time for dev, since we you really want to do is compare against the VM to find out if the operation is valid or not. --- diff --git a/src/gdcmDataEntry.cxx b/src/gdcmDataEntry.cxx index 6c7a11b8..7f08f14b 100644 --- a/src/gdcmDataEntry.cxx +++ b/src/gdcmDataEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDataEntry.cxx,v $ Language: C++ - Date: $Date: 2005/10/20 07:23:50 $ - Version: $Revision: 1.4 $ + Date: $Date: 2005/10/21 14:09:41 $ + Version: $Revision: 1.5 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -219,6 +219,15 @@ double DataEntry::GetValue(const uint32_t &id) const return BinArea[id]; } +bool DataEntry::IsValueCountValid() const +{ + uint32_t vm; + ostringstream os; + os.str( GetVM() ); + os >> vm; + return vm == GetValueCount(); +} + uint32_t DataEntry::GetValueCount(void) const { const VRKey &vr = GetVR(); @@ -241,8 +250,8 @@ uint32_t DataEntry::GetValueCount(void) const } return count; } - else - return GetLength(); + + return GetLength(); } void DataEntry::SetString(std::string const &value) diff --git a/src/gdcmDataEntry.h b/src/gdcmDataEntry.h index 2469bc46..7bd59830 100644 --- a/src/gdcmDataEntry.h +++ b/src/gdcmDataEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDataEntry.h,v $ Language: C++ - Date: $Date: 2005/10/19 08:06:45 $ - Version: $Revision: 1.2 $ + Date: $Date: 2005/10/21 14:09:41 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -63,6 +63,7 @@ public: void SetValue(const uint32_t &id,const double &val); double GetValue(const uint32_t &id) const; uint32_t GetValueCount(void) const; + bool IsValueCountValid() const; void SetString(std::string const &value); std::string const &GetString() const; diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 428c866e..def9a2ba 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2005/10/21 12:12:18 $ - Version: $Revision: 1.285 $ + Date: $Date: 2005/10/21 14:09:41 $ + Version: $Revision: 1.286 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -889,7 +889,6 @@ float File::GetZOrigin() entry = GetDataEntry(0x0020,0x0050); if( entry ) { - gdcmWarningMacro( "Unfound Location (0020,0050)"); if( entry->GetValueCount() == 1 ) return (float)entry->GetValue(0); gdcmWarningMacro( "Wrong Location (0020,0050)");