From d72e3cb0326093093f99863964f8f4df382c83e1 Mon Sep 17 00:00:00 2001 From: malaterre Date: Tue, 11 Jan 2005 23:06:35 +0000 Subject: [PATCH] ENH: Since HandleOutOfGroup0002 need access to the transfer syntax move the method GetTransferSyntaxName from Header to Document --- src/gdcmDocument.cxx | 64 +++++++++++++++++++++++++++++++++----------- src/gdcmDocument.h | 9 ++++--- src/gdcmHeader.cxx | 37 ++----------------------- src/gdcmHeader.h | 7 ++--- 4 files changed, 58 insertions(+), 59 deletions(-) diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 24777f51..ae50bc8a 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/01/11 22:46:22 $ - Version: $Revision: 1.179 $ + Date: $Date: 2005/01/11 23:06:35 $ + Version: $Revision: 1.180 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -2361,6 +2361,40 @@ void Document::HandleBrokenEndian(uint16_t &group, uint16_t &elem) } } +/** + * \brief Accesses the info from 0002,0010 : Transfer Syntax and TS + * else 1. + * @return The full Transfer Syntax Name (as opposed to Transfer Syntax UID) + */ +std::string Document::GetTransferSyntaxName() +{ + // use the TS (TS : Transfer Syntax) + std::string transferSyntax = GetEntry(0x0002,0x0010); + + if ( transferSyntax == GDCM_NOTLOADED ) + { + gdcmVerboseMacro( "Transfer Syntax not loaded. " << std::endl + << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" ); + return "Uncompressed ACR-NEMA"; + } + if ( transferSyntax == GDCM_UNFOUND ) + { + gdcmVerboseMacro( "Unfound Transfer Syntax (0002,0010)"); + return "Uncompressed ACR-NEMA"; + } + + while ( ! isdigit((unsigned char)transferSyntax[transferSyntax.length()-1]) ) + { + transferSyntax.erase(transferSyntax.length()-1, 1); + } + // we do it only when we need it + TS* ts = Global::GetTS(); + std::string tsName = ts->GetValue( transferSyntax ); + + // Global::GetTS() is a global static you shall never try to delete it! + return tsName; +} + /** * \brief Group 0002 is always coded Little Endian * whatever Transfer Syntax is @@ -2372,25 +2406,23 @@ void Document::HandleOutOfGroup0002(uint16_t group) if ( !Group0002Parsed && group != 0x0002) { Group0002Parsed = true; - // we just came out of group 0002 - // if Transfer syntax is Big Endian we have to change CheckSwap + // we just came out of group 0002 + // if Transfer syntax is Big Endian we have to change CheckSwap - TagKey key = DictEntry::TranslateToKey(0x0002, 0x0010); - if ( !TagHT.count(key)) + std::string ts = GetTransferSyntaxName(); + if ( !Global::GetTS()->IsTransferSyntax(ts) ) { - gdcmVerboseMacro("True DICOM File, with NO Tansfer Syntax ?!?"); + gdcmVerboseMacro("True DICOM File, with NO Tansfer Syntax: " << ts ); return; } - // FIXME Strangely, this works with - //'Implicit VR Transfer Syntax (GE Private) - - if ( ((ValEntry *)TagHT.find(key)->second)->GetValue() - == "Explicit VR - Big Endian" ) - { - gdcmVerboseMacro("Tansfer Syntax = Explicit VR - Big Endian"); - SwitchByteSwapCode(); - } + // FIXME Strangely, this works with + //'Implicit VR Transfer Syntax (GE Private) + if ( Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRBigEndian ) + { + gdcmVerboseMacro("Tansfer Syntax = Explicit VR - Big Endian"); + SwitchByteSwapCode(); + } } } diff --git a/src/gdcmDocument.h b/src/gdcmDocument.h index 3b33d635..8d4425fa 100644 --- a/src/gdcmDocument.h +++ b/src/gdcmDocument.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.h,v $ Language: C++ - Date: $Date: 2005/01/11 22:46:22 $ - Version: $Revision: 1.82 $ + Date: $Date: 2005/01/11 23:06:35 $ + Version: $Revision: 1.83 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -121,7 +121,10 @@ public: void LoadDocEntrySafe(DocEntry *entry); TagDocEntryHT *BuildFlatHashTable(); - + + /// Return the Transfer Syntax as a string + std::string GetTransferSyntaxName(); + protected: // Methods // Constructor and destructor are protected to forbid end user diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index bc79a675..b5b3b07a 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmHeader.cxx,v $ Language: C++ - Date: $Date: 2005/01/11 20:49:44 $ - Version: $Revision: 1.230 $ + Date: $Date: 2005/01/11 23:06:35 $ + Version: $Revision: 1.231 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1193,39 +1193,6 @@ int Header::GetLUTNbits() return lutNbits; } -/** - * \brief Accesses the info from 0002,0010 : Transfer Syntax and TS - * else 1. - * @return The full Transfer Syntax Name (as opposed to Transfer Syntax UID) - */ -std::string Header::GetTransferSyntaxName() -{ - // use the TS (TS : Transfer Syntax) - std::string transferSyntax = GetEntry(0x0002,0x0010); - - if ( transferSyntax == GDCM_NOTLOADED ) - { - gdcmVerboseMacro( "Transfer Syntax not loaded. " << std::endl - << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" ); - return "Uncompressed ACR-NEMA"; - } - if ( transferSyntax == GDCM_UNFOUND ) - { - gdcmVerboseMacro( "Unfound Transfer Syntax (0002,0010)"); - return "Uncompressed ACR-NEMA"; - } - - while ( ! isdigit((unsigned char)transferSyntax[transferSyntax.length()-1]) ) - { - transferSyntax.erase(transferSyntax.length()-1, 1); - } - // we do it only when we need it - TS* ts = Global::GetTS(); - std::string tsName = ts->GetValue( transferSyntax ); - - //delete ts; /// \todo Seg Fault when deleted ?! - return tsName; -} //----------------------------------------------------------------------------- // Protected diff --git a/src/gdcmHeader.h b/src/gdcmHeader.h index 5d8037ba..87a10f13 100644 --- a/src/gdcmHeader.h +++ b/src/gdcmHeader.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmHeader.h,v $ Language: C++ - Date: $Date: 2005/01/11 15:15:38 $ - Version: $Revision: 1.99 $ + Date: $Date: 2005/01/11 23:06:35 $ + Version: $Revision: 1.100 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -159,9 +159,6 @@ public: bool HasLUT(); int GetLUTNbits(); - /// Return the Transfer Syntax as a string - std::string GetTransferSyntaxName(); - /// Accessor to \ref Header::GrPixel uint16_t GetGrPixel() { return GrPixel; } -- 2.45.1