X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=src%2FgdcmDataEntry.cxx;h=4d7b76283a5f290ed3896db61410dfd3d6a7d8a7;hb=0a4f28d5ec16e85a53faa056246fd9d7dde3a168;hp=6c7a11b813f1900a2b16857dfbc783e9bdaa9eb4;hpb=7cb37a242568f7905f1e16d5cc8004e869f0d9f5;p=gdcm.git diff --git a/src/gdcmDataEntry.cxx b/src/gdcmDataEntry.cxx index 6c7a11b8..4d7b7628 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 15:52:13 $ + Version: $Revision: 1.9 $ 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,30 @@ double DataEntry::GetValue(const uint32_t &id) const return BinArea[id]; } +bool DataEntry::IsValueCountValid() const +{ + bool valid = false; + uint32_t vm; + const std::string &strVM = GetVM(); + uint32_t vc = GetValueCount(); + if( strVM == "1-n" ) + { + // make sure it is at least one ??? FIXME + valid = vc >= 1 || vc == 0; + } + else + { + std::istringstream os; + os.str( strVM ); + os >> vm; + // Two cases: + // vm respect the one from the dict + // vm is 0 (we need to check is this element is allowed to be empty) FIXME + valid = vc == vm || vc == 0; + } + return valid; +} + uint32_t DataEntry::GetValueCount(void) const { const VRKey &vr = GetVR(); @@ -232,6 +256,8 @@ uint32_t DataEntry::GetValueCount(void) const return GetLength()/sizeof(double); else if( Global::GetVR()->IsVROfStringRepresentable(vr) ) { + // Some element in DICOM are allowed to be empty + if( !GetLength() ) return 0; // Don't use std::string to accelerate processing uint32_t count = 1; for(uint32_t i=0;i