]> Creatis software - gdcm.git/commitdiff
COMP: Fix comp, and use IsValueCountValid in an assert just for kick
authormalaterre <malaterre>
Fri, 21 Oct 2005 14:15:41 +0000 (14:15 +0000)
committermalaterre <malaterre>
Fri, 21 Oct 2005 14:15:41 +0000 (14:15 +0000)
src/gdcmDataEntry.cxx
src/gdcmFile.cxx

index 7f08f14b086c7c96968d57c892d6eb4d2a89cfa0..cf6a3689d36bf28cdaa8aaf350a2a0d22b2fb0a5 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDataEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/21 14:09:41 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2005/10/21 14:15:41 $
+  Version:   $Revision: 1.6 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -222,7 +222,7 @@ double DataEntry::GetValue(const uint32_t &id) const
 bool DataEntry::IsValueCountValid() const
 {
   uint32_t vm;
-  ostringstream os;
+  std::istringstream os;
   os.str( GetVM() );
   os >> vm;
   return vm == GetValueCount();
index def9a2ba8bd8d53bbc5f7e4c4f92232d073eea79..4beeccff13d5c6d037dbea83ce32f2d4c55f3a5f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/21 14:09:41 $
-  Version:   $Revision: 1.286 $
+  Date:      $Date: 2005/10/21 14:15:42 $
+  Version:   $Revision: 1.287 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -467,6 +467,7 @@ float File::GetXSpacing()
    if( entry )
    {
       nbValue = entry->GetValueCount();
+      // Can't use IsValueCountValid because of the complex heuristic.
       if( nbValue >= 3 )
          xspacing = (float)entry->GetValue(2);
       if( nbValue >= 2 )
@@ -737,7 +738,10 @@ float File::GetXOrigin()
    }
 
    if( entry->GetValueCount() == 3 )
+   {
+      gdcmAssertMacro( entry->IsValueCountValid() );
       return (float)entry->GetValue(0);
+   }
    return 0.0f;
 
 /*   std::string strImPos = GetEntryString(0x0020,0x0032);
@@ -781,7 +785,10 @@ float File::GetYOrigin()
    }
 
    if( entry->GetValueCount() == 3 )
+   {
+      gdcmAssertMacro( entry->IsValueCountValid() );
       return (float)entry->GetValue(1);
+   }
    return 0.0f;
 /*   float xImPos, yImPos, zImPos;
    std::string strImPos = GetEntryString(0x0020,0x0032);
@@ -819,7 +826,10 @@ float File::GetZOrigin()
    if( entry )
    {
       if( entry->GetValueCount() == 3 )
+      {
+         gdcmAssertMacro( entry->IsValueCountValid() );
          return (float)entry->GetValue(0);
+      }
       gdcmWarningMacro( "Wrong Image Position Patient (0020,0032)");
       return 0.0f;
    }
@@ -843,7 +853,10 @@ float File::GetZOrigin()
    if( entry )
    {
       if( entry->GetValueCount() == 3 )
+      {
+         gdcmAssertMacro( entry->IsValueCountValid() );
          return (float)entry->GetValue(0);
+      }
       gdcmWarningMacro( "Wrong Image Position (RET) (0020,0030)");
       return 0.0f;
    }
@@ -867,7 +880,10 @@ float File::GetZOrigin()
    if( entry )
    {
       if( entry->GetValueCount() == 1 )
+      {
+         gdcmAssertMacro( entry->IsValueCountValid() );
          return (float)entry->GetValue(0);
+      }
       gdcmWarningMacro( "Wrong Slice Location (0020,1041)");
       return 0.0f;
    }
@@ -890,7 +906,10 @@ float File::GetZOrigin()
    if( entry )
    {
       if( entry->GetValueCount() == 1 )
+      {
+         gdcmAssertMacro( entry->IsValueCountValid() );
          return (float)entry->GetValue(0);
+      }
       gdcmWarningMacro( "Wrong Location (0020,0050)");
       return 0.0f;
    }