From: regrain Date: Tue, 10 Feb 2004 10:47:54 +0000 (+0000) Subject: * FIX : bug fix in the gdcmDirList for the recursivity in directories X-Git-Tag: Version0.5.bp~316 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e785350bf905bcac85e241f9cf9f07d03eae345d;p=gdcm.git * FIX : bug fix in the gdcmDirList for the recursivity in directories * FIX : in gdcmDicomDir when the directory is empty -- BeNours --- diff --git a/ChangeLog b/ChangeLog index 8637425f..6d73c866 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,13 @@ +2004-02-10 Benoit Regrain + * FIX : bug fix in the gdcmDirList for the recursivity in directories + * FIX : in gdcmDicomDir when the directory is empty + 2004-02-06 Jean-Pierre Roux * ENH : - now gdcmDicomDir::CreateDicomDir() returns also the meta elements - GDCM_META added to gdcmDicomDirType - class gdcmMeta created - * ENH : - A brief summary is now displayed at the beginning of 'testDicomDir' - to help disaster magnitude estimation + * ENH : - A brief summary is now displayed at the beginning of + 'testDicomDir' to help disaster magnitude estimation * REM : Now useless Test/explDICOMDIR.cxx 2004-02-05 Benoit Regrain diff --git a/gdcmPython/gdcm.i b/gdcmPython/gdcm.i index 36f117ab..129a6f42 100644 --- a/gdcmPython/gdcm.i +++ b/gdcmPython/gdcm.i @@ -13,6 +13,7 @@ #include "gdcmObject.h" #include "gdcmDicomDir.h" #include "gdcmDicomDirElement.h" +#include "gdcmMeta.h" #include "gdcmPatient.h" #include "gdcmStudy.h" #include "gdcmSerie.h" @@ -204,6 +205,7 @@ extern gdcmGlobal gdcmGlob; %include "gdcmObject.h" %include "gdcmDicomDir.h" %include "gdcmDicomDirElement.h" +%include "gdcmMeta.h" %include "gdcmPatient.h" %include "gdcmStudy.h" %include "gdcmSerie.h" diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index edda84f7..23f33438 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -27,6 +27,8 @@ gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir, bool exception_on_error): gdcmParser(FileName,exception_on_error,true) { + metaElems=NULL; + if( GetListEntry().begin()==GetListEntry().end() ) { dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry list empty"); @@ -41,26 +43,14 @@ gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir, CreateDicomDir(); } -/* - * \ingroup gdcmDicomDir - * \brief - * @param exception_on_error - */ -/*gdcmDicomDir::gdcmDicomDir(ListTag *l, - bool exception_on_error): - gdcmParser(exception_on_error ) -{ - listEntries=*l; - CreateDicomDir(); -}*/ - /* * \ingroup gdcmDicomDir * \brief Canonical destructor */ gdcmDicomDir::~gdcmDicomDir() { - delete metaelems; + if(metaElems) + delete metaElems; for(ListPatient::iterator cc=patients.begin();cc!=patients.end();++cc) { @@ -76,8 +66,11 @@ gdcmDicomDir::~gdcmDicomDir() */ void gdcmDicomDir::Print(std::ostream &os) { - (*metaelems).SetPrintLevel(printLevel); - (*metaelems).Print(os); + if(metaElems) + { + metaElems->SetPrintLevel(printLevel); + metaElems->Print(os); + } for(ListPatient::iterator cc=patients.begin();cc!=patients.end();++cc) { @@ -149,6 +142,7 @@ void gdcmDicomDir::NewDicomDir(std::string path) for(gdcmDirList::iterator it=fileList.begin(); it!=fileList.end(); ++it) { + std::cout<<*it<c_str()); if(header->IsReadable()) list.push_back(header); @@ -196,24 +190,13 @@ void gdcmDicomDir::CreateDicomDir() // + we create the object for the precedent tag // + loop to 1 - - gdcmDicomDirType type=gdcmDicomDir::GDCM_NONE; + gdcmDicomDirType type=gdcmDicomDir::GDCM_META; ListTag::iterator begin; ListTag::iterator end; - ListTag::iterator k; begin=listEntries.begin(); end=begin; - - for(ListTag::iterator j=begin;j !=listEntries.end();++j) - { - if((*j)->GetValue()=="PATIENT ") { - k = j; - break; - } - } - AddObjectToEnd(gdcmDicomDir::GDCM_META,begin,k); - - for(ListTag::iterator i=k;i !=listEntries.end();++i) + for(ListTag::iterator i=end;i !=listEntries.end();++i) { std::string v=(*i)->GetValue(); if(v=="PATIENT ") @@ -253,8 +236,11 @@ void gdcmDicomDir::CreateDicomDir() } } - end=GetListEntry().end(); - AddObjectToEnd(type,begin,end); + if(begin!=end) + { + end=GetListEntry().end(); + AddObjectToEnd(type,begin,end); + } } /* * \ingroup gdcmDicomDir @@ -288,7 +274,6 @@ void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin, } } - /* * \ingroup gdcmDicomDir * \brief Well ... Not realy to end, there is only one occurence @@ -297,7 +282,9 @@ void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin, */ void gdcmDicomDir::AddMetaToEnd(ListTag::iterator begin,ListTag::iterator end) { - metaelems = new gdcmMeta(begin,end); + if(metaElems) + delete metaElems; + metaElems = new gdcmMeta(begin,end); } /* diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index e06fcd1a..e54995e3 100644 --- a/src/gdcmDicomDir.h +++ b/src/gdcmDicomDir.h @@ -35,7 +35,7 @@ public: void SetPrintLevel(int level) { printLevel = level; }; virtual void Print(std::ostream &os = std::cout); - inline gdcmMeta *GetMeta() {return metaelems;}; + inline gdcmMeta *GetMeta() {return metaElems;}; inline ListPatient &GetPatients() {return patients;}; // Write @@ -72,7 +72,7 @@ private: static bool HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2); - gdcmMeta *metaelems; + gdcmMeta *metaElems; ListPatient patients; }; diff --git a/src/gdcmDirList.cxx b/src/gdcmDirList.cxx index f8a2d637..42b3120a 100644 --- a/src/gdcmDirList.cxx +++ b/src/gdcmDirList.cxx @@ -101,10 +101,11 @@ void gdcmDirList::Explore(std::string dirName,bool recursive) while( (hFile!=INVALID_HANDLE_VALUE) && (found) ) { fileName=fileData.cFileName; + std::cout<d_type==DT_DIR) { if( (fileName!=".") && (fileName!="..") && (recursive) ) - Explore(dirName+fileName); + Explore(dirName+fileName,recursive); } else {