From: regrain Date: Thu, 20 Jan 2005 11:09:21 +0000 (+0000) Subject: * src/gdcmDicomDir*.[h|cxx] : rename methods to be logik in their name. X-Git-Tag: Version1.0.bp~240 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=060ddb1e7fabdfc43c258dfd575df80e4023fd32;p=gdcm.git * src/gdcmDicomDir*.[h|cxx] : rename methods to be logik in their name. Remove all access to the hash-tables or lists in the objects. -- BeNours --- diff --git a/ChangeLog b/ChangeLog index a0ac327e..a05be787 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-01-20 Benoit Regrain + * src/gdcmDicomDir*.[h|cxx] : rename methods to be logik in their name. + Remove all access to the hash-tables or lists in the objects. + 2005-01-20 Benoit Regrain * src/gdcmDebug.h : remove the Debug test in the gdcmErrorMacro * src/gdcmDocument.[h|cxx] : rename the Initialise method to Initialize, to diff --git a/Example/PrintDicomDir.cxx b/Example/PrintDicomDir.cxx index 5e589900..cc8c9a7f 100644 --- a/Example/PrintDicomDir.cxx +++ b/Example/PrintDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: PrintDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/01/18 07:55:16 $ - Version: $Revision: 1.16 $ + Date: $Date: 2005/01/20 11:09:21 $ + 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 @@ -71,7 +71,7 @@ int main(int argc, char* argv[]) } // Test if the DicomDir contains any Patient - pa = e1->GetFirstEntry(); + pa = e1->GetFirstPatient(); if ( pa == 0) { std::cout<<" DicomDir '"<GetFirstEntry(); + pa = e1->GetFirstPatient(); while (pa) { std::cout << pa->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name - pa = e1->GetNextEntry(); + pa = e1->GetNextPatient(); } break; @@ -104,16 +104,17 @@ int main(int argc, char* argv[]) << " = PATIENT/STUDY List =======================================" << std::endl<< std::endl; - pa = e1->GetFirstEntry(); + pa = e1->GetFirstPatient(); while ( pa ) // on degouline les PATIENT de ce DICOMDIR { std::cout << pa->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name - st = pa->GetFirstEntry(); + + st = pa->GetFirstStudy(); while ( st ) { // on degouline les STUDY de ce patient std::cout << "--- "<< st->GetEntry(0x0008, 0x1030) << std::endl; // Study Description - st = pa->GetNextEntry(); + st = pa->GetNextStudy(); } - pa = e1->GetNextEntry(); + pa = e1->GetNextPatient(); } break; @@ -122,29 +123,31 @@ int main(int argc, char* argv[]) << " = PATIENT/STUDY/SERIE List ==================================" << std::endl<< std::endl; - pa = e1->GetFirstEntry(); + pa = e1->GetFirstPatient(); while ( pa ) // on degouline les PATIENT de ce DICOMDIR { // Patient's Name, Patient ID std::cout << "Pat.Name:[" << pa->GetEntry(0x0010, 0x0010) <<"]"; // Patient's Name std::cout << " Pat.ID:["; std::cout << pa->GetEntry(0x0010, 0x0020) << "]" << std::endl; // Patient ID - st = pa->GetFirstEntry(); + + st = pa->GetFirstStudy(); while ( st ) { // on degouline les STUDY de ce patient std::cout << "--- Stud.descr:[" << st->GetEntry(0x0008, 0x1030) << "]";// Study Description std::cout << " Stud.ID:[" << st->GetEntry(0x0020, 0x0010); // Study ID std::cout << "]" << std::endl; - se = st->GetFirstEntry(); + + se = st->GetFirstSerie(); while ( se ) { // on degouline les SERIES de cette study std::cout << "--- --- Ser.Descr:["<< se->GetEntry(0x0008, 0x103e)<< "]"; // Series Description std::cout << " Ser.nb:[" << se->GetEntry(0x0020, 0x0011); // Series number std::cout << "] Mod.:[" << se->GetEntry(0x0008, 0x0060) << "]"; // Modality std::cout << std::endl; - se = st->GetNextEntry(); + se = st->GetNextSerie(); } - st = pa->GetNextEntry(); + st = pa->GetNextStudy(); } - pa = e1->GetNextEntry(); + pa = e1->GetNextPatient(); } break; @@ -153,28 +156,31 @@ int main(int argc, char* argv[]) << " = PATIENT/STUDY/SERIE/IMAGE List ============================" << std::endl<< std::endl; - pa = e1->GetFirstEntry(); + pa = e1->GetFirstPatient(); while ( pa ) { // les PATIENT de ce DICOMDIR std::cout << pa->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name - st = pa->GetFirstEntry(); + + st = pa->GetFirstStudy(); while ( st ) { // on degouline les STUDY de ce patient std::cout << "--- "<< st->GetEntry(0x0008, 0x1030) << std::endl; // Study Description std::cout << " Stud.ID:[" << st->GetEntry(0x0020, 0x0010); // Study ID - se = st->GetFirstEntry(); + + se = st->GetFirstSerie(); while ( se ) { // on degouline les SERIES de cette study std::cout << "--- --- "<< se->GetEntry(0x0008, 0x103e) << std::endl; // Serie Description std::cout << " Ser.nb:[" << se->GetEntry(0x0020, 0x0011); // Series number std::cout << "] Mod.:[" << se->GetEntry(0x0008, 0x0060) << "]"; // Modality - im = se->GetFirstEntry(); + + im = se->GetFirstImage(); while ( im ) { // on degouline les Images de cette serie std::cout << "--- --- --- "<< im->GetEntry(0x0004, 0x1500) << std::endl; // File name - im = se->GetNextEntry(); + im = se->GetNextImage(); } - se = st->GetNextEntry(); + se = st->GetNextSerie(); } - st = pa->GetNextEntry(); + st = pa->GetNextStudy(); } - pa = e1->GetNextEntry(); + pa = e1->GetNextPatient(); } break; diff --git a/Testing/TestDicomDir.cxx b/Testing/TestDicomDir.cxx index 7a70e90b..abcf31fa 100644 --- a/Testing/TestDicomDir.cxx +++ b/Testing/TestDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/01/18 07:56:21 $ - Version: $Revision: 1.30 $ + Date: $Date: 2005/01/20 11:09:22 $ + Version: $Revision: 1.31 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -70,7 +70,7 @@ int TestDicomDir(int argc, char* argv[]) } // Test if the DicomDir contains any Patient - if( !e1->GetFirstEntry() ) + if( !e1->GetFirstPatient() ) { std::cout<<" DicomDir '"<GetFirstEntry(); - while ( pa ) { // we process all the PATIENT of this DICOMDIR + pa = e1->GetFirstPatient(); + while ( pa ) + { // we process all the PATIENT of this DICOMDIR std::cout << pa->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name - st = pa->GetFirstEntry(); - while ( st ) { // we process all the STUDY of this patient + + st = pa->GetFirstStudy(); + while ( st ) + { // we process all the STUDY of this patient std::cout << "--- "<< st->GetEntry(0x0008, 0x1030) << std::endl; // Study Description std::cout << " Stud.ID:[" << st->GetEntry(0x0020, 0x0010); // Study ID - se = st->GetFirstEntry(); - while ( se ) { // we process all the SERIES of this study + + se = st->GetFirstSerie(); + while ( se ) + { // we process all the SERIES of this study std::cout << "--- --- "<< se->GetEntry(0x0008, 0x103e) << std::endl; // Serie Description std::cout << " Ser.nb:[" << se->GetEntry(0x0020, 0x0011); // Series number std::cout << "] Mod.:[" << se->GetEntry(0x0008, 0x0060) << "]"; // Modality - im = se->GetFirstEntry(); + + im = se->GetFirstImage(); while ( im ) { // we process all the IMAGE of this serie std::cout << "--- --- --- "<< im->GetEntry(0x0004, 0x1500) << std::endl; // File name - im = se->GetNextEntry(); + im = se->GetNextImage(); } - se = st->GetNextEntry(); + se = st->GetNextSerie(); } - st = pa->GetNextEntry(); - } - pa = e1->GetNextEntry(); - } - - + st = pa->GetNextStudy(); + } + pa = e1->GetNextPatient(); + } + std::cout << std::endl << std::endl << " = DICOMDIR full content ====================================" << std::endl<< std::endl; diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index ebbbfde8..9f05141b 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/19 15:24:28 $ - Version: $Revision: 1.107 $ + Date: $Date: 2005/01/20 11:09:23 $ + Version: $Revision: 1.108 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -61,9 +61,9 @@ namespace gdcm */ DicomDir::DicomDir() :Document( ) -{ +{ Initialize(); // sets all private fields to NULL - MetaElems = NewMeta(); + NewMeta(); } /** @@ -107,7 +107,7 @@ DicomDir::DicomDir(std::string const &fileName, bool parseDir ): if ( parseDir ) // user asked for a recursive parsing of a root directory { - MetaElems = NewMeta(); + NewMeta(); gdcmVerboseMacro( "Parse directory and create the DicomDir"); ParseDirectory(); @@ -209,29 +209,6 @@ bool DicomDir::IsReadable() return true; } -/** - * \brief Sets all fields to NULL - */ - -void DicomDir::Initialize() -{ - StartMethod = NULL; - ProgressMethod = NULL; - EndMethod = NULL; - StartMethodArgDelete = NULL; - ProgressMethodArgDelete = NULL; - EndMethodArgDelete = NULL; - StartArg = NULL; - ProgressArg = NULL; - EndArg = NULL; - - Progress = 0.0; - Abort = false; - - MetaElems = NULL; -} - - /** * \brief fills the whole structure, starting from a root Directory */ @@ -336,6 +313,34 @@ void DicomDir::SetEndMethodArgDelete( DicomDir::Method *method ) EndMethodArgDelete = method; } +/** + * \brief Get the first entry while visiting the DicomDirPatients + * \return The first DicomDirPatient if found, otherwhise NULL + */ +DicomDirPatient *DicomDir::GetFirstPatient() +{ + ItPatient = Patients.begin(); + if ( ItPatient != Patients.end() ) + return *ItPatient; + return NULL; +} + +/** + * \brief Get the next entry while visiting the DicomDirPatients + * \note : meaningfull only if GetFirstEntry already called + * \return The next DicomDirPatient if found, otherwhise NULL + */ +DicomDirPatient *DicomDir::GetNextPatient() +{ + gdcmAssertMacro (ItPatient != Patients.end()); + { + ++ItPatient; + if ( ItPatient != Patients.end() ) + return *ItPatient; + } + return NULL; +} + /** * \brief writes on disc a DICOMDIR * \ warning does NOT add the missing elements in the header : @@ -366,7 +371,7 @@ bool DicomDir::WriteDicomDir(std::string const &fileName) fp->write(filePreamble, 128); //FIXME binary_write( *fp, "DICM"); - DicomDirMeta *ptrMeta = GetDicomDirMeta(); + DicomDirMeta *ptrMeta = GetMeta(); ptrMeta->WriteContent(fp, ExplicitVR); // force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta @@ -463,7 +468,10 @@ void DicomDir::CreateDicomDirChainedList(std::string const & path) DicomDirMeta * DicomDir::NewMeta() { - DicomDirMeta *m = new DicomDirMeta(); + if( MetaElems ) + delete MetaElems; + + MetaElems = new DicomDirMeta(); if ( TagHT.begin() != TagHT.end() ) // after Document Parsing { @@ -475,17 +483,17 @@ DicomDirMeta * DicomDir::NewMeta() cc != lastOneButSequence; ++cc) { - m->AddEntry( cc->second ); + MetaElems->AddEntry( cc->second ); } } else // after root directory parsing { ListDicomDirMetaElem const &elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements(); - m->FillObject(elemList); + MetaElems->FillObject(elemList); } - m->SetSQItemNumber(0); // To avoid further missprinting - return m; + MetaElems->SetSQItemNumber(0); // To avoid further missprinting + return MetaElems; } /** @@ -515,8 +523,7 @@ DicomDirPatient *DicomDir::NewPatient() p->AddEntry( entry ); } - Patients.push_front( p ); - + AddPatientToEnd( p ); return p; } @@ -544,33 +551,37 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, case GDCM_DICOMDIR_IMAGE: elemList = Global::GetDicomDirElements()->GetDicomDirImageElements(); si = new DicomDirImage(); - if( !AddDicomDirImageToEnd(static_cast(si)) ) + if( !AddImageToEnd(static_cast(si)) ) { - gdcmVerboseMacro( "Add DicomDirImageToEnd failed"); + delete si; + gdcmErrorMacro( "Add ImageToEnd failed"); } break; case GDCM_DICOMDIR_SERIE: elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements(); si = new DicomDirSerie(); - if( !AddDicomDirSerieToEnd(static_cast(si)) ) + if( !AddSerieToEnd(static_cast(si)) ) { - gdcmVerboseMacro( "Add DicomDirSerieToEnd failed"); + delete si; + gdcmErrorMacro( "Add SerieToEnd failed"); } break; case GDCM_DICOMDIR_STUDY: elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements(); si = new DicomDirStudy(); - if( !AddDicomDirStudyToEnd(static_cast(si)) ) + if( !AddStudyToEnd(static_cast(si)) ) { - gdcmVerboseMacro( "Add DicomDirStudyToEnd failed"); + delete si; + gdcmErrorMacro( "Add StudyToEnd failed"); } break; case GDCM_DICOMDIR_PATIENT: elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements(); si = new DicomDirPatient(); - if( !AddDicomDirPatientToEnd(static_cast(si)) ) + if( !AddPatientToEnd(static_cast(si)) ) { - gdcmVerboseMacro( "Add DicomDirPatientToEnd failed"); + delete si; + gdcmErrorMacro( "Add PatientToEnd failed"); } break; case GDCM_DICOMDIR_META: @@ -578,8 +589,8 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, si = new DicomDirMeta(); if( MetaElems ) { - gdcmVerboseMacro( "MetaElements already exist, they will be destroyed"); delete MetaElems; + gdcmErrorMacro( "MetaElements already exist, they will be destroyed"); } MetaElems = static_cast(si); break; @@ -651,8 +662,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, if ( type == GDCM_DICOMDIR_META ) // fusible : should never print ! { - std::cout << "GDCM_DICOMDIR_META ?!? should never print that" - << std::endl; + gdcmVerboseMacro("GDCM_DICOMDIR_META ?!? should never print that"); } si->AddEntry(entry); } @@ -699,6 +709,27 @@ void DicomDir::CallEndMethod() //----------------------------------------------------------------------------- // Private +/** + * \brief Sets all fields to NULL + */ +void DicomDir::Initialize() +{ + StartMethod = NULL; + ProgressMethod = NULL; + EndMethod = NULL; + StartMethodArgDelete = NULL; + ProgressMethodArgDelete = NULL; + EndMethodArgDelete = NULL; + StartArg = NULL; + ProgressArg = NULL; + EndArg = NULL; + + Progress = 0.0; + Abort = false; + + MetaElems = NULL; +} + /** * \brief create a 'DicomDir' from a DICOMDIR Header */ @@ -729,7 +760,7 @@ void DicomDir::CreateDicomDir() return; } - MetaElems = NewMeta(); + NewMeta(); ListSQItem listItems = s->GetSQItems(); @@ -753,22 +784,42 @@ void DicomDir::CreateDicomDir() if( v == "PATIENT " ) { si = new DicomDirPatient(); - AddDicomDirPatientToEnd( static_cast(si) ); + if( !AddPatientToEnd( static_cast(si)) ) + { + delete si; + si = NULL; + gdcmErrorMacro( "Add PatientToEnd failed"); + } } else if( v == "STUDY " ) { si = new DicomDirStudy(); - AddDicomDirStudyToEnd( static_cast(si) ); + if( !AddStudyToEnd( static_cast(si)) ) + { + delete si; + si = NULL; + gdcmErrorMacro( "Add AddStudyToEnd failed"); + } } else if( v == "SERIES" ) { si = new DicomDirSerie(); - AddDicomDirSerieToEnd( static_cast(si) ); + if( !AddSerieToEnd( static_cast(si)) ) + { + delete si; + si = NULL; + gdcmErrorMacro( "Add AddSerieToEnd failed"); + } } else if( v == "IMAGE " ) { si = new DicomDirImage(); - AddDicomDirImageToEnd( static_cast(si) ); + if( !AddImageToEnd( static_cast(si)) ) + { + delete si; + si = NULL; + gdcmErrorMacro( "Add AddImageToEnd failed"); + } } else { @@ -776,85 +827,90 @@ void DicomDir::CreateDicomDir() // neither an 'IMAGE' SQItem. Skip to next item. continue; } - MoveSQItem(si,*i); - } - TagHT.clear(); -} -/** - * \brief Well ... there is only one occurence - */ -bool DicomDir::AddDicomDirMeta() -{ - if( MetaElems ) - { - delete MetaElems; + if( si ) + MoveSQItem(si,*i); } - MetaElems = new DicomDirMeta(); - return true; + TagHT.clear(); } /** - * \brief AddDicomDirPatientToEnd + * \brief AddPatientToEnd * @param dd SQ Item to enqueue to the DicomPatient chained List */ -bool DicomDir::AddDicomDirPatientToEnd(DicomDirPatient *dd) +bool DicomDir::AddPatientToEnd(DicomDirPatient *dd) { Patients.push_back(dd); return true; } /** - * \brief AddDicomDirStudyToEnd + * \brief AddStudyToEnd * @param dd SQ Item to enqueue to the DicomDirStudy chained List */ -bool DicomDir::AddDicomDirStudyToEnd(DicomDirStudy *dd) +bool DicomDir::AddStudyToEnd(DicomDirStudy *dd) { if( Patients.size() > 0 ) { ListDicomDirPatient::iterator itp = Patients.end(); itp--; - (*itp)->AddDicomDirStudy(dd); + (*itp)->AddStudy(dd); return true; } return false; } /** - * \brief AddDicomDirSerieToEnd + * \brief AddSerieToEnd * @param dd SQ Item to enqueue to the DicomDirSerie chained List */ -bool DicomDir::AddDicomDirSerieToEnd(DicomDirSerie *dd) +bool DicomDir::AddSerieToEnd(DicomDirSerie *dd) { if( Patients.size() > 0 ) { ListDicomDirPatient::iterator itp = Patients.end(); itp--; - if( (*itp)->GetDicomDirStudies().size() > 0 ) + DicomDirStudy *study = (*itp)->GetLastStudy(); + if( study ) + { + study->AddSerie(dd); + return true; + } +/* if( (*itp)->GetDicomDirStudies().size() > 0 ) { ListDicomDirStudy::const_iterator itst = (*itp)->GetDicomDirStudies().end(); itst--; - (*itst)->AddDicomDirSerie(dd); + (*itst)->AddSerie(dd); return true; - } + }*/ } return false; } /** - * \brief AddDicomDirImageToEnd + * \brief AddImageToEnd * @param dd SQ Item to enqueue to the DicomDirImage chained List */ -bool DicomDir::AddDicomDirImageToEnd(DicomDirImage *dd) +bool DicomDir::AddImageToEnd(DicomDirImage *dd) { if( Patients.size() > 0 ) { ListDicomDirPatient::iterator itp = Patients.end(); itp--; - if( (*itp)->GetDicomDirStudies().size() > 0 ) + DicomDirStudy *study = (*itp)->GetLastStudy(); + if( study ) + { + DicomDirSerie *serie = study->GetLastSerie(); + if( serie ) + { + serie->AddImage(dd); + return true; + } + } +/* if( (*itp)->GetDicomDirStudies().size() > 0 ) { ListDicomDirStudy::const_iterator itst = (*itp)->GetDicomDirStudies().end(); @@ -864,10 +920,10 @@ bool DicomDir::AddDicomDirImageToEnd(DicomDirImage *dd) { ListDicomDirSerie::const_iterator its = (*itst)->GetDicomDirSeries().end(); its--; - (*its)->AddDicomDirImage(dd); + (*its)->AddImage(dd); return true; } - } + }*/ } return false; } @@ -965,36 +1021,6 @@ bool DicomDir::HeaderLessThan(Document *header1, Document *header2) return *header1 < *header2; } - -/** - * \brief Get the first entry while visiting the DicomDirPatients - * \return The first DicomDirPatient if found, otherwhise NULL - */ -DicomDirPatient *DicomDir::GetFirstEntry() -{ - ItDicomDirPatient = Patients.begin(); - if ( ItDicomDirPatient != Patients.end() ) - return *ItDicomDirPatient; - return NULL; -} - -/** - * \brief Get the next entry while visiting the DicomDirPatients - * \note : meaningfull only if GetFirstEntry already called - * \return The next DicomDirPatient if found, otherwhise NULL - */ -DicomDirPatient *DicomDir::GetNextEntry() -{ - gdcmAssertMacro (ItDicomDirPatient != Patients.end()); - { - ++ItDicomDirPatient; - if ( ItDicomDirPatient != Patients.end() ) - return *ItDicomDirPatient; - } - return NULL; -} - - } // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index eca86fba..f3f9b073 100644 --- a/src/gdcmDicomDir.h +++ b/src/gdcmDicomDir.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.h,v $ Language: C++ - Date: $Date: 2005/01/18 07:53:42 $ - Version: $Revision: 1.48 $ + Date: $Date: 2005/01/20 11:09:23 $ + Version: $Revision: 1.49 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -60,16 +60,10 @@ public: /// \brief canonical Printer void Print(std::ostream &os = std::cout, std::string const & indent = "" ); + /// Informations contained in the parser virtual bool IsReadable(); - /// Returns a pointer to the DicomDirMeta for this DICOMDIR. - DicomDirMeta* GetDicomDirMeta() { return MetaElems; }; - - // should avoid exposing internal mechanism - DicomDirPatient *GetFirstEntry(); - DicomDirPatient *GetNextEntry(); - /// Parsing void ParseDirectory(); @@ -88,16 +82,20 @@ public: void SetStartMethodArgDelete( DicomDir::Method *m ); void SetProgressMethodArgDelete( DicomDir::Method *m ); void SetEndMethodArgDelete( DicomDir::Method *m ); - /// GetProgress GetProgress float GetProgress() { return Progress; }; - /// AbortProgress AbortProgress void AbortProgress() { Abort = true; }; - /// IsAborted IsAborted bool IsAborted() { return Abort; }; - + + /// Returns a pointer to the DicomDirMeta for this DICOMDIR. + DicomDirMeta* GetMeta() { return MetaElems; }; + + // should avoid exposing internal mechanism + DicomDirPatient *GetFirstPatient(); + DicomDirPatient *GetNextPatient(); + /// Adding DicomDirMeta *NewMeta(); DicomDirPatient *NewPatient(); @@ -126,11 +124,10 @@ private: void Initialize(); void CreateDicomDir(); - bool AddDicomDirMeta(); - bool AddDicomDirPatientToEnd(DicomDirPatient *dd); - bool AddDicomDirStudyToEnd (DicomDirStudy *dd); - bool AddDicomDirSerieToEnd (DicomDirSerie *dd); - bool AddDicomDirImageToEnd (DicomDirImage *dd); + bool AddPatientToEnd(DicomDirPatient *dd); + bool AddStudyToEnd (DicomDirStudy *dd); + bool AddSerieToEnd (DicomDirSerie *dd); + bool AddImageToEnd (DicomDirImage *dd); void SetElements(std::string const &path, VectDocument const &list); void SetElement (std::string const &path, DicomDirType type, @@ -143,10 +140,10 @@ private: /// Pointer on *the* DicomDirObject 'DicomDirMeta Elements' DicomDirMeta* MetaElems; - ListDicomDirPatient::iterator ItDicomDirPatient; /// Chained list of DicomDirPatient (to be exploited recursively) ListDicomDirPatient Patients; + ListDicomDirPatient::iterator ItPatient; /// pointer to the initialisation method for any progress bar Method* StartMethod; diff --git a/src/gdcmDicomDirElement.cxx b/src/gdcmDicomDirElement.cxx index b393d5dd..bf876a9a 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/18 07:53:42 $ - Version: $Revision: 1.27 $ + Date: $Date: 2005/01/20 11:09:23 $ + Version: $Revision: 1.28 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -40,7 +40,8 @@ DicomDirElement::DicomDirElement() std::ifstream from(filename.c_str()); if(!from) { - gdcmVerboseMacro( "Can't open dictionary" << filename.c_str()); + gdcmVerboseMacro( "Can't open DicomDirElement dictionary" + << filename.c_str()); FillDefaultDIRDict( this ); } else diff --git a/src/gdcmDicomDirObject.cxx b/src/gdcmDicomDirObject.cxx index edbd6a85..c4501ffc 100644 --- a/src/gdcmDicomDirObject.cxx +++ b/src/gdcmDicomDirObject.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirObject.cxx,v $ Language: C++ - Date: $Date: 2005/01/08 15:03:59 $ - Version: $Revision: 1.15 $ + Date: $Date: 2005/01/20 11:09:23 $ + 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 @@ -49,25 +49,6 @@ DicomDirObject::~DicomDirObject() //----------------------------------------------------------------------------- // Public - -/** - * \brief Builds a hash table (multimap) containing - * pointers to all Header Entries (i.e Dicom Element) - * related to this 'object' - * @return - */ -TagDocEntryHT DicomDirObject::GetEntryHT() -{ - TagDocEntryHT HT; - DocEntries = GetDocEntries(); - for(ListDocEntry::iterator i = DocEntries.begin(); - i != DocEntries.end(); ++i) - { - HT[(*i)->GetKey()] = *i; - } - return HT; -} - //----------------------------------------------------------------------------- // Protected /** diff --git a/src/gdcmDicomDirObject.h b/src/gdcmDicomDirObject.h index c731f46e..2c70277b 100644 --- a/src/gdcmDicomDirObject.h +++ b/src/gdcmDicomDirObject.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirObject.h,v $ Language: C++ - Date: $Date: 2005/01/11 15:15:38 $ - Version: $Revision: 1.12 $ + Date: $Date: 2005/01/20 11:09:23 $ + 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 @@ -30,6 +30,8 @@ namespace gdcm //----------------------------------------------------------------------------- class DicomDirObject; +//----------------------------------------------------------------------------- +typedef std::list ListContent; //----------------------------------------------------------------------------- /** * \ingroup DicomDirObject @@ -38,9 +40,7 @@ class DicomDirObject; */ class GDCM_EXPORT DicomDirObject : public SQItem { -typedef std::list ListContent; public: - TagDocEntryHT GetEntryHT(); void FillObject(ListDicomDirMetaElem const &elemList); protected: diff --git a/src/gdcmDicomDirPatient.cxx b/src/gdcmDicomDirPatient.cxx index abf4d1b2..035f6492 100644 --- a/src/gdcmDicomDirPatient.cxx +++ b/src/gdcmDicomDirPatient.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirPatient.cxx,v $ Language: C++ - Date: $Date: 2005/01/18 14:28:32 $ - Version: $Revision: 1.28 $ + Date: $Date: 2005/01/20 11:09:23 $ + 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 @@ -69,6 +69,8 @@ void DicomDirPatient::Print(std::ostream &os, std::string const & ) } } +//----------------------------------------------------------------------------- +// Public /** * \brief Writes the Object * @param fp ofstream to write to @@ -85,8 +87,6 @@ void DicomDirPatient::WriteContent(std::ofstream *fp, FileType t) (*cc)->WriteContent( fp, t ); } } -//----------------------------------------------------------------------------- -// Public /** * \brief adds a new Patient at the begining of the PatientList @@ -100,7 +100,7 @@ DicomDirStudy* DicomDirPatient::NewStudy() DicomDirStudy *st = new DicomDirStudy(); st->FillObject(elemList); - Studies.push_front(st); + Studies.push_back(st); return st; } @@ -108,11 +108,11 @@ DicomDirStudy* DicomDirPatient::NewStudy() * \brief Get the first entry while visiting the DicomDirStudy * \return The first DicomDirStudy if found, otherwhise NULL */ -DicomDirStudy *DicomDirPatient::GetFirstEntry() +DicomDirStudy *DicomDirPatient::GetFirstStudy() { - ItDicomDirStudy = Studies.begin(); - if (ItDicomDirStudy != Studies.end()) - return *ItDicomDirStudy; + ItStudy = Studies.begin(); + if (ItStudy != Studies.end()) + return *ItStudy; return NULL; } @@ -121,16 +121,32 @@ DicomDirStudy *DicomDirPatient::GetFirstEntry() * \note : meaningfull only if GetFirstEntry already called * \return The next DicomDirStudies if found, otherwhise NULL */ -DicomDirStudy *DicomDirPatient::GetNextEntry() +DicomDirStudy *DicomDirPatient::GetNextStudy() { - gdcmAssertMacro (ItDicomDirStudy != Studies.end()) + gdcmAssertMacro (ItStudy != Studies.end()) { - ++ItDicomDirStudy; - if (ItDicomDirStudy != Studies.end()) - return *ItDicomDirStudy; + ++ItStudy; + if (ItStudy != Studies.end()) + return *ItStudy; } return NULL; } + +/** + * \brief Get the first entry while visiting the DicomDirStudy + * \return The first DicomDirStudy if found, otherwhise NULL + */ +DicomDirStudy *DicomDirPatient::GetLastStudy() +{ + ItStudy = Studies.end(); + if (ItStudy != Studies.begin()) + { + --ItStudy; + return *ItStudy; + } + return NULL; +} + //----------------------------------------------------------------------------- // Protected diff --git a/src/gdcmDicomDirPatient.h b/src/gdcmDicomDirPatient.h index 97f78cf7..b3602e5a 100644 --- a/src/gdcmDicomDirPatient.h +++ b/src/gdcmDicomDirPatient.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirPatient.h,v $ Language: C++ - Date: $Date: 2005/01/18 07:53:42 $ - Version: $Revision: 1.20 $ + Date: $Date: 2005/01/20 11:09:23 $ + Version: $Revision: 1.21 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -42,15 +42,13 @@ public: void Print(std::ostream &os = std::cout, std::string const & indent = "" ); void WriteContent(std::ofstream *fp, FileType t); - /// Returns the STUDY chained List for this PATIENT. - ListDicomDirStudy const &GetDicomDirStudies() const { return Studies; }; - // should avoid exposing internal mechanism - DicomDirStudy *GetFirstEntry(); - DicomDirStudy *GetNextEntry(); + DicomDirStudy *GetFirstStudy(); + DicomDirStudy *GetNextStudy(); + DicomDirStudy *GetLastStudy(); /// adds the passed STUDY to the STUDY chained List for this PATIENT. - void AddDicomDirStudy (DicomDirStudy *obj) { Studies.push_back(obj); }; + void AddStudy(DicomDirStudy *obj) { Studies.push_back(obj); }; DicomDirStudy *NewStudy(); @@ -59,7 +57,7 @@ private: /// chained list of DicomDirStudy (to be exploited recursively) ListDicomDirStudy Studies; /// iterator on the DicomDirStudies of the current DicomDirPatient - ListDicomDirStudy::iterator ItDicomDirStudy; + ListDicomDirStudy::iterator ItStudy; }; } // end namespace gdcm diff --git a/src/gdcmDicomDirSerie.cxx b/src/gdcmDicomDirSerie.cxx index 50dbfa91..0abf587e 100644 --- a/src/gdcmDicomDirSerie.cxx +++ b/src/gdcmDicomDirSerie.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirSerie.cxx,v $ Language: C++ - Date: $Date: 2005/01/18 14:28:32 $ - Version: $Revision: 1.30 $ + Date: $Date: 2005/01/20 11:09:23 $ + Version: $Revision: 1.31 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -70,7 +70,6 @@ void DicomDirSerie::Print(std::ostream &os, std::string const &) //----------------------------------------------------------------------------- // Public - /** * \brief Writes the Object * @param fp ofstream to write to @@ -97,9 +96,9 @@ DicomDirImage *DicomDirSerie::NewImage() Global::GetDicomDirElements()->GetDicomDirImageElements(); DicomDirImage *st = new DicomDirImage(); - FillObject(elemList); - Images.push_front(st); + st->FillObject(elemList); + Images.push_back(st); return st; } @@ -107,11 +106,11 @@ DicomDirImage *DicomDirSerie::NewImage() * \brief Get the first entry while visiting the DicomDirImage * \return The first DicomDirImage if found, otherwhise NULL */ -DicomDirImage *DicomDirSerie::GetFirstEntry() +DicomDirImage *DicomDirSerie::GetFirstImage() { - ItDicomDirImage = Images.begin(); - if (ItDicomDirImage != Images.end()) - return *ItDicomDirImage; + ItImage = Images.begin(); + if (ItImage != Images.end()) + return *ItImage; return NULL; } @@ -120,17 +119,32 @@ DicomDirImage *DicomDirSerie::GetFirstEntry() * \note : meaningfull only if GetFirstEntry already called * \return The next DicomDirImages if found, otherwhise NULL */ -DicomDirImage *DicomDirSerie::GetNextEntry() +DicomDirImage *DicomDirSerie::GetNextImage() { - gdcmAssertMacro (ItDicomDirImage != Images.end()); + gdcmAssertMacro (ItImage != Images.end()); { - ++ItDicomDirImage; - if (ItDicomDirImage != Images.end()) - return *ItDicomDirImage; + ++ItImage; + if (ItImage != Images.end()) + return *ItImage; } return NULL; } +/** + * \brief Get the first entry while visiting the DicomDirImage + * \return The first DicomDirImage if found, otherwhise NULL + */ +DicomDirImage *DicomDirSerie::GetLastImage() +{ + ItImage = Images.end(); + if (ItImage != Images.begin()) + { + --ItImage; + return *ItImage; + } + return NULL; +} + //----------------------------------------------------------------------------- // Protected diff --git a/src/gdcmDicomDirSerie.h b/src/gdcmDicomDirSerie.h index 4449d20d..75140047 100644 --- a/src/gdcmDicomDirSerie.h +++ b/src/gdcmDicomDirSerie.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirSerie.h,v $ Language: C++ - Date: $Date: 2005/01/18 07:53:42 $ - Version: $Revision: 1.21 $ + Date: $Date: 2005/01/20 11:09:23 $ + Version: $Revision: 1.22 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -41,15 +41,13 @@ public: void Print( std::ostream &os = std::cout, std::string const & indent = "" ); void WriteContent( std::ofstream *fp, FileType t ); - /// Returns the IMAGE chained List for this SERIE. - ListDicomDirImage const &GetDicomDirImages() const { return Images; }; - // should avoid exposing internal mechanism - DicomDirImage *GetFirstEntry(); - DicomDirImage *GetNextEntry(); + DicomDirImage *GetFirstImage(); + DicomDirImage *GetNextImage(); + DicomDirImage *GetLastImage(); /// adds the passed IMAGE to the IMAGE chained List for this SERIE. - void AddDicomDirImage(DicomDirImage *obj) { Images.push_back(obj); }; + void AddImage(DicomDirImage *obj) { Images.push_back(obj); }; DicomDirImage *NewImage(); @@ -58,7 +56,7 @@ private: ///chained list of DicomDirImages (to be exploited recursively) ListDicomDirImage Images; /// iterator on the DicomDirImages of the current DicomDirSerie - ListDicomDirImage::iterator ItDicomDirImage; + ListDicomDirImage::iterator ItImage; }; } // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmDicomDirStudy.cxx b/src/gdcmDicomDirStudy.cxx index 92630664..3a552627 100644 --- a/src/gdcmDicomDirStudy.cxx +++ b/src/gdcmDicomDirStudy.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirStudy.cxx,v $ Language: C++ - Date: $Date: 2005/01/18 14:28:32 $ - Version: $Revision: 1.27 $ + Date: $Date: 2005/01/20 11:09:23 $ + Version: $Revision: 1.28 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -70,7 +70,6 @@ void DicomDirStudy::Print(std::ostream &os, std::string const & ) //----------------------------------------------------------------------------- // Public - /** * \brief Writes the Object * @param fp ofstream to write to @@ -99,21 +98,21 @@ DicomDirSerie *DicomDirStudy::NewSerie() Global::GetDicomDirElements()->GetDicomDirSerieElements(); DicomDirSerie* st = new DicomDirSerie(); - FillObject(elemList); - Series.push_front(st); + st->FillObject(elemList); - return st; + Series.push_back(st); + return st; } - /** +/** * \brief Get the first entry while visiting the DicomDirSeries * \return The first DicomDirSerie if found, otherwhise NULL */ -DicomDirSerie *DicomDirStudy::GetFirstEntry() +DicomDirSerie *DicomDirStudy::GetFirstSerie() { - ItDicomDirSerie = Series.begin(); - if (ItDicomDirSerie != Series.end()) - return *ItDicomDirSerie; + ItSerie = Series.begin(); + if (ItSerie != Series.end()) + return *ItSerie; return NULL; } @@ -122,16 +121,32 @@ DicomDirSerie *DicomDirStudy::GetFirstEntry() * \note : meaningfull only if GetFirstEntry already called * \return The next DicomDirSerie if found, otherwhise NULL */ -DicomDirSerie *DicomDirStudy::GetNextEntry() +DicomDirSerie *DicomDirStudy::GetNextSerie() { - gdcmAssertMacro (ItDicomDirSerie != Series.end()); + gdcmAssertMacro (ItSerie != Series.end()); { - ++ItDicomDirSerie; - if (ItDicomDirSerie != Series.end()) - return *ItDicomDirSerie; + ++ItSerie; + if (ItSerie != Series.end()) + return *ItSerie; } return NULL; } + +/** + * \brief Get the last entry while visiting the DicomDirSeries + * \return The first DicomDirSerie if found, otherwhise NULL + */ +DicomDirSerie *DicomDirStudy::GetLastSerie() +{ + ItSerie = Series.end(); + if (ItSerie != Series.begin()) + { + --ItSerie; + return *ItSerie; + } + return NULL; +} + //----------------------------------------------------------------------------- // Protected diff --git a/src/gdcmDicomDirStudy.h b/src/gdcmDicomDirStudy.h index 1a33f86f..57d533af 100644 --- a/src/gdcmDicomDirStudy.h +++ b/src/gdcmDicomDirStudy.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirStudy.h,v $ Language: C++ - Date: $Date: 2005/01/18 07:53:42 $ - Version: $Revision: 1.19 $ + Date: $Date: 2005/01/20 11:09:23 $ + Version: $Revision: 1.20 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -41,15 +41,13 @@ public: void Print(std::ostream &os = std::cout, std::string const & indent = "" ); void WriteContent(std::ofstream *fp, FileType t); - /// Returns the SERIE chained List for this STUDY. - ListDicomDirSerie const &GetDicomDirSeries() const { return Series; }; - // should avoid exposing internal mechanism - DicomDirSerie *GetFirstEntry(); - DicomDirSerie *GetNextEntry(); + DicomDirSerie *GetFirstSerie(); + DicomDirSerie *GetNextSerie(); + DicomDirSerie *GetLastSerie(); /// adds the passed SERIE to the SERIE chained List for this STUDY. - void AddDicomDirSerie(DicomDirSerie *obj) { Series.push_back(obj); }; + void AddSerie(DicomDirSerie *obj) { Series.push_back(obj); }; DicomDirSerie* NewSerie(); @@ -58,7 +56,7 @@ private: /// chained list of DicomDirSeries (to be exploited recursively) ListDicomDirSerie Series; /// iterator on the DicomDirSeries of the current DicomDirStudy - ListDicomDirSerie::iterator ItDicomDirSerie; + ListDicomDirSerie::iterator ItSerie; }; } // end namespace gdcm