]> Creatis software - gdcm.git/blobdiff - src/gdcmElementSet.cxx
Fix trouble with BCC
[gdcm.git] / src / gdcmElementSet.cxx
index 4804928cb7ac8173dbbd62a9c069fcccafc5fda3..e7855bdd16c051d90cd46b2f296d6eceeb5a88f0 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/02/16 20:06:14 $
+  Version:   $Revision: 1.73 $
                                                                                 
   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
 
@@ -223,7 +268,7 @@ void ElementSet::Print(std::ostream &os, std::string const & )
       entry->SetPrintLevel(PrintLevel);
       entry->Print(os);   
 
-      if ( dynamic_cast<SeqEntry *>(entry) )
+      if ( dynamic_cast<SeqEntry*>(entry) )
       {
          // Avoid the newline for a sequence:
          continue;