From abd6bfcc2b10b5f7447d1758938d7c15c31240af Mon Sep 17 00:00:00 2001 From: malaterre Date: Fri, 7 Jan 2005 19:20:37 +0000 Subject: [PATCH] ENH: update gdcmDebug after Benoit comments --- Example/TestFromScratch.cxx | 6 +- src/gdcmDebug.cxx | 86 ++++----------------------- src/gdcmDebug.h | 102 ++++++++++++++++++++++++++++---- src/gdcmDicomDir.cxx | 46 +++++++-------- src/gdcmDicomDirElement.cxx | 9 ++- src/gdcmDict.cxx | 10 ++-- src/gdcmDictEntry.cxx | 12 ++-- src/gdcmDictSet.cxx | 8 +-- src/gdcmDocEntrySet.cxx | 14 ++--- src/gdcmDocument.cxx | 111 +++++++++++++++++------------------ src/gdcmElementSet.cxx | 14 ++--- src/gdcmFile.cxx | 16 ++--- src/gdcmGlobal.cxx | 6 +- src/gdcmHeader.cxx | 66 ++++++++++----------- src/gdcmPixelReadConvert.cxx | 58 +++++++++--------- src/gdcmSQItem.cxx | 12 ++-- src/gdcmTS.cxx | 6 +- src/gdcmVR.cxx | 6 +- 18 files changed, 299 insertions(+), 289 deletions(-) diff --git a/Example/TestFromScratch.cxx b/Example/TestFromScratch.cxx index f7293996..ca89f4fd 100644 --- a/Example/TestFromScratch.cxx +++ b/Example/TestFromScratch.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestFromScratch.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 16:26:11 $ - Version: $Revision: 1.5 $ + Date: $Date: 2005/01/07 19:20:37 $ + 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 @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) } // Doesn't seems to do anything: - gdcm::Debug::SetDebugLevel(-1); + gdcm::Debug::SetDebugOn(); // Doesn't link properly: //gdcm::Debug::GetReference().SetDebug(1); diff --git a/src/gdcmDebug.cxx b/src/gdcmDebug.cxx index 5eadc164..ee721664 100644 --- a/src/gdcmDebug.cxx +++ b/src/gdcmDebug.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDebug.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 16:26:12 $ - Version: $Revision: 1.14 $ + Date: $Date: 2005/01/07 19:20:38 $ + Version: $Revision: 1.15 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -23,90 +23,26 @@ namespace gdcm { /// warning message level to be displayed -static int DebugLevel = -1; +static int DebugFlag = 0; //----------------------------------------------------------------------------- /** * \brief Accessor * @param level Set the debug level */ -void Debug::SetDebugLevel (int level) +void Debug::SetDebugFlag (int flag) { - DebugLevel = level; + DebugFlag = flag; } /** - * \brief Verbose - * @param level level - * @param msg1 first message part - * @param msg2 second message part - */ -void Debug::Verbose(int level, const char *msg1, const char *msg2) -{ - if (level > DebugLevel) - { - return ; - } - std::cerr << "gdcm::" << msg1 << ' ' << msg2 << std::endl; -} - -/** - * \brief Error - * @param test test - * @param msg1 first message part - * @param msg2 second message part - */ -void Debug::Error(bool test, const char *msg1, const char *msg2) -{ - if (!test) - { - return; - } - std::cerr << "gdcm::" << msg1 << ' ' << msg2 << std::endl; - Exit(1); -} - -/** - * \brief Error - * @param msg1 first message part - * @param msg2 second message part - * @param msg3 Third message part - */ -void Debug::Error(const char *msg1, const char *msg2, - const char *msg3) + * \brief Accessor + * @param level Get the debug level + */ +int Debug::GetDebugFlag () { - std::cerr << "gdcm::" << msg1 << ' ' << msg2 << ' ' << msg3 - << std::endl; - Exit(1); + return DebugFlag; } -/** - * \brief Assert - * @param level level - * @param test test - * @param msg1 first message part - * @param msg2 second message part - */ -void Debug::Assert(int level, bool test, const char *msg1, - const char *msg2) -{ - if (level > DebugLevel) - { - return ; - } - if (!test) - { - std::cerr << "gdcm::" << msg1 << ' ' << msg2 - << std::endl; - } -} +} // end namespace gdcm -/** - * \brief Exit - * @param a return code - */ -void Debug::Exit(int a) -{ - exit(a); // Found in #include -} -} // end namespace gdcm diff --git a/src/gdcmDebug.h b/src/gdcmDebug.h index 0ea4fd73..a173a811 100644 --- a/src/gdcmDebug.h +++ b/src/gdcmDebug.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDebug.h,v $ Language: C++ - Date: $Date: 2005/01/07 16:39:59 $ - Version: $Revision: 1.12 $ + Date: $Date: 2005/01/07 19:20:38 $ + Version: $Revision: 1.13 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -41,17 +41,97 @@ class GDCM_EXPORT Debug public: /// This is a global flag that controls whether any debug, warning /// messages are displayed. - static void SetDebugLevel (int level); - static int GetDebugLevel (); - - static void Verbose(int level, const char *msg1, const char *msg2 = "") ; - static void Error (bool test, const char *msg1, const char *msg2 = ""); - static void Error (const char *msg1, const char *msg2 = "", const char *msg3 = ""); - - static void Assert(int level, bool test, const char *msg1, const char *msg2); - static void Exit (int a); + static int GetDebugFlag (); + static void SetDebugFlag (int flag); + static void SetDebugOn () { SetDebugFlag(1); }; + static void SetDebugOff () { SetDebugFlag(0); }; }; } // end namespace gdcm +// Here we define function this is the only way to be able to pass +// stuff with indirection like: +// gdcmDebug( "my message:" << i << '\t' ); +// You cannot use function unless you use vnsprintf ... + +// __FUNCTION is not always defined by preprocessor +#ifndef __FUNCTION__ +# define __FUNCTION__ "" +#endif + +/** + * \brief Verbose + * @param level level + * @param msg1 first message part + * @param msg2 second message part + */ +#define gdcmDebugMacro(x) \ +{ \ + if( gdcm::Debug::GetDebugFlag() ) \ + { \ + std::ostringstream osmacro; \ + osmacro << "Debug: In " __FILE__ ", line " << __LINE__ \ + << ", function " << __FUNCTION__ << '\n' \ + << x << "\n\n"; \ + std::cerr << osmacro.str() << std::endl; \ + } \ +} + +/** + * \brief Verbose + * @param level level + * @param msg1 first message part + * @param msg2 second message part + */ +#define gdcmVerboseMacro(x) \ +{ \ + if( gdcm::Debug::GetDebugFlag() ) \ + { \ + std::ostringstream osmacro; \ + osmacro << "Verbose: In " __FILE__ ", line " << __LINE__ \ + << ", function " __FUNCTION__ "\n" \ + << x << "\n\n"; \ + std::cerr << osmacro.str() << std::endl; \ + } \ +} + +/** + * \brief Error + * @param test test + * @param msg1 first message part + * @param msg2 second message part + */ +#define gdcmErrorMacro(x) \ +{ \ + if( gdcm::Debug::GetDebugFlag() ) \ + { \ + std::ostringstream osmacro; \ + osmacro << "Error: In " __FILE__ ", line " << __LINE__ \ + << ", function " << __FUNCTION__ << '\n' \ + << x << "\n\n"; \ + std::cerr << osmacro.str() << std::endl; \ + exit(1); \ + } \ +} + +/** + * \brief Assert + * @param level level + * @param test test + * @param msg1 first message part + * @param msg2 second message part + */ +#define gdcmAssertMacro(x) \ +{ \ + if( x ) \ + { \ + std::ostringstream osmacro; \ + osmacro << "Assert: In " __FILE__ ", line " << __LINE__ \ + << ", function " << __FUNCTION__ \ + << "\n\n"; \ + std::cerr << osmacro.str() << std::endl; \ + assert ( x ); \ + } \ +} + #endif diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index cfeec8cc..c12a9a6f 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 16:26:12 $ - Version: $Revision: 1.93 $ + Date: $Date: 2005/01/07 19:20:38 $ + Version: $Revision: 1.94 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -90,9 +90,9 @@ DicomDir::DicomDir(std::string const &fileName, bool parseDir ): // if user passed a root directory, sure we didn't get anything if ( TagHT.begin() == TagHT.end() ) // when user passed a Directory to parse { - Debug::Verbose(0, "DicomDir::DicomDir : entry HT empty"); + gdcmVerboseMacro("DicomDir::DicomDir : entry HT empty"); - if ( fileName.size() == 1 && fileName[0] == '.' ) + if ( fileName == "." ) { // user passed '.' as Name // we get current directory name @@ -105,8 +105,8 @@ DicomDir::DicomDir(std::string const &fileName, bool parseDir ): { MetaElems = NewMeta(); - Debug::Verbose(0, "DicomDir::DicomDir : Parse directory" - " and create the DicomDir"); + gdcmVerboseMacro("DicomDir::DicomDir : Parse directory" + " and create the DicomDir"); ParseDirectory(); } else @@ -122,7 +122,7 @@ DicomDir::DicomDir(std::string const &fileName, bool parseDir ): DocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); if ( !e ) { - Debug::Verbose(0, "DicomDir::DicomDir : NO Directory record" + gdcmVerboseMacro("DicomDir::DicomDir : NO Directory record" " sequence (0x0004,0x1220)"); /// \todo FIXME : what do we do when the parsed file IS NOT a /// DICOMDIR file ? @@ -358,7 +358,7 @@ bool DicomDir::WriteDicomDir(std::string const &fileName) std::ios::out | std::ios::binary); if( !fp ) { - Debug::Verbose(2, "Failed to open(write) File: ", fileName.c_str()); + gdcmVerboseMacro("Failed to open(write) File: " << fileName.c_str()); return false; } @@ -425,9 +425,8 @@ void DicomDir::CreateDicomDirChainedList(std::string const & path) header = new Header( it->c_str() ); if( !header ) { - Debug::Verbose( 1, - "DicomDir::CreateDicomDirChainedList: " - "failure in new Header ", + gdcmVerboseMacro( "DicomDir::CreateDicomDirChainedList: " << + "failure in new Header " << it->c_str() ); continue; } @@ -436,8 +435,7 @@ void DicomDir::CreateDicomDirChainedList(std::string const & path) { // Add the file header to the chained list: list.push_back(header); - Debug::Verbose( 1, - "DicomDir::CreateDicomDirChainedList: readable ", + gdcmVerboseMacro( "DicomDir::CreateDicomDirChainedList: readable " << it->c_str() ); } else @@ -552,7 +550,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, si = new DicomDirImage(); if( !AddDicomDirImageToEnd(static_cast(si)) ) { - Debug::Verbose(0,"DicomDir::SetElement:", + gdcmVerboseMacro("DicomDir::SetElement:" "Add DicomDirImageToEnd failed"); } break; @@ -561,7 +559,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, si = new DicomDirSerie(); if( !AddDicomDirSerieToEnd(static_cast(si)) ) { - Debug::Verbose(0,"DicomDir::SetElement:", + gdcmVerboseMacro("DicomDir::SetElement:" "Add DicomDirSerieToEnd failed"); } break; @@ -570,7 +568,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, si = new DicomDirStudy(); if( !AddDicomDirStudyToEnd(static_cast(si)) ) { - Debug::Verbose(0,"DicomDir::SetElement:", + gdcmVerboseMacro("DicomDir::SetElement:" "Add DicomDirStudyToEnd failed"); } break; @@ -579,7 +577,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, si = new DicomDirPatient(); if( !AddDicomDirPatientToEnd(static_cast(si)) ) { - Debug::Verbose(0,"DicomDir::SetElement:", + gdcmVerboseMacro("DicomDir::SetElement:" "Add DicomDirPatientToEnd failed"); } break; @@ -588,7 +586,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, si = new DicomDirMeta(); if( MetaElems ) { - Debug::Verbose(0,"DicomDir::SetElement:", + gdcmVerboseMacro("DicomDir::SetElement:" "MetaElements already exist, they will be destroyed"); delete MetaElems; } @@ -639,8 +637,8 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, { if( header->GetFileName().substr(0, path.length()) != path ) { - Debug::Verbose(0, "DicomDir::SetElement : the base path" - " of file name is incorrect"); + gdcmVerboseMacro("DicomDir::SetElement : the base path" + " of file name is incorrect"); val = header->GetFileName(); } else @@ -731,8 +729,8 @@ void DicomDir::CreateDicomDir() DocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); if ( !e ) { - Debug::Verbose(0, "DicomDir::DicomDir : NO Directory record" - " sequence (0x0004,0x1220)"); + gdcmVerboseMacro("DicomDir::DicomDir : NO Directory record" + " sequence (0x0004,0x1220)"); /// \todo FIXME: what to do when the parsed file IS NOT a DICOMDIR file ? return; } @@ -740,7 +738,7 @@ void DicomDir::CreateDicomDir() SeqEntry *s = dynamic_cast(e); if ( !s ) { - Debug::Verbose(0, "DicomDir::CreateDicomDir: no SeqEntry present"); + gdcmVerboseMacro("DicomDir::CreateDicomDir: no SeqEntry present"); // useless : (0x0004,0x1220) IS a Sequence ! return; } @@ -763,7 +761,7 @@ void DicomDir::CreateDicomDir() } else { - Debug::Verbose(0, "DicomDir::CreateDicomDir: not a ValEntry."); + gdcmVerboseMacro("DicomDir::CreateDicomDir: not a ValEntry."); continue; } diff --git a/src/gdcmDicomDirElement.cxx b/src/gdcmDicomDirElement.cxx index 1baebc1c..e2791d55 100644 --- a/src/gdcmDicomDirElement.cxx +++ b/src/gdcmDicomDirElement.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirElement.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 16:26:12 $ - Version: $Revision: 1.24 $ + Date: $Date: 2005/01/07 19:20:38 $ + Version: $Revision: 1.25 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -40,9 +40,8 @@ DicomDirElement::DicomDirElement() std::ifstream from(filename.c_str()); if(!from) { - Debug::Verbose(2, - "DicomDirElement::DicomDirElement: can't open dictionary", - filename.c_str()); + gdcmVerboseMacro( "DicomDirElement::DicomDirElement: can't open dictionary" + << filename.c_str()); FillDefaultDIRDict( this ); } else diff --git a/src/gdcmDict.cxx b/src/gdcmDict.cxx index 1985e4e3..37180fd9 100644 --- a/src/gdcmDict.cxx +++ b/src/gdcmDict.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDict.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 16:26:12 $ - Version: $Revision: 1.58 $ + Date: $Date: 2005/01/07 19:20:38 $ + Version: $Revision: 1.59 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -44,7 +44,7 @@ Dict::Dict(std::string const &filename) std::ifstream from( filename.c_str() ); if( !from ) { - Debug::Verbose(2,"Dict::Dict: can't open dictionary", filename.c_str()); + gdcmVerboseMacro("Dict::Dict: can't open dictionary" << filename.c_str()); // Using default embeded one: FillDefaultDataDict( this ); } @@ -128,7 +128,7 @@ bool Dict::AddNewEntry(DictEntry const &newEntry) if(KeyHt.count(key) == 1) { - Debug::Verbose(1, "Dict::AddNewEntry already present", key.c_str()); + gdcmVerboseMacro("Dict::AddNewEntry already present" << key.c_str()); return false; } else @@ -172,7 +172,7 @@ bool Dict::RemoveEntry (TagKey const &key) } else { - Debug::Verbose(1, "Dict::RemoveEntry unfound entry", key.c_str()); + gdcmVerboseMacro("Dict::RemoveEntry unfound entry" << key.c_str()); return false; } } diff --git a/src/gdcmDictEntry.cxx b/src/gdcmDictEntry.cxx index 2da08f05..f208f3e9 100644 --- a/src/gdcmDictEntry.cxx +++ b/src/gdcmDictEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictEntry.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 16:33:07 $ - Version: $Revision: 1.35 $ + Date: $Date: 2005/01/07 19:20:38 $ + Version: $Revision: 1.36 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -78,8 +78,8 @@ void DictEntry::SetVR(TagName const &vr) } else { - Debug::Error(true, "DictEntry::SetVR", - "Overwriting VR might compromise a dictionary"); + gdcmErrorMacro("DictEntry::SetVR" + "Overwriting VR might compromise a dictionary"); } } @@ -97,8 +97,8 @@ void DictEntry::SetVM(TagName const &vm) } else { - Debug::Error(true, "DictEntry::SetVM", - "Overwriting VM might compromise a dictionary"); + gdcmErrorMacro( "DictEntry::SetVM" + "Overwriting VM might compromise a dictionary"); } } //----------------------------------------------------------------------------- diff --git a/src/gdcmDictSet.cxx b/src/gdcmDictSet.cxx index 13ed5510..149ecac0 100644 --- a/src/gdcmDictSet.cxx +++ b/src/gdcmDictSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictSet.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 16:26:12 $ - Version: $Revision: 1.47 $ + Date: $Date: 2005/01/07 19:20:38 $ + Version: $Revision: 1.48 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -220,8 +220,8 @@ std::string DictSet::BuildDictPath() { resultPath += '/'; } - Debug::Verbose(1, "DictSet::BuildDictPath:", - "Dictionary path set from environnement"); + gdcmVerboseMacro("DictSet::BuildDictPath:" + "Dictionary path set from environnement"); } else { diff --git a/src/gdcmDocEntrySet.cxx b/src/gdcmDocEntrySet.cxx index c0deb983..5e3cd38e 100644 --- a/src/gdcmDocEntrySet.cxx +++ b/src/gdcmDocEntrySet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 16:26:12 $ - Version: $Revision: 1.35 $ + Date: $Date: 2005/01/07 19:20:38 $ + Version: $Revision: 1.36 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -71,7 +71,7 @@ ValEntry *DocEntrySet::NewValEntryByNumber(uint16_t group,uint16_t elem, ValEntry *newEntry = new ValEntry(dictEntry); if (!newEntry) { - Debug::Verbose(1, "Document::NewValEntryByNumber", + gdcmVerboseMacro("Document::NewValEntryByNumber" "failed to allocate ValEntry"); return 0; } @@ -96,7 +96,7 @@ BinEntry *DocEntrySet::NewBinEntryByNumber(uint16_t group,uint16_t elem, BinEntry *newEntry = new BinEntry(dictEntry); if (!newEntry) { - Debug::Verbose(1, "Document::NewBinEntryByNumber", + gdcmVerboseMacro("Document::NewBinEntryByNumber" "failed to allocate BinEntry"); return 0; } @@ -118,7 +118,7 @@ SeqEntry* DocEntrySet::NewSeqEntryByNumber(uint16_t group,uint16_t elem) SeqEntry *newEntry = new SeqEntry( dictEntry ); if (!newEntry) { - Debug::Verbose(1, "Document::NewSeqEntryByNumber", + gdcmVerboseMacro("Document::NewSeqEntryByNumber" "failed to allocate SeqEntry"); return 0; } @@ -140,8 +140,8 @@ DictEntry *DocEntrySet::GetDictEntryByNumber(uint16_t group,uint16_t elem) Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); if (!pubDict) { - Debug::Verbose(0, "Document::GetDictEntry", - "we SHOULD have a default dictionary"); + gdcmVerboseMacro("Document::GetDictEntry" + "we SHOULD have a default dictionary"); } else { diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 313cee7a..06f7a066 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/07 16:45:51 $ - Version: $Revision: 1.164 $ + Date: $Date: 2005/01/07 19:20:38 $ + Version: $Revision: 1.165 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -106,7 +106,7 @@ Document::Document( std::string const &filename ) : ElementSet(-1) return; } - Debug::Verbose(0, "Document::Document: starting parsing of file: ", + gdcmVerboseMacro("Document::Document: starting parsing of file: " << Filename.c_str()); Fp->seekg( 0, std::ios::beg); @@ -283,14 +283,14 @@ bool Document::IsReadable() { if( Filetype == Unknown) { - Debug::Verbose(0, "Document::IsReadable: wrong filetype"); + gdcmVerboseMacro("Document::IsReadable: wrong filetype"); return false; } if( TagHT.empty() ) { - Debug::Verbose(0, "Document::IsReadable: no tags in internal" - " hash table."); + gdcmVerboseMacro("Document::IsReadable: no tags in internal" + " hash table."); return false; } @@ -424,16 +424,14 @@ std::ifstream *Document::OpenFile() if(Fp) { - Debug::Verbose( 0, - "Document::OpenFile is already opened when opening: ", + gdcmVerboseMacro( "Document::OpenFile is already opened when opening: " << Filename.c_str()); } Fp = new std::ifstream(Filename.c_str(), std::ios::in | std::ios::binary); if( ! *Fp ) { - Debug::Verbose( 0, - "Document::OpenFile cannot open file: ", + gdcmVerboseMacro( "Document::OpenFile cannot open file: " << Filename.c_str()); delete Fp; Fp = 0; @@ -473,8 +471,7 @@ std::ifstream *Document::OpenFile() } CloseFile(); - Debug::Verbose( 0, - "Document::OpenFile not DICOM/ACR (missing preamble)", + gdcmVerboseMacro( "Document::OpenFile not DICOM/ACR (missing preamble)" << Filename.c_str()); return 0; @@ -566,8 +563,8 @@ ValEntry *Document::ReplaceOrCreateByNumber(std::string const &value, { if (!RemoveEntry(currentEntry)) { - Debug::Verbose(0, "Document::ReplaceOrCreateByNumber: removal" - " of previous DocEntry failed."); + gdcmVerboseMacro("Document::ReplaceOrCreateByNumber: removal" + " of previous DocEntry failed."); return NULL; } @@ -581,8 +578,8 @@ ValEntry *Document::ReplaceOrCreateByNumber(std::string const &value, if ( !AddEntry(valEntry)) { - Debug::Verbose(0, "Document::ReplaceOrCreateByNumber: AddEntry" - " failed allthough this is a creation."); + gdcmVerboseMacro("Document::ReplaceOrCreateByNumber: AddEntry" + " failed allthough this is a creation."); delete valEntry; return NULL; @@ -629,8 +626,8 @@ BinEntry *Document::ReplaceOrCreateByNumber(uint8_t *binArea, { if (!RemoveEntry(currentEntry)) { - Debug::Verbose(0, "Document::ReplaceOrCreateByNumber: removal" - " of previous DocEntry failed."); + gdcmVerboseMacro("Document::ReplaceOrCreateByNumber: removal" + " of previous DocEntry failed."); return NULL; } @@ -644,8 +641,8 @@ BinEntry *Document::ReplaceOrCreateByNumber(uint8_t *binArea, if ( !AddEntry(binEntry)) { - Debug::Verbose(0, "Document::ReplaceOrCreateByNumber: AddEntry" - " failed allthough this is a creation."); + gdcmVerboseMacro("Document::ReplaceOrCreateByNumber: AddEntry" + " failed allthough this is a creation."); delete binEntry; return NULL; @@ -702,8 +699,8 @@ SeqEntry *Document::ReplaceOrCreateByNumber( uint16_t group, uint16_t elem) { if (!RemoveEntry(currentEntry)) { - Debug::Verbose(0, "Document::ReplaceOrCreateByNumber: removal" - " of previous DocEntry failed."); + gdcmVerboseMacro("Document::ReplaceOrCreateByNumber: removal" + " of previous DocEntry failed."); return NULL; } @@ -717,7 +714,7 @@ SeqEntry *Document::ReplaceOrCreateByNumber( uint16_t group, uint16_t elem) if ( !AddEntry(seqEntry)) { - Debug::Verbose(0, "Document::ReplaceOrCreateByNumber: AddEntry" + gdcmVerboseMacro("Document::ReplaceOrCreateByNumber: AddEntry" " failed allthough this is a creation."); delete seqEntry; @@ -841,7 +838,7 @@ bool Document::SetEntryByNumber(std::string const& content, ValEntry *entry = GetValEntryByNumber(group, element); if (!entry ) { - Debug::Verbose(0, "Document::SetEntryByNumber: no corresponding", + gdcmVerboseMacro("Document::SetEntryByNumber: no corresponding" " ValEntry (try promotion first)."); return false; } @@ -863,7 +860,7 @@ bool Document::SetEntryByNumber(uint8_t*content, int lgth, BinEntry *entry = GetBinEntryByNumber(group, element); if (!entry ) { - Debug::Verbose(0, "Document::SetEntryByNumber: no corresponding", + gdcmVerboseMacro( "Document::SetEntryByNumber: no corresponding" " ValEntry (try promotion first)."); return false; } @@ -925,7 +922,7 @@ void *Document::GetEntryBinAreaByNumber(uint16_t group, uint16_t elem) DocEntry *entry = GetDocEntryByNumber(group, elem); if (!entry) { - Debug::Verbose(1, "Document::GetDocEntryByNumber: no entry"); + gdcmVerboseMacro("Document::GetDocEntryByNumber: no entry"); return 0; } if ( BinEntry *binEntry = dynamic_cast(entry) ) @@ -977,7 +974,7 @@ void Document::LoadEntryBinArea(BinEntry *element) uint8_t *a = new uint8_t[l]; if( !a ) { - Debug::Verbose(0, "Document::LoadEntryBinArea cannot allocate a"); + gdcmVerboseMacro("Document::LoadEntryBinArea cannot allocate a"); return; } @@ -1057,7 +1054,7 @@ ValEntry *Document::GetValEntryByNumber(uint16_t group, uint16_t element) { return entry; } - Debug::Verbose(0, "Document::GetValEntryByNumber: unfound ValEntry."); + gdcmVerboseMacro("Document::GetValEntryByNumber: unfound ValEntry."); return 0; } @@ -1079,7 +1076,7 @@ BinEntry *Document::GetBinEntryByNumber(uint16_t group, uint16_t element) { return entry; } - Debug::Verbose(0, "Document::GetBinEntryByNumber: unfound BinEntry."); + gdcmVerboseMacro("Document::GetBinEntryByNumber: unfound BinEntry."); return 0; } @@ -1126,7 +1123,7 @@ uint32_t Document::SwapLong(uint32_t a) break; default : //std::cout << "swapCode= " << SwapCode << std::endl; - Debug::Error(" Document::SwapLong : unset swap code"); + gdcmErrorMacro(" Document::SwapLong : unset swap code"); a = 0; } return a; @@ -1207,7 +1204,7 @@ void Document::ParseDES(DocEntrySet *set, long offset, if ( ! Global::GetVR()->IsVROfBinaryRepresentable(vr) ) { ////// Neither ValEntry NOR BinEntry: should mean UNKOWN VR - Debug::Verbose(0, "Document::ParseDES: neither Valentry, " + gdcmVerboseMacro("Document::ParseDES: neither Valentry, " "nor BinEntry. Probably unknown VR."); } @@ -1555,8 +1552,8 @@ void Document::LoadDocEntry(DocEntry *entry) if( length % 2 ) { newValue = Util::DicomString(str, length+1); - //Debug::Verbose(0, "Warning: bad length: ", length ); - Debug::Verbose(0, "For string :", newValue.c_str()); + gdcmVerboseMacro("Warning: bad length: " << length ); + gdcmVerboseMacro("For string :" << newValue.c_str()); // Since we change the length of string update it length //entry->SetReadLength(length+1); } @@ -1570,7 +1567,7 @@ void Document::LoadDocEntry(DocEntry *entry) { if ( Fp->fail() || Fp->eof())//Fp->gcount() == 1 { - Debug::Verbose(1, "Document::LoadDocEntry", + gdcmVerboseMacro("Document::LoadDocEntry" "unread element value"); valEntry->SetValue(GDCM_UNREAD); return; @@ -1588,7 +1585,7 @@ void Document::LoadDocEntry(DocEntry *entry) } else { - Debug::Error(true, "Document::LoadDocEntry" + gdcmErrorMacro("Document::LoadDocEntry" "Should have a ValEntry, here !"); } } @@ -1956,13 +1953,13 @@ void Document::FixDocEntryFoundLength(DocEntry *entry, s << "Warning : Tag with uneven length " << foundLength << " in x(" << std::hex << gr << "," << elem <<")" << std::dec; - Debug::Verbose(0, s.str().c_str()); + gdcmVerboseMacro(s.str().c_str()); } //////// Fix for some naughty General Electric images. // Allthough not recent many such GE corrupted images are still present // on Creatis hard disks. Hence this fix shall remain when such images - // are no longer in user (we are talking a few years, here)... + // are no longer in use (we are talking a few years, here)... // Note: XMedCom probably uses such a trick since it is able to read // those pesky GE images ... if ( foundLength == 13) @@ -2044,7 +2041,7 @@ bool Document::IsDocEntryAnInteger(DocEntry *entry) << std::hex << group << " , " << element << ") -before- position x(" << filePosition << ")" << "lgt : " << length; - Debug::Verbose(0, "Document::IsDocEntryAnInteger", s.str().c_str() ); + gdcmVerboseMacro("Document::IsDocEntryAnInteger" << s.str().c_str() ); } } @@ -2089,7 +2086,7 @@ uint32_t Document::FindDocEntryLengthOBOrOW() if ( group != 0xfffe || ( ( elem != 0xe0dd ) && ( elem != 0xe000 ) ) ) { - Debug::Verbose(1, "Document::FindDocEntryLengthOBOrOW: neither an Item " + gdcmVerboseMacro("Document::FindDocEntryLengthOBOrOW: neither an Item " "tag nor a Sequence delimiter tag."); Fp->seekg(positionOnEntry, std::ios::beg); throw FormatUnexpected("Document::FindDocEntryLengthOBOrOW()", @@ -2224,7 +2221,7 @@ bool Document::CheckSwap() char *entCur = deb + 128; if( memcmp(entCur, "DICM", (size_t)4) == 0 ) { - Debug::Verbose(1, "Document::CheckSwap:", "looks like DICOM Version3"); + gdcmVerboseMacro("Document::CheckSwap:" "looks like DICOM Version3"); // Next, determine the value representation (VR). Let's skip to the // first element (0002, 0000) and check there if we find "UL" @@ -2258,26 +2255,26 @@ bool Document::CheckSwap() // instead of just checking for UL, OB and UI !? group 0000 { Filetype = ExplicitVR; - Debug::Verbose(1, "Document::CheckSwap:", + gdcmVerboseMacro( "Document::CheckSwap:" "explicit Value Representation"); } else { Filetype = ImplicitVR; - Debug::Verbose(1, "Document::CheckSwap:", + gdcmVerboseMacro("Document::CheckSwap:" "not an explicit Value Representation"); } if ( net2host ) { SwapCode = 4321; - Debug::Verbose(1, "Document::CheckSwap:", + gdcmVerboseMacro("Document::CheckSwap:" "HostByteOrder != NetworkByteOrder"); } else { SwapCode = 0; - Debug::Verbose(1, "Document::CheckSwap:", + gdcmVerboseMacro("Document::CheckSwap:" "HostByteOrder = NetworkByteOrder"); } @@ -2291,7 +2288,7 @@ bool Document::CheckSwap() // Alas, this is not a DicomV3 file and whatever happens there is no file // preamble. We can reset the file position indicator to where the data // is (i.e. the beginning of the file). - Debug::Verbose(1, "Document::CheckSwap:", "not a DICOM Version3 file"); + gdcmVerboseMacro("Document::CheckSwap:" "not a DICOM Version3 file"); Fp->seekg(0, std::ios::beg); // Our next best chance would be to be considering a 'clean' ACR/NEMA file. @@ -2366,7 +2363,7 @@ bool Document::CheckSwap() Filetype = ACR; return true; default : - Debug::Verbose(0, "Document::CheckSwap:", + gdcmVerboseMacro( "Document::CheckSwap:" "ACR/NEMA unfound swap info (Really hopeless !)"); Filetype = Unknown; return false; @@ -2388,7 +2385,7 @@ bool Document::CheckSwap() */ void Document::SwitchSwapToBigEndian() { - Debug::Verbose(1, "Document::SwitchSwapToBigEndian", + gdcmVerboseMacro("Document::SwitchSwapToBigEndian" "Switching to BigEndian mode."); if ( SwapCode == 0 ) { @@ -2530,7 +2527,7 @@ DocEntry *Document::ReadNextDocEntry() std::string msg; msg = Util::Format("Falsely explicit vr file (%04x,%04x)\n", newEntry->GetGroup(), newEntry->GetElement()); - Debug::Verbose(1, "Document::FindVR: ", msg.c_str()); + gdcmVerboseMacro("Document::FindVR: " << msg.c_str()); } newEntry->SetImplicitVR(); } @@ -2613,8 +2610,8 @@ bool Document::ReadTag(uint16_t testGroup, uint16_t testElement) s << std::hex << itemTagGroup << "," << itemTagElement << ")" << std::endl; s << " at address: " << (unsigned)currentPosition << std::endl; - Debug::Verbose(0, "Document::ReadItemTagLength: wrong Item Tag found:"); - Debug::Verbose(0, s.str().c_str()); + gdcmVerboseMacro("Document::ReadItemTagLength: wrong Item Tag found:" + << s.str().c_str()); Fp->seekg(positionOnEntry, std::ios::beg); return false; @@ -2654,7 +2651,7 @@ uint32_t Document::ReadTagLength(uint16_t testGroup, uint16_t testElement) s << "Basic Item Length is: " << itemLength << std::endl; s << " at address: " << (unsigned)currentPosition << std::endl; - Debug::Verbose(0, "Document::ReadItemTagLength: ", s.str().c_str()); + gdcmVerboseMacro("Document::ReadItemTagLength: " << s.str().c_str()); } return itemLength; } @@ -2687,7 +2684,7 @@ void Document::ReadAndSkipEncapsulatedBasicOffsetTable() std::ostringstream s; s << " Read one length: "; s << std::hex << individualLength << std::endl; - Debug::Verbose(0, + gdcmVerboseMacro(0, "Document::ReadAndSkipEncapsulatedBasicOffsetTable: ", s.str().c_str()); } @@ -2746,7 +2743,7 @@ void Document::ComputeRLEInfo() if ( nbRleSegments > 16 ) { // There should be at most 15 segments (refer to RLEFrame class) - Debug::Verbose(0, "Document::ComputeRLEInfo: too many segments."); + gdcmVerboseMacro("Document::ComputeRLEInfo: too many segments."); } uint32_t rleSegmentOffsetTable[16]; @@ -2789,8 +2786,8 @@ void Document::ComputeRLEInfo() // Delimiter Item': if ( !ReadTag(0xfffe, 0xe0dd) ) { - Debug::Verbose(0, "Document::ComputeRLEInfo: no sequence delimiter "); - Debug::Verbose(0, " item at end of RLE item sequence"); + gdcmVerboseMacro("Document::ComputeRLEInfo: no sequence delimiter " + " item at end of RLE item sequence"); } } @@ -2830,8 +2827,8 @@ void Document::ComputeJPEGFragmentInfo() // Delimiter Item': if ( !ReadTag(0xfffe, 0xe0dd) ) { - Debug::Verbose(0, "Document::ComputeRLEInfo: no sequence delimiter "); - Debug::Verbose(0, " item at end of JPEG item sequence"); + gdcmVerboseMacro("Document::ComputeRLEInfo: no sequence delimiter " + " item at end of JPEG item sequence"); } } diff --git a/src/gdcmElementSet.cxx b/src/gdcmElementSet.cxx index f30da69b..97436d14 100644 --- a/src/gdcmElementSet.cxx +++ b/src/gdcmElementSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 16:26:12 $ - Version: $Revision: 1.37 $ + Date: $Date: 2005/01/07 19:20:38 $ + Version: $Revision: 1.38 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -113,7 +113,7 @@ bool ElementSet::AddEntry(DocEntry *newEntry) if( TagHT.count(key) == 1 ) { - Debug::Verbose(1, "ElementSet::AddEntry key already present: ", + gdcmVerboseMacro("ElementSet::AddEntry key already present: " << key.c_str()); return false; } @@ -136,12 +136,12 @@ bool ElementSet::RemoveEntry( DocEntry *entryToRemove) if( TagHT.count(key) == 1 ) { TagHT.erase(key); - Debug::Verbose(0, "ElementSet::RemoveEntry: one element erased."); + gdcmVerboseMacro( "ElementSet::RemoveEntry: one element erased."); delete entryToRemove; return true; } - Debug::Verbose(0, "ElementSet::RemoveEntry: key not present"); + gdcmVerboseMacro("ElementSet::RemoveEntry: key not present"); return false ; } @@ -155,11 +155,11 @@ bool ElementSet::RemoveEntryNoDestroy(DocEntry *entryToRemove) if( TagHT.count(key) == 1 ) { TagHT.erase(key); - Debug::Verbose(0, "ElementSet::RemoveEntry: one element erased."); + gdcmVerboseMacro("ElementSet::RemoveEntry: one element erased."); return true; } - Debug::Verbose(0, "ElementSet::RemoveEntry: key not present"); + gdcmVerboseMacro("ElementSet::RemoveEntry: key not present"); return false ; } diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 52ef22ee..c412b4cd 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/01/07 16:26:12 $ - Version: $Revision: 1.184 $ + Date: $Date: 2005/01/07 19:20:38 $ + Version: $Revision: 1.185 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -255,7 +255,7 @@ size_t File::GetImageDataIntoVector (void *destination, size_t maxSize) { if ( PixelReadConverter->GetRGBSize() > maxSize ) { - Debug::Verbose(0, "File::GetImageDataIntoVector: pixel data bigger" + gdcmVerboseMacro("File::GetImageDataIntoVector: pixel data bigger" "than caller's expected MaxSize"); return 0; } @@ -268,7 +268,7 @@ size_t File::GetImageDataIntoVector (void *destination, size_t maxSize) // Either no LUT conversion necessary or LUT conversion failed if ( PixelReadConverter->GetRawSize() > maxSize ) { - Debug::Verbose(0, "File::GetImageDataIntoVector: pixel data bigger" + gdcmVerboseMacro("File::GetImageDataIntoVector: pixel data bigger" "than caller's expected MaxSize"); return 0; } @@ -373,7 +373,7 @@ bool File::WriteRawData(std::string const &fileName) std::ofstream fp1(fileName.c_str(), std::ios::out | std::ios::binary ); if (!fp1) { - Debug::Verbose(2, "Fail to open (write) file:", fileName.c_str()); + gdcmVerboseMacro("Fail to open (write) file:" << fileName.c_str()); return false; } @@ -615,7 +615,7 @@ bool File::CheckWriteIntegrity() case WMODE_RAW : if( decSize!=PixelWriteConverter->GetUserDataSize() ) { - Debug::Verbose(0, "File::CheckWriteIntegrity: Data size is incorrect (Raw)"); + gdcmVerboseMacro("File::CheckWriteIntegrity: Data size is incorrect (Raw)"); //std::cerr << "File::CheckWriteIntegrity: Data size is incorrect (Raw)\n" // << decSize << " / " << PixelWriteConverter->GetUserDataSize() << "\n"; return false; @@ -624,7 +624,7 @@ bool File::CheckWriteIntegrity() case WMODE_RGB : if( rgbSize!=PixelWriteConverter->GetUserDataSize() ) { - Debug::Verbose(0, "File::CheckWriteIntegrity: Data size is incorrect (RGB)"); + gdcmVerboseMacro( "File::CheckWriteIntegrity: Data size is incorrect (RGB)"); //std::cerr << "File::CheckWriteIntegrity: Data size is incorrect (RGB)\n" // << decSize << " / " << PixelWriteConverter->GetUserDataSize() << "\n"; return false; @@ -910,7 +910,7 @@ uint8_t *File::GetRaw() raw = PixelReadConverter->GetRaw(); if ( ! raw ) { - Debug::Verbose(0, "File::GetRaw: read/decompress of " + gdcmVerboseMacro("File::GetRaw: read/decompress of " "pixel data apparently went wrong."); return 0; } diff --git a/src/gdcmGlobal.cxx b/src/gdcmGlobal.cxx index 9fb2c8ec..79e3962c 100644 --- a/src/gdcmGlobal.cxx +++ b/src/gdcmGlobal.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmGlobal.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 16:26:12 $ - Version: $Revision: 1.8 $ + Date: $Date: 2005/01/07 19:20:38 $ + Version: $Revision: 1.9 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -67,7 +67,7 @@ Global::Global() { if (ValRes || TranSyn || Dicts || ddElem) { - Debug::Verbose(0, "Global::Global : VR or TS or Dicts already allocated"); + gdcmVerboseMacro("Global::Global : VR or TS or Dicts already allocated"); return; } Dicts = new DictSet(); diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 945f2885..1a5eec96 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/07 16:26:13 $ - Version: $Revision: 1.223 $ + Date: $Date: 2005/01/07 19:20:38 $ + Version: $Revision: 1.224 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -131,7 +131,7 @@ bool Header::Write(std::string fileName, FileType filetype) std::ios::out | std::ios::binary); if (*fp == NULL) { - Debug::Verbose(2, "Failed to open (write) File: " , fileName.c_str()); + gdcmVerboseMacro("Failed to open (write) File: " << fileName.c_str()); return false; } @@ -328,7 +328,7 @@ float Header::GetXSpacing() if ( strSpacing == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::GetXSpacing: unfound Pixel Spacing (0028,0030)"); + gdcmVerboseMacro("Header::GetXSpacing: unfound Pixel Spacing (0028,0030)"); return 1.; } @@ -355,7 +355,7 @@ float Header::GetXSpacing() if ( xspacing == 0.) { - Debug::Verbose(0, "Header::GetXSpacing: gdcmData/CT-MONO2-8-abdo.dcm problem"); + gdcmVerboseMacro("Header::GetXSpacing: gdcmData/CT-MONO2-8-abdo.dcm problem"); // seems to be a bug in the header ... nbValues = sscanf( strSpacing.c_str(), "%f\\0\\%f", &yspacing, &xspacing); assert( nbValues == 2 ); @@ -376,7 +376,7 @@ float Header::GetYSpacing() if ( strSpacing == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::GetYSpacing: unfound Pixel Spacing (0028,0030)"); + gdcmVerboseMacro("Header::GetYSpacing: unfound Pixel Spacing (0028,0030)"); return 1.; } @@ -411,7 +411,7 @@ float Header::GetZSpacing() if ( strSpacingBSlices == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::GetZSpacing: unfound StrSpacingBSlices"); + gdcmVerboseMacro("Header::GetZSpacing: unfound StrSpacingBSlices"); const std::string &strSliceThickness = GetEntryByNumber(0x0018,0x0050); if ( strSliceThickness == GDCM_UNFOUND ) { @@ -444,7 +444,7 @@ float Header::GetRescaleIntercept() if( sscanf( strRescInter.c_str(), "%f", &resInter) != 1 ) { // bug in the element 0x0028,0x1052 - Debug::Verbose(0, "Header::GetRescaleIntercept: Rescale Slope " + gdcmVerboseMacro("Header::GetRescaleIntercept: Rescale Slope " "is empty"); } } @@ -466,7 +466,7 @@ float Header::GetRescaleSlope() if( sscanf( strRescSlope.c_str(), "%f", &resSlope) != 1) { // bug in the element 0x0028,0x1053 - Debug::Verbose(0, "Header::GetRescaleSlope: Rescale Slope is empty"); + gdcmVerboseMacro("Header::GetRescaleSlope: Rescale Slope is empty"); } } @@ -572,12 +572,12 @@ float Header::GetXOrigin() if ( strImPos == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::GetXImagePosition: unfound Image " + gdcmVerboseMacro("Header::GetXImagePosition: unfound Image " "Position Patient (0020,0032)"); strImPos = GetEntryByNumber(0x0020,0x0030); // For ACR-NEMA images if ( strImPos == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::GetXImagePosition: unfound Image " + gdcmVerboseMacro("Header::GetXImagePosition: unfound Image " "Position (RET) (0020,0030)"); /// \todo How to tell the caller nothing was found ? return 0.; @@ -605,12 +605,12 @@ float Header::GetYOrigin() if ( strImPos == GDCM_UNFOUND) { - Debug::Verbose(0, "Header::GetYImagePosition: unfound Image " + gdcmVerboseMacro("Header::GetYImagePosition: unfound Image " "Position Patient (0020,0032)"); strImPos = GetEntryByNumber(0x0020,0x0030); // For ACR-NEMA images if ( strImPos == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::GetYImagePosition: unfound Image " + gdcmVerboseMacro("Header::GetYImagePosition: unfound Image " "Position (RET) (0020,0030)"); /// \todo How to tell the caller nothing was found ? return 0.; @@ -642,7 +642,7 @@ float Header::GetZOrigin() { if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3) { - Debug::Verbose(0, "Header::GetZImagePosition: wrong Image " + gdcmVerboseMacro("Header::GetZImagePosition: wrong Image " "Position Patient (0020,0032)"); return 0.; // bug in the element 0x0020,0x0032 } @@ -658,7 +658,7 @@ float Header::GetZOrigin() if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos ) != 3 ) { - Debug::Verbose(0, "Header::GetZImagePosition: wrong Image Position (RET) (0020,0030)"); + gdcmVerboseMacro("Header::GetZImagePosition: wrong Image Position (RET) (0020,0030)"); return 0.; // bug in the element 0x0020,0x0032 } else @@ -672,7 +672,7 @@ float Header::GetZOrigin() { if( sscanf( strSliceLocation.c_str(), "%f", &zImPos) != 1) { - Debug::Verbose(0, "Header::GetZImagePosition: wrong Slice Location (0020,1041)"); + gdcmVerboseMacro("Header::GetZImagePosition: wrong Slice Location (0020,1041)"); return 0.; // bug in the element 0x0020,0x1041 } else @@ -680,14 +680,14 @@ float Header::GetZOrigin() return zImPos; } } - Debug::Verbose(0, "Header::GetZImagePosition: unfound Slice Location (0020,1041)"); + gdcmVerboseMacro("Header::GetZImagePosition: unfound Slice Location (0020,1041)"); std::string strLocation = GetEntryByNumber(0x0020,0x0050); if ( strLocation != GDCM_UNFOUND ) { if( sscanf( strLocation.c_str(), "%f", &zImPos) != 1) { - Debug::Verbose(0, "Header::GetZImagePosition: wrong Location (0020,0050)"); + gdcmVerboseMacro("Header::GetZImagePosition: wrong Location (0020,0050)"); return 0.; // bug in the element 0x0020,0x0050 } else @@ -695,7 +695,7 @@ float Header::GetZOrigin() return zImPos; } } - Debug::Verbose(0, "Header::GetYImagePosition: unfound Location (0020,0050)"); + gdcmVerboseMacro("Header::GetYImagePosition: unfound Location (0020,0050)"); return 0.; // Hopeless } @@ -794,7 +794,7 @@ int Header::GetBitsStored() std::string strSize = GetEntryByNumber( 0x0028, 0x0101 ); if ( strSize == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::GetBitsStored: this is supposed to " + gdcmVerboseMacro("Header::GetBitsStored: this is supposed to " "be mandatory"); return 0; // It's supposed to be mandatory // the caller will have to check @@ -813,7 +813,7 @@ int Header::GetHighBitPosition() std::string strSize = GetEntryByNumber( 0x0028, 0x0102 ); if ( strSize == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::GetHighBitPosition: this is supposed " + gdcmVerboseMacro("Header::GetHighBitPosition: this is supposed " "to be mandatory"); return 0; } @@ -831,7 +831,7 @@ bool Header::IsSignedPixelData() std::string strSize = GetEntryByNumber( 0x0028, 0x0103 ); if ( strSize == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::IsSignedPixelData: this is supposed " + gdcmVerboseMacro("Header::IsSignedPixelData: this is supposed " "to be mandatory"); return false; } @@ -854,7 +854,7 @@ int Header::GetBitsAllocated() std::string strSize = GetEntryByNumber(0x0028,0x0100); if ( strSize == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::GetBitsStored: this is supposed to " + gdcmVerboseMacro("Header::GetBitsStored: this is supposed to " "be mandatory"); return 0; // It's supposed to be mandatory // the caller will have to check @@ -873,7 +873,7 @@ int Header::GetSamplesPerPixel() const std::string& strSize = GetEntryByNumber(0x0028,0x0002); if ( strSize == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::GetBitsStored: this is supposed to " + gdcmVerboseMacro("Header::GetBitsStored: this is supposed to " "be mandatory"); return 1; // Well, it's supposed to be mandatory ... // but sometimes it's missing : *we* assume Gray pixels @@ -896,7 +896,7 @@ bool Header::IsMonochrome() } if ( PhotometricInterp == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::IsMonochrome: absent Photometric " + gdcmVerboseMacro("Header::IsMonochrome: absent Photometric " "Interpretation"); } return false; @@ -916,7 +916,7 @@ bool Header::IsPaletteColor() } if ( PhotometricInterp == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::IsPaletteColor: absent Photometric " + gdcmVerboseMacro( "Header::IsPaletteColor: absent Photometric " "Interpretation"); } return false; @@ -936,7 +936,7 @@ bool Header::IsYBRFull() } if ( PhotometricInterp == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::IsYBRFull: absent Photometric " + gdcmVerboseMacro("Header::IsYBRFull: absent Photometric " "Interpretation"); } return false; @@ -986,7 +986,7 @@ int Header::GetPixelSize() { return 8; } - Debug::Verbose(0, "Header::GetPixelSize: Unknown pixel type"); + gdcmVerboseMacro("Header::GetPixelSize: Unknown pixel type"); return 0; } @@ -1009,7 +1009,7 @@ std::string Header::GetPixelType() std::string bitsAlloc = GetEntryByNumber(0x0028, 0x0100); // Bits Allocated if ( bitsAlloc == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::GetPixelType: unfound Bits Allocated"); + gdcmVerboseMacro("Header::GetPixelType: unfound Bits Allocated"); bitsAlloc = "16"; } @@ -1032,7 +1032,7 @@ std::string Header::GetPixelType() if (sign == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::GetPixelType: unfound Pixel Representation"); + gdcmVerboseMacro("Header::GetPixelType: unfound Pixel Representation"); bitsAlloc = "0"; } else if ( sign == "0" ) @@ -1194,7 +1194,7 @@ std::string Header::GetTransfertSyntaxName() } if ( transfertSyntax == GDCM_UNFOUND ) { - Debug::Verbose(0, "Header::GetTransfertSyntaxName:" + gdcmVerboseMacro( "Header::GetTransfertSyntaxName:" " unfound Transfert Syntax (0002,0010)"); return "Uncompressed ACR-NEMA"; } @@ -1312,7 +1312,7 @@ void Header::GetImageOrientationPatient( float iop[6] ) if( sscanf( strImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f", &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 ) { - Debug::Verbose(0, "Header::GetImageOrientationPatient: " + gdcmVerboseMacro("Header::GetImageOrientationPatient: " "wrong Image Orientation Patient (0020,0037)"); } } @@ -1323,7 +1323,7 @@ void Header::GetImageOrientationPatient( float iop[6] ) if( sscanf( strImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f", &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 ) { - Debug::Verbose(0, "Header::GetImageOrientationPatient: " + gdcmVerboseMacro("Header::GetImageOrientationPatient: " "wrong Image Orientation Patient (0020,0035)"); } } diff --git a/src/gdcmPixelReadConvert.cxx b/src/gdcmPixelReadConvert.cxx index 112adc08..2a75f588 100644 --- a/src/gdcmPixelReadConvert.cxx +++ b/src/gdcmPixelReadConvert.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelReadConvert.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 16:26:13 $ - Version: $Revision: 1.15 $ + Date: $Date: 2005/01/07 19:20:38 $ + Version: $Revision: 1.16 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -259,7 +259,7 @@ bool PixelReadConvert::ReadAndDecompressRLEFragment( uint8_t *subRaw, if ( numberOfReadBytes > fragmentSize ) { - Debug::Verbose(0, "PixelReadConvert::ReadAndDecompressRLEFragment: we " + gdcmVerboseMacro("PixelReadConvert::ReadAndDecompressRLEFragment: we " "read more bytes than the segment size."); return false; } @@ -332,7 +332,7 @@ void PixelReadConvert::ConvertSwapZone() } break; default: - Debug::Verbose( 0, "PixelReadConvert::ConvertSwapZone: SwapCode value " + gdcmVerboseMacro( "PixelReadConvert::ConvertSwapZone: SwapCode value " "(16 bits) not allowed." ); } } @@ -379,7 +379,7 @@ void PixelReadConvert::ConvertSwapZone() } break; default: - Debug::Verbose( 0, "PixelReadConvert::ConvertSwapZone: SwapCode value " + gdcmVerboseMacro( "PixelReadConvert::ConvertSwapZone: SwapCode value " "(32 bits) not allowed." ); } } @@ -460,7 +460,7 @@ bool PixelReadConvert::ReadAndDecompressJPEGFramesFromFile( std::ifstream *fp ) else { // other JPEG lossy not supported - Debug::Error("PixelReadConvert::ReadAndDecompressJPEGFile: unknown " + gdcmErrorMacro("PixelReadConvert::ReadAndDecompressJPEGFile: unknown " "jpeg lossy compression "); return false; } @@ -520,7 +520,7 @@ ReadAndDecompressJPEGSingleFrameFragmentsFromFile( std::ifstream *fp ) if ( ! gdcm_read_JPEG_memory8( buffer, totalLength, Raw, &howManyRead, &howManyWritten ) ) { - Debug::Error( + gdcmErrorMacro( "PixelConvert::ReadAndDecompressJPEGFile: failed to read jpeg8 " ); delete [] buffer; @@ -532,7 +532,7 @@ ReadAndDecompressJPEGSingleFrameFragmentsFromFile( std::ifstream *fp ) if ( ! gdcm_read_JPEG_memory12( buffer, totalLength, Raw, &howManyRead, &howManyWritten ) ) { - Debug::Error( + gdcmErrorMacro( "PixelConvert::ReadAndDecompressJPEGFile: failed to read jpeg12 " ); delete [] buffer; @@ -545,7 +545,7 @@ ReadAndDecompressJPEGSingleFrameFragmentsFromFile( std::ifstream *fp ) if ( ! gdcm_read_JPEG_memory16( buffer, totalLength, Raw, &howManyRead, &howManyWritten ) ) { - Debug::Error( + gdcmErrorMacro( "PixelConvert::ReadAndDecompressJPEGFile: failed to read jpeg16 " ); delete [] buffer; @@ -555,7 +555,7 @@ ReadAndDecompressJPEGSingleFrameFragmentsFromFile( std::ifstream *fp ) else { // other JPEG lossy not supported - Debug::Error("PixelConvert::ReadAndDecompressJPEGFile: unknown " + gdcmErrorMacro("PixelConvert::ReadAndDecompressJPEGFile: unknown " "jpeg lossy compression "); delete [] buffer; return false; @@ -622,7 +622,7 @@ ReadAndDecompressJPEGFragmentedFramesFromFile( std::ifstream *fp ) Raw+howManyWritten, &howManyRead, &howManyWritten ) ) { - Debug::Error("PixelConvert::ReadAndDecompressJPEGFile: failed to read jpeg8 "); + gdcmErrorMacro("PixelConvert::ReadAndDecompressJPEGFile: failed to read jpeg8 "); delete [] buffer; return false; } @@ -634,7 +634,7 @@ ReadAndDecompressJPEGFragmentedFramesFromFile( std::ifstream *fp ) Raw+howManyWritten, &howManyRead, &howManyWritten ) ) { - Debug::Error("PixelConvert::ReadAndDecompressJPEGFile: failed to read jpeg12 "); + gdcmErrorMacro("PixelConvert::ReadAndDecompressJPEGFile: failed to read jpeg12 "); delete [] buffer; return false; } @@ -646,7 +646,7 @@ ReadAndDecompressJPEGFragmentedFramesFromFile( std::ifstream *fp ) Raw+howManyWritten, &howManyRead, &howManyWritten ) ) { - Debug::Error("PixelConvert::ReadAndDecompressJPEGFile: failed to read jpeg16 "); + gdcmErrorMacro("PixelConvert::ReadAndDecompressJPEGFile: failed to read jpeg16 "); delete [] buffer; return false; } @@ -654,7 +654,7 @@ ReadAndDecompressJPEGFragmentedFramesFromFile( std::ifstream *fp ) else { // other JPEG lossy not supported - Debug::Error("PixelConvert::ReadAndDecompressJPEGFile: unknown " + gdcmErrorMacro("PixelConvert::ReadAndDecompressJPEGFile: unknown " "jpeg lossy compression "); delete [] buffer; return false; @@ -738,7 +738,7 @@ bool PixelReadConvert::ConvertReArrangeBits() throw ( FormatError ) } else { - Debug::Verbose(0, "PixelReadConvert::ConvertReArrangeBits: weird image"); + gdcmVerboseMacro("PixelReadConvert::ConvertReArrangeBits: weird image"); throw FormatError( "PixelReadConvert::ConvertReArrangeBits()", "weird image !?" ); } @@ -836,7 +836,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp ) //// First stage: get our hands on the Pixel Data. if ( !fp ) { - Debug::Verbose( 0, "PixelReadConvert::ReadAndDecompressPixelData: " + gdcmVerboseMacro( "PixelReadConvert::ReadAndDecompressPixelData: " "unavailable file pointer." ); return false; } @@ -844,7 +844,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp ) fp->seekg( PixelOffset, std::ios::beg ); if( fp->fail() || fp->eof()) //Fp->gcount() == 1 { - Debug::Verbose( 0, "PixelReadConvert::ReadAndDecompressPixelData: " + gdcmVerboseMacro( "PixelReadConvert::ReadAndDecompressPixelData: " "unable to find PixelOffset in file." ); return false; } @@ -865,7 +865,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp ) // variable). But RawSize is the right size of the image ! if( PixelDataLength != RawSize) { - Debug::Verbose( 0, "PixelReadConvert::ReadAndDecompressPixelData: " + gdcmVerboseMacro( "PixelReadConvert::ReadAndDecompressPixelData: " "Mismatch between PixelReadConvert and RawSize." ); } if( PixelDataLength > RawSize) @@ -879,7 +879,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp ) if ( fp->fail() || fp->eof())//Fp->gcount() == 1 { - Debug::Verbose( 0, "PixelReadConvert::ReadAndDecompressPixelData: " + gdcmVerboseMacro( "PixelReadConvert::ReadAndDecompressPixelData: " "reading of Raw pixel data failed." ); return false; } @@ -888,7 +888,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp ) { if ( ! ReadAndDecompressRLEFile( fp ) ) { - Debug::Verbose( 0, "PixelReadConvert::ReadAndDecompressPixelData: " + gdcmVerboseMacro( "PixelReadConvert::ReadAndDecompressPixelData: " "RLE decompressor failed." ); return false; } @@ -898,7 +898,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp ) // Default case concerns JPEG family if ( ! ReadAndDecompressJPEGFile( fp ) ) { - Debug::Verbose( 0, "PixelReadConvert::ReadAndDecompressPixelData: " + gdcmVerboseMacro( "PixelReadConvert::ReadAndDecompressPixelData: " "JPEG decompressor failed." ); return false; } @@ -1104,7 +1104,7 @@ void PixelReadConvert::GrabInformationsFromHeader( Header *header ) LutRedData = (uint8_t*)header->GetEntryBinAreaByNumber( 0x0028, 0x1201 ); if ( ! LutRedData ) { - Debug::Verbose(0, "PixelReadConvert::GrabInformationsFromHeader: " + gdcmVerboseMacro("PixelReadConvert::GrabInformationsFromHeader: " "unable to read red LUT data" ); } @@ -1113,7 +1113,7 @@ void PixelReadConvert::GrabInformationsFromHeader( Header *header ) LutGreenData = (uint8_t*)header->GetEntryBinAreaByNumber(0x0028, 0x1202 ); if ( ! LutGreenData) { - Debug::Verbose(0, "PixelReadConvert::GrabInformationsFromHeader: " + gdcmVerboseMacro("PixelReadConvert::GrabInformationsFromHeader: " "unable to read green LUT data" ); } @@ -1122,7 +1122,7 @@ void PixelReadConvert::GrabInformationsFromHeader( Header *header ) LutBlueData = (uint8_t*)header->GetEntryBinAreaByNumber( 0x0028, 0x1203 ); if ( ! LutBlueData ) { - Debug::Verbose(0, "PixelReadConvert::GrabInformationsFromHeader: " + gdcmVerboseMacro("PixelReadConvert::GrabInformationsFromHeader: " "unable to read blue LUT data" ); } } @@ -1176,7 +1176,7 @@ void PixelReadConvert::BuildLUTRGBA() &lengthR, &debR, &nbitsR ); if( nbRead != 3 ) { - Debug::Verbose(0, "PixelReadConvert::BuildLUTRGBA: wrong red LUT descriptor"); + gdcmVerboseMacro("PixelReadConvert::BuildLUTRGBA: wrong red LUT descriptor"); } int lengthG; // Green LUT length in Bytes @@ -1187,7 +1187,7 @@ void PixelReadConvert::BuildLUTRGBA() &lengthG, &debG, &nbitsG ); if( nbRead != 3 ) { - Debug::Verbose(0, "PixelReadConvert::BuildLUTRGBA: wrong green LUT descriptor"); + gdcmVerboseMacro("PixelReadConvert::BuildLUTRGBA: wrong green LUT descriptor"); } int lengthB; // Blue LUT length in Bytes @@ -1198,7 +1198,7 @@ void PixelReadConvert::BuildLUTRGBA() &lengthB, &debB, &nbitsB ); if( nbRead != 3 ) { - Debug::Verbose(0, "PixelReadConvert::BuildLUTRGBA: wrong blue LUT descriptor"); + gdcmVerboseMacro("PixelReadConvert::BuildLUTRGBA: wrong blue LUT descriptor"); } //////////////////////////////////////////////////////// @@ -1336,7 +1336,7 @@ void PixelReadConvert::Print( std::string indent, std::ostream &os ) } else { - Debug::Verbose(0, "PixelReadConvert::Print: set as RLE file " + gdcmVerboseMacro("PixelReadConvert::Print: set as RLE file " "but NO RLEinfo present."); } } @@ -1349,7 +1349,7 @@ void PixelReadConvert::Print( std::string indent, std::ostream &os ) } else { - Debug::Verbose(0, "PixelReadConvert::Print: set as JPEG file " + gdcmVerboseMacro("PixelReadConvert::Print: set as JPEG file " "but NO JPEGinfo present."); } } diff --git a/src/gdcmSQItem.cxx b/src/gdcmSQItem.cxx index 841832db..d5a1bd21 100644 --- a/src/gdcmSQItem.cxx +++ b/src/gdcmSQItem.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSQItem.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 16:26:13 $ - Version: $Revision: 1.46 $ + Date: $Date: 2005/01/07 19:20:39 $ + Version: $Revision: 1.47 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -235,13 +235,13 @@ bool SQItem::RemoveEntry( DocEntry* entryToRemove) if( *it == entryToRemove) { DocEntries.erase(it); - Debug::Verbose(0, "SQItem::RemoveEntry: one element erased."); + gdcmVerboseMacro( "SQItem::RemoveEntry: one element erased."); delete entryToRemove; return true; } } - Debug::Verbose(0, "SQItem::RemoveEntry: value not present "); + gdcmVerboseMacro( "SQItem::RemoveEntry: value not present "); return false ; } @@ -258,12 +258,12 @@ bool SQItem::RemoveEntryNoDestroy(DocEntry* entryToRemove) if( *it == entryToRemove) { DocEntries.erase(it); - Debug::Verbose(0, "SQItem::RemoveEntry: one element erased."); + gdcmVerboseMacro( "SQItem::RemoveEntry: one element erased."); return true; } } - Debug::Verbose(0, "SQItem::RemoveEntry: value not present "); + gdcmVerboseMacro( "SQItem::RemoveEntry: value not present "); return false ; } diff --git a/src/gdcmTS.cxx b/src/gdcmTS.cxx index 8bd86a57..d898be75 100644 --- a/src/gdcmTS.cxx +++ b/src/gdcmTS.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmTS.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 16:26:13 $ - Version: $Revision: 1.31 $ + Date: $Date: 2005/01/07 19:20:39 $ + Version: $Revision: 1.32 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -42,7 +42,7 @@ TS::TS() std::ifstream from(filename.c_str()); if( !from ) { - Debug::Verbose(2, "TS::TS: can't open dictionary", filename.c_str()); + gdcmVerboseMacro("TS::TS: can't open dictionary" << filename.c_str()); FillDefaultTSDict( TsMap ); } else diff --git a/src/gdcmVR.cxx b/src/gdcmVR.cxx index 4dd664c8..bc2a39ec 100644 --- a/src/gdcmVR.cxx +++ b/src/gdcmVR.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmVR.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 16:26:13 $ - Version: $Revision: 1.28 $ + Date: $Date: 2005/01/07 19:20:39 $ + Version: $Revision: 1.29 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -37,7 +37,7 @@ VR::VR() std::ifstream from(filename.c_str()); if(!from) { - Debug::Verbose(2, "VR::VR: can't open dictionary", filename.c_str()); + gdcmVerboseMacro("VR::VR: can't open dictionary" << filename.c_str()); FillDefaultVRDict(vr); } else -- 2.48.1