From 3842530aeeb5ab67f9d7b0f1754108fd176ee51a Mon Sep 17 00:00:00 2001 From: jpr Date: Wed, 26 Oct 2005 15:49:56 +0000 Subject: [PATCH] Swap64 deals with double (VR=FD) Will avoid some warning (debug?) messages at run time --- src/gdcmDocument.cxx | 48 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index ee8bf9bf..3625d94b 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2005/10/26 09:09:31 $ - Version: $Revision: 1.310 $ + Date: $Date: 2005/10/26 15:49:56 $ + Version: $Revision: 1.311 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -501,6 +501,42 @@ uint32_t Document::SwapLong(uint32_t a) return a; } +/** + * \brief Swaps back the bytes of 8-byte long 'double' accordingly to + * processor order. + * @return The properly swaped 64 bits double. + */ +double Document::SwapDouble(double a) +{ + switch (SwapCode) + { + // There were no 'double' at ACR-NEMA time. + // We just have to deal with 'straight Little Endian' and + // 'straight Big Endian' + case 1234 : + break; + case 4321 : + char *beg = (char *)&a; + char *end = beg + 7; + char t; + for (unsigned int i = 0; i<7; i++) + { + t = *beg; + *beg = *end; + *end = t; + beg++, + end--; + } + break; + + default : + gdcmErrorMacro( "Unset swap code:" << SwapCode ); + a = 0.; + } + return a; +} + + // // -----------------File I/O --------------- /** @@ -719,10 +755,9 @@ void Document::LoadEntryBinArea(DataEntry *entry) } case 8: { - gdcmWarningMacro("Can't swap 64 bits data"); -/* uint64_t *data64 = (uint64_t *)data; + double *data64 = (double *)data; for(i=0;i VR: " << vr ) if ( !CheckDocEntryVR(vr) ) { - gdcmWarningMacro( "Unknown VR '" << vr << "'" ) + gdcmWarningMacro( "Unknown VR '" << vr << "' at offset :" + << positionOnEntry ); Fp->seekg(positionOnEntry, std::ios::beg); return GDCM_VRUNKNOWN; } -- 2.45.1