From 8c378fae336dbfe722ae986708969386f0eed6db Mon Sep 17 00:00:00 2001 From: jpr Date: Mon, 19 Jul 2004 15:16:18 +0000 Subject: [PATCH] Now Examples/PrintFile displays properly Transfert Syntax Name, whatever the padding is made of... --- src/gdcmDocument.cxx | 17 +++++++---------- src/gdcmHeader.cxx | 9 +++++++-- src/gdcmTS.cxx | 5 ++--- src/gdcmValEntry.cxx | 22 ++++++++++++++++------ 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index e91b158c..2ad09079 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2004/07/19 05:59:12 $ - Version: $Revision: 1.54 $ + Date: $Date: 2004/07/19 15:16:18 $ + Version: $Revision: 1.55 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -301,7 +301,7 @@ bool gdcmDocument::IsReadable() * @param SyntaxToCheck The transfert syntax we need to check against. * @return True when SyntaxToCheck corresponds to the Transfer Syntax of * the current document. False either when the document contains - * no Transfer Syntax, or when the Tranfer Syntaxes don't match. + * no Transfer Syntax, or when the Tranfer Syntaxes doesn't match. */ bool gdcmDocument::IsGivenTransferSyntax(std::string const & syntaxToCheck) { @@ -312,7 +312,7 @@ bool gdcmDocument::IsGivenTransferSyntax(std::string const & syntaxToCheck) } // The entry might be present but not loaded (parsing and loading - // happen at differente stages): try loading and proceed with check... + // happen at different stages): try loading and proceed with check... LoadDocEntrySafe(entry); if (gdcmValEntry* valEntry = dynamic_cast< gdcmValEntry* >(entry) ) { @@ -326,10 +326,7 @@ bool gdcmDocument::IsGivenTransferSyntax(std::string const & syntaxToCheck) transfer.erase(transfer.length()-1, 1); } if ( transfer == syntaxToCheck ) - //if( transfer.find( syntaxToCheck ) ) //should be faster { - int k = - abort() return true; } } @@ -880,10 +877,10 @@ bool gdcmDocument::SetEntryByNumber(std::string content, " ValEntry (try promotion first)."); return false; } - // Non even content must be padded with a space (020H). + // Non even content must be padded with a space (020H)... if( content.length() % 2 ) { - content += '\0'; + content += '\0'; // ... therefore we padd with (000H) .!?! } valEntry->SetValue(content); @@ -926,7 +923,7 @@ bool gdcmDocument::SetEntryByNumber(void *content, return false; } -/* Hope Binaray field length is *never* wrong +/* Hope Binary field length is *never* wrong if(lgth%2) // Non even length are padded with a space (020H). { lgth++; diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 79962747..1cffe3ac 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmHeader.cxx,v $ Language: C++ - Date: $Date: 2004/07/17 22:45:40 $ - Version: $Revision: 1.177 $ + Date: $Date: 2004/07/19 15:16:18 $ + Version: $Revision: 1.178 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1213,6 +1213,7 @@ std::string gdcmHeader::GetTransfertSyntaxName() { // use the gdcmTS (TS : Transfert Syntax) std::string transfertSyntax = GetEntryByNumber(0x0002,0x0010); + if ( transfertSyntax == GDCM_UNFOUND ) { dbg.Verbose(0, "gdcmHeader::GetTransfertSyntaxName:" @@ -1220,6 +1221,10 @@ std::string gdcmHeader::GetTransfertSyntaxName() return "Uncompressed ACR-NEMA"; } + while ( ! isdigit(transfertSyntax[transfertSyntax.length()-1]) ) + { + transfertSyntax.erase(transfertSyntax.length()-1, 1); + } // we do it only when we need it gdcmTS* ts = gdcmGlobal::GetTS(); std::string tsName = ts->GetValue( transfertSyntax ); diff --git a/src/gdcmTS.cxx b/src/gdcmTS.cxx index a1c83a8b..0f41bb5c 100644 --- a/src/gdcmTS.cxx +++ b/src/gdcmTS.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmTS.cxx,v $ Language: C++ - Date: $Date: 2004/07/19 11:51:26 $ - Version: $Revision: 1.22 $ + Date: $Date: 2004/07/19 15:16:19 $ + Version: $Revision: 1.23 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -35,7 +35,6 @@ gdcmTS::gdcmTS(void) std::ifstream from(filename.c_str()); dbg.Error(!from, "gdcmTS::gdcmTS: can't open dictionary",filename.c_str()); - //char buff[1024]; //not used std::string key; std::string name; diff --git a/src/gdcmValEntry.cxx b/src/gdcmValEntry.cxx index d10cacae..f8732073 100644 --- a/src/gdcmValEntry.cxx +++ b/src/gdcmValEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmValEntry.cxx,v $ Language: C++ - Date: $Date: 2004/07/02 13:55:28 $ - Version: $Revision: 1.16 $ + Date: $Date: 2004/07/19 15:16:19 $ + Version: $Revision: 1.17 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -99,18 +99,28 @@ void gdcmValEntry::Print(std::ostream & os) s << " [gdcm::too long for print (" << GetLength() << ") ]"; } - // Display the UID value (instead of displaying only the rough code) + // Display the UID value (instead of displaying only the rough code) + // First 'clean' trailing character (space or zero) if (g == 0x0002) { // Any more to be displayed ? - if ( (e == 0x0010) || (e == 0x0002) ) + if ( (e == 0x0010) || (e == 0x0002) ) { + if ( ! isdigit(v[v.length()-1]) ) + v.erase(v.length()-1, 1); s << " ==>\t[" << ts->GetValue(v) << "]"; + } } else { if (g == 0x0008) { - if ( (e == 0x0016) || (e == 0x1150) ) + if ( (e == 0x0016) || (e == 0x1150) ) { + if ( ! isdigit(v[v.length()-1]) ) + v.erase(v.length()-1, 1); s << " ==>\t[" << ts->GetValue(v) << "]"; + } } else { if (g == 0x0004) { - if ( (e == 0x1510) || (e == 0x1512) ) + if ( (e == 0x1510) || (e == 0x1512) ) { + if ( ! isdigit(v[v.length()-1]) ) + v.erase(v.length()-1, 1); s << " ==>\t[" << ts->GetValue(v) << "]"; + } } } } -- 2.48.1