From 42741e5f9bddec6ff604bffe74977848db3edf0a Mon Sep 17 00:00:00 2001 From: malaterre Date: Fri, 21 Oct 2005 14:15:41 +0000 Subject: [PATCH] COMP: Fix comp, and use IsValueCountValid in an assert just for kick --- src/gdcmDataEntry.cxx | 6 +++--- src/gdcmFile.cxx | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/gdcmDataEntry.cxx b/src/gdcmDataEntry.cxx index 7f08f14b..cf6a3689 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/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(); diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index def9a2ba..4beeccff 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -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; } -- 2.48.1