From: jpr Date: Tue, 31 Jan 2006 11:39:47 +0000 (+0000) Subject: Add the method int ElementSet::IsVRCoherent( uint16_t group ) X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=75726b8bc3eec583090893444bca78aa3352718e;p=gdcm.git Add the method int ElementSet::IsVRCoherent( uint16_t group ) To check whether *all* the DataEntries of the group have all the same type for VR (ImplicitVR or ExplicitVR) @param group group number to be checked @return 1:ImplicitVR 2:ExplicitVR -1:NotCoherent --- diff --git a/src/gdcmElementSet.cxx b/src/gdcmElementSet.cxx index 4804928c..f073783c 100644 --- a/src/gdcmElementSet.cxx +++ b/src/gdcmElementSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.cxx,v $ Language: C++ - Date: $Date: 2005/11/29 12:48:47 $ - Version: $Revision: 1.71 $ + Date: $Date: 2006/01/31 11:39:47 $ + Version: $Revision: 1.72 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -193,6 +193,51 @@ void ElementSet::Copy(DocEntrySet *set) } } +/** + * \brief Checks whether *all* the DataEntries of the group have all + * the same type for VR (ImplicitVR or ExplicitVR) + * @param group group number to be checked + * @return 1:ImplicitVR 2:ExplicitVR -1:NotCoherent + */ +int ElementSet::IsVRCoherent( uint16_t group ) +{ + uint16_t currentGroup; + int codeVR = -1; + int currentCodeVR; + for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc) + { + currentGroup = cc->second->GetGroup(); + + if ( currentGroup < group ) + continue; + if ( currentGroup > group ) + break; + // currentGroup == group + if (codeVR == -1) + { + if (cc->second->IsImplicitVR() ) + codeVR = 1; + else + codeVR = 2; + continue; + } + else + { + if (cc->second->IsImplicitVR() ) + currentCodeVR = 1; //Implicit + else + currentCodeVR = 2; // Explicit + + if ( currentCodeVR == codeVR ) + continue; + else + return -1; // -1 : not coherent + } + } + return codeVR; +} + + //----------------------------------------------------------------------------- // Protected diff --git a/src/gdcmElementSet.h b/src/gdcmElementSet.h index ab4b3a7b..ccf78090 100644 --- a/src/gdcmElementSet.h +++ b/src/gdcmElementSet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.h,v $ Language: C++ - Date: $Date: 2005/11/29 12:48:47 $ - Version: $Revision: 1.53 $ + Date: $Date: 2006/01/31 11:39:47 $ + Version: $Revision: 1.54 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -56,6 +56,8 @@ public: DocEntry *GetDocEntry(uint16_t group, uint16_t elem); /// Tells us if the ElementSet contains no entry bool IsEmpty() { return TagHT.empty(); } + + int IsVRCoherent(uint16_t group); virtual void Copy(DocEntrySet *set);