]> Creatis software - gdcm.git/commitdiff
Add the method int ElementSet::IsVRCoherent( uint16_t group )
authorjpr <jpr>
Tue, 31 Jan 2006 11:39:47 +0000 (11:39 +0000)
committerjpr <jpr>
Tue, 31 Jan 2006 11:39:47 +0000 (11:39 +0000)
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

src/gdcmElementSet.cxx
src/gdcmElementSet.h

index 4804928cb7ac8173dbbd62a9c069fcccafc5fda3..f073783c9b2528741be56b17b8a3e9b87d5273f9 100644 (file)
@@ -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
 
index ab4b3a7bc8135394877a5179bc0394ed13c80ae3..ccf780904fe0d780196c355eca8e892567c06f10 100644 (file)
@@ -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);