From: jpr Date: Fri, 6 Feb 2004 14:56:55 +0000 (+0000) Subject: * ENH : now gdcmDicomDir::CreateDicomDir() returns also the meta elements X-Git-Tag: Version0.5.bp~321 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=bc3e7a63638ffb3aa7460bf579ae65002ac6770c;p=gdcm.git * ENH : now gdcmDicomDir::CreateDicomDir() returns also the meta elements GDCM_META added to gdcmDicomDirType class gdcmMeta created --- diff --git a/ChangeLog b/ChangeLog index f642fb49..e30d1a3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-02-06 Jean-Pierre Roux + * ENH : now gdcmDicomDir::CreateDicomDir() returns also the meta elements + GDCM_META added to gdcmDicomDirType + class gdcmMeta created + 2004-02-05 Benoit Regrain * ENH : add methods in gdcmObject to get the hash table or the list of header entries diff --git a/Testing/TestDicomDir.cxx b/Testing/TestDicomDir.cxx index db226de8..84d41113 100644 --- a/Testing/TestDicomDir.cxx +++ b/Testing/TestDicomDir.cxx @@ -46,7 +46,94 @@ int main(int argc, char* argv[]) return(1); } +// Exemples exploitation de la structure + +// DON'T REMOVE neither the folowong code, nor the commented out lines + + + cout << std::endl << std::endl + << " = Liste des PATIENT ==========================================" + << std::endl<< std::endl; + + + itPatient = e1->GetPatients().begin(); + while ( itPatient != e1->GetPatients().end() ) { // on degouline la liste de PATIENT + std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name + itPatient ++; + } + +/* + + cout << std::endl << std::endl + << " = Liste des PATIENT/STUDY ==========================================" + << std::endl<< std::endl; + + itPatient = e1->GetPatients().begin(); + while ( itPatient != e1->GetPatients().end() ) { // on degouline la liste de PATIENT + std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name + itStudy = ((*itPatient)->GetStudies()).begin(); + while (itStudy != (*itPatient)->GetStudies().end() ) { // on degouline les STUDY de ce patient + std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Stdy Description + ++itStudy; + } + itPatient ++; + } + + */ + + cout << std::endl << std::endl + << " = Liste des PATIENT/STUDY/SERIE ==========================================" + << std::endl<< std::endl; + + itPatient = e1->GetPatients().begin(); + while ( itPatient != e1->GetPatients().end() ) { // on degouline la liste de PATIENT + std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name + itStudy = ((*itPatient)->GetStudies()).begin(); + while (itStudy != (*itPatient)->GetStudies().end() ) { // on degouline les STUDY de ce patient + std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description + itSerie = ((*itStudy)->GetSeries()).begin(); + while (itSerie != (*itStudy)->GetSeries().end() ) { // on degouline les SERIES de cette study + std::cout << "--- --- "<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e) << std::endl; // Serie Description + ++itSerie; + } + ++itStudy; + } + itPatient ++; + } + + + /* + cout << std::endl << std::endl + << " = Liste des PATIENT/STUDY/SERIE/IMAGE ===================================" + << std::endl<< std::endl; + + itPatient = e1->GetPatients().begin(); + while ( itPatient != e1->GetPatients().end() ) { // on degouline la liste de PATIENT + std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name + itStudy = ((*itPatient)->GetStudies()).begin(); + while (itStudy != (*itPatient)->GetStudies().end() ) { // on degouline les STUDY de ce patient + std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description + itSerie = ((*itStudy)->GetSeries()).begin(); + while (itSerie != (*itStudy)->GetSeries().end() ) { // on degouline les SERIES de cette study + std::cout << "--- --- "<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e) << std::endl; // Serie Description + itImage = ((*itSerie)->GetImages()).begin(); + while (itImage != (*itSerie)->GetImages().end() ) { // on degouline les SERIES de cette study + std::cout << "--- --- --- "<< (*itImage)->GetEntryByNumber(0x0004, 0x1500) << std::endl; // File name + ++itImage; + } + ++itSerie; + } + ++itStudy; + } + itPatient ++; + } + + */ + // DICOM DIR + +//What about the META informations? + cout << std::endl << std::endl << " = Contenu Complet du DICOMDIR ==========================================" << std::endl<< std::endl; diff --git a/src/Makefile.am b/src/Makefile.am index ce709d5d..fc59601e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = jpeg +&SUBDIRS = jpeg LTVERSION = 0:1:0 @@ -25,6 +25,7 @@ libgdcm_la_SOURCES= \ gdcmHeaderEntry.cxx \ gdcmHeaderHelper.cxx \ gdcmImage.cxx \ + gdcmMeta.cxx \ gdcmJpeg12.cxx \ gdcmJpeg2000.cxx \ gdcmJpeg.cxx \ @@ -37,14 +38,14 @@ libgdcm_la_SOURCES= \ gdcmStudy.cxx \ gdcmTS.cxx \ gdcmUtil.cxx \ - gdcmVR.cxx + gdcmVR.cxx libgdcmincludedir = $(includedir) -libgdcminclude_HEADERS = \ +libgdcminclude_HEADERS = \ gdcmCommon.h \ gdcmDicomDir.h \ - gdcmDicomDirElement.h \ + gdcmDicomDirElement.h \ gdcmDictEntry.h \ gdcmDict.h \ gdcmDictSet.h \ @@ -56,13 +57,14 @@ libgdcminclude_HEADERS = \ gdcmHeader.h \ gdcmHeaderHelper.h \ gdcmImage.h \ + gdcmMeta.h \ gdcmObject.h \ gdcmParser.h \ gdcmPatient.h \ gdcmSerie.h \ gdcmStudy.h \ gdcmVR.h \ - gdcmTS.h + gdcmTS.h EXTRA_DIST = \ diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index aedfc412..cb54ee51 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -58,6 +58,8 @@ gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir, */ gdcmDicomDir::~gdcmDicomDir() { + delete metaelems; + for(ListPatient::iterator cc=patients.begin();cc!=patients.end();++cc) { delete *cc; @@ -72,6 +74,9 @@ gdcmDicomDir::~gdcmDicomDir() */ void gdcmDicomDir::Print(std::ostream &os) { + (*metaelems).SetPrintLevel(printLevel); + (*metaelems).Print(os); + for(ListPatient::iterator cc=patients.begin();cc!=patients.end();++cc) { (*cc)->SetPrintLevel(printLevel); @@ -127,7 +132,7 @@ void gdcmDicomDir::ParseDirectory(void) // Protected /* * \ingroup gdcmDicomDir - * \brief + * \brief create a gdcmDicomDir from a root Directory * @param path entry point of the stree-like structure */ void gdcmDicomDir::NewDicomDir(std::string path) @@ -157,7 +162,7 @@ void gdcmDicomDir::NewDicomDir(std::string path) /* * \ingroup gdcmDicomDir - * \brief Get the dicom dir path + * \brief Get the DicomDir path * @param */ std::string gdcmDicomDir::GetPath(void) @@ -178,8 +183,7 @@ std::string gdcmDicomDir::GetPath(void) // Private /* * \ingroup gdcmDicomDir - * \brief - * @param + * \brief create a 'gdcmDicomDir' from a DICOMDIR gdcmHeader */ void gdcmDicomDir::CreateDicomDir() { @@ -193,10 +197,22 @@ void gdcmDicomDir::CreateDicomDir() gdcmDicomDirType type=gdcmDicomDir::GDCM_NONE; ListTag::iterator begin; ListTag::iterator end; + ListTag::iterator k; begin=listEntries.begin(); end=begin; - for(ListTag::iterator i=listEntries.begin();i !=listEntries.end();++i) + + for(ListTag::iterator j=listEntries.begin();j !=listEntries.end();++j) + { + if((*j)->GetValue()=="PATIENT ") { + k = j; + break; + } + AddObjectToEnd(gdcmDicomDir::GDCM_META,begin,j); + } + +// for(ListTag::iterator i=listEntries.begin();i !=listEntries.end();++i) + for(ListTag::iterator i=k;i !=listEntries.end();++i) { std::string v=(*i)->GetValue(); if(v=="PATIENT ") @@ -253,6 +269,9 @@ void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin, switch(type) { + case gdcmDicomDir::GDCM_META: + AddMetaToEnd(begin,end); + break; case gdcmDicomDir::GDCM_PATIENT: AddPatientToEnd(begin,end); break; @@ -268,6 +287,18 @@ void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin, } } + +/* + * \ingroup gdcmDicomDir + * \brief Well ... Not realy to end, there is only one occurence + * @param begin + * @param end +*/ +void gdcmDicomDir::AddMetaToEnd(ListTag::iterator begin,ListTag::iterator end) +{ + metaelems = new gdcmMeta(begin,end); +} + /* * \ingroup gdcmDicomDir * \brief @@ -382,9 +413,7 @@ void gdcmDicomDir::SetElements(std::string &path,ListHeader &list) // if new Serie Deal with 'SERIE' Elements if(serCurInstanceUID!=serPrevInstanceUID || serCurID!=serPrevID) - { SetElement(path,GDCM_SERIE,*it); - } // Always Deal with 'IMAGE' Elements SetElement(path,GDCM_IMAGE,*it); diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index 3604104e..e06fcd1a 100644 --- a/src/gdcmDicomDir.h +++ b/src/gdcmDicomDir.h @@ -6,13 +6,14 @@ #include "gdcmHeader.h" #include "gdcmCommon.h" #include "gdcmPatient.h" +#include "gdcmMeta.h" #include "gdcmDicomDirElement.h" #include #include //----------------------------------------------------------------------------- -typedef std::list ListPatient; +typedef std::list ListPatient; typedef std::vector ListHeader; //----------------------------------------------------------------------------- @@ -24,8 +25,9 @@ typedef std::vector ListHeader; class GDCM_EXPORT gdcmDicomDir: public gdcmParser { public: -// gdcmDicomDir(ListTag *l, bool exception_on_error = false); - gdcmDicomDir(const char *FileName, bool parseDir = false, +// gdcmDicomDir(ListTag *l, bool exception_on_error = false); + gdcmDicomDir(const char *FileName, + bool parseDir = false, bool exception_on_error = false); ~gdcmDicomDir(void); @@ -33,6 +35,7 @@ public: void SetPrintLevel(int level) { printLevel = level; }; virtual void Print(std::ostream &os = std::cout); + inline gdcmMeta *GetMeta() {return metaelems;}; inline ListPatient &GetPatients() {return patients;}; // Write @@ -43,6 +46,7 @@ public: typedef enum { GDCM_NONE, + GDCM_META, GDCM_PATIENT, GDCM_STUDY, GDCM_SERIE, @@ -55,17 +59,20 @@ protected: private: void CreateDicomDir(void); - void AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin,ListTag::iterator end); + void AddObjectToEnd(gdcmDicomDirType type, + ListTag::iterator begin,ListTag::iterator end); + void AddMetaToEnd (ListTag::iterator begin,ListTag::iterator end); void AddPatientToEnd(ListTag::iterator begin,ListTag::iterator end); - void AddStudyToEnd(ListTag::iterator begin,ListTag::iterator end); - void AddSerieToEnd(ListTag::iterator begin,ListTag::iterator end); - void AddImageToEnd(ListTag::iterator begin,ListTag::iterator end); + void AddStudyToEnd (ListTag::iterator begin,ListTag::iterator end); + void AddSerieToEnd (ListTag::iterator begin,ListTag::iterator end); + void AddImageToEnd (ListTag::iterator begin,ListTag::iterator end); void SetElements(std::string &path,ListHeader &list); - void SetElement(std::string &path,gdcmDicomDirType type,gdcmHeader *header); + void SetElement (std::string &path,gdcmDicomDirType type,gdcmHeader *header); static bool HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2); + gdcmMeta *metaelems; ListPatient patients; }; diff --git a/src/gdcmDicomDirElement.cxx b/src/gdcmDicomDirElement.cxx index f8aba446..25afc82d 100644 --- a/src/gdcmDicomDirElement.cxx +++ b/src/gdcmDicomDirElement.cxx @@ -26,8 +26,7 @@ * \ingroup gdcmDicomDirElement * \brief constructor */ - gdcmDicomDirElement::gdcmDicomDirElement(void) -{ + gdcmDicomDirElement::gdcmDicomDirElement(void) { std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_ELEM); std::ifstream from(filename.c_str()); dbg.Error(!from, "gdcmDicomDirElement::gdcmDicomDirElement: can't open dictionary",filename.c_str()); @@ -41,8 +40,8 @@ from.getline(buff, 1024, ' '); type = buff; - if( (type=="metaElem") || (type=="patientElem") || - (type=="studyElem") || (type=="serieElem") || + if( (type=="metaElem") || (type=="patientElem") || + (type=="studyElem") || (type=="serieElem") || (type=="imageElem") ) { from >> std::hex >> elem.group >> elem.elem; @@ -74,8 +73,7 @@ * \ingroup gdcmDicomDirElement * \brief destructor */ - gdcmDicomDirElement::~gdcmDicomDirElement() -{ + gdcmDicomDirElement::~gdcmDicomDirElement() { MetaList.clear(); PatientList.clear(); StudyList.clear(); @@ -91,8 +89,7 @@ * \todo add a 'Print Level' check * @param os The output stream to be written to. */ -void gdcmDicomDirElement::Print(std::ostream &os) -{ +void gdcmDicomDirElement::Print(std::ostream &os) { std::ostringstream s; std::list::iterator it; char greltag[10]; //group element tag diff --git a/src/gdcmDirList.cxx b/src/gdcmDirList.cxx index 836041fb..f8a2d637 100644 --- a/src/gdcmDirList.cxx +++ b/src/gdcmDirList.cxx @@ -43,7 +43,6 @@ gdcmDirList::gdcmDirList(std::string dirName,bool recursive) /* * \ingroup gdcmDirList * \brief Destructor - * @param */ gdcmDirList::~gdcmDirList(void) { diff --git a/src/gdcmDirList.h b/src/gdcmDirList.h index 2dae2fcb..e9cf3c55 100644 --- a/src/gdcmDirList.h +++ b/src/gdcmDirList.h @@ -1,4 +1,4 @@ -// gdcmDir.h +// gdcmDirList.h //----------------------------------------------------------------------------- #ifndef GDCMDIRLIST_H #define GDCMDIRLIST_H diff --git a/src/gdcmMeta.cxx b/src/gdcmMeta.cxx new file mode 100644 index 00000000..52bb3ad6 --- /dev/null +++ b/src/gdcmMeta.cxx @@ -0,0 +1,50 @@ +// gdcmMeta.cxx +//----------------------------------------------------------------------------- +#include "gdcmMeta.h" + +//----------------------------------------------------------------------------- +// Constructor / Destructor +/** + * \ingroup gdcmMeta + * \brief + * @param begin iterator of begin for the object + * @param end iterator of end for the object + */ +gdcmMeta::gdcmMeta(ListTag::iterator begin,ListTag::iterator end): + gdcmObject(begin,end) +{ +} + +/** + * \ingroup gdcmMeta + * \brief Canonical destructor. + */ +gdcmMeta::~gdcmMeta() +{ +} + +//----------------------------------------------------------------------------- +// Print +/** + * \ingroup gdcmMeta + * \brief Prints the Object + * @return + */ +void gdcmMeta::Print(std::ostream &os) +{ + os<<"META : "; + os<