X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDicomDir.cxx;h=f775d215aed10281da9eb3293b0b8ab084f7b307;hb=963480c814326423065a4a02fa1bf8bc1243ae4f;hp=2a19043b9cc6706b803e16e5b7ad287cb9d357f7;hpb=58156942f515f7d313b9b098156313a44f3b1e2b;p=gdcm.git diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 2a19043b..f775d215 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 22:03:30 $ - Version: $Revision: 1.96 $ + Date: $Date: 2005/01/18 11:39:59 $ + Version: $Revision: 1.105 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -57,7 +57,6 @@ namespace gdcm // Constructor / Destructor /** - * \ingroup DicomDir * \brief Constructor : creates an empty DicomDir */ DicomDir::DicomDir() @@ -82,16 +81,21 @@ DicomDir::DicomDir() DicomDir::DicomDir(std::string const &fileName, bool parseDir ): Document( fileName ) { - // Whatever user passed (a root directory or a DICOMDIR) - // and whatever the value of parseDir was, - // Document is already executed + // At this step, Document constructor is already executed, + // whatever user passed (a root directory or a DICOMDIR) + // and whatever the value of parseDir was. + // (nothing is cheked in Document constructor, to avoid overhead) + Initialize(); // sets all private fields to NULL // if user passed a root directory, sure we didn't get anything if ( TagHT.begin() == TagHT.end() ) // when user passed a Directory to parse { - gdcmVerboseMacro( "Entry HT empty"); + if (!parseDir) + gdcmVerboseMacro( "Entry HT empty for file: "<Group; tmpEl = it->Elem; - dictEntry = GetPubDict()->GetDictEntryByNumber(tmpGr, tmpEl); + dictEntry = GetPubDict()->GetDictEntry(tmpGr, tmpEl); entry = new ValEntry( dictEntry ); entry->SetOffset(0); // just to avoid further missprinting entry->SetValue( it->Value ); @@ -599,7 +600,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, { tmpGr = it->Group; tmpEl = it->Elem; - dictEntry = GetPubDict()->GetDictEntryByNumber(tmpGr, tmpEl); + dictEntry = GetPubDict()->GetDictEntry(tmpGr, tmpEl); entry = new ValEntry( dictEntry ); // Be sure it's never a BinEntry ! @@ -609,7 +610,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, { // NULL when we Build Up (ex nihilo) a DICOMDIR // or when we add the META elems - val = header->GetEntryByNumber(tmpGr, tmpEl); + val = header->GetEntry(tmpGr, tmpEl); } else { @@ -642,7 +643,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, } else { - if ( header->GetEntryLengthByNumber(tmpGr,tmpEl) == 0 ) + if ( header->GetEntryLength(tmpGr,tmpEl) == 0 ) val = it->Value; } @@ -673,7 +674,6 @@ void DicomDir::CallStartMethod() //----------------------------------------------------------------------------- /** - * \ingroup DicomDir * \brief CallProgressMethod */ void DicomDir::CallProgressMethod() @@ -686,7 +686,6 @@ void DicomDir::CallProgressMethod() //----------------------------------------------------------------------------- /** - * \ingroup DicomDir * \brief CallEndMethod */ void DicomDir::CallEndMethod() @@ -701,7 +700,6 @@ void DicomDir::CallEndMethod() //----------------------------------------------------------------------------- // Private /** - * \ingroup DicomDir * \brief create a 'DicomDir' from a DICOMDIR Header */ void DicomDir::CreateDicomDir() @@ -715,7 +713,7 @@ void DicomDir::CreateDicomDir() // + loop to 1 - // Directory record sequence - DocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); + DocEntry *e = GetDocEntry(0x0004, 0x1220); if ( !e ) { gdcmVerboseMacro( "NO Directory record sequence (0x0004,0x1220)"); @@ -731,7 +729,6 @@ void DicomDir::CreateDicomDir() return; } - DicomDirType type; // = DicomDir::GDCM_DICOMDIR_META; MetaElems = NewMeta(); ListSQItem listItems = s->GetSQItems(); @@ -742,7 +739,7 @@ void DicomDir::CreateDicomDir() for( ListSQItem::iterator i = listItems.begin(); i !=listItems.end(); ++i ) { - d = (*i)->GetDocEntryByNumber(0x0004, 0x1430); // Directory Record Type + d = (*i)->GetDocEntry(0x0004, 0x1430); // Directory Record Type if ( ValEntry* valEntry = dynamic_cast(d) ) { v = valEntry->GetValue(); @@ -757,25 +754,21 @@ void DicomDir::CreateDicomDir() { si = new DicomDirPatient(); AddDicomDirPatientToEnd( static_cast(si) ); - type = DicomDir::GDCM_DICOMDIR_PATIENT; } else if( v == "STUDY " ) { si = new DicomDirStudy(); AddDicomDirStudyToEnd( static_cast(si) ); - type = DicomDir::GDCM_DICOMDIR_STUDY; } else if( v == "SERIES" ) { si = new DicomDirSerie(); AddDicomDirSerieToEnd( static_cast(si) ); - type = DicomDir::GDCM_DICOMDIR_SERIE; } else if( v == "IMAGE " ) { si = new DicomDirImage(); AddDicomDirImageToEnd( static_cast(si) ); - type = DicomDir::GDCM_DICOMDIR_IMAGE; } else { @@ -789,7 +782,6 @@ void DicomDir::CreateDicomDir() } /** - * \ingroup DicomDir * \brief Well ... there is only one occurence */ bool DicomDir::AddDicomDirMeta() @@ -803,7 +795,6 @@ bool DicomDir::AddDicomDirMeta() } /** - * \ingroup DicomDir * \brief AddDicomDirPatientToEnd * @param dd SQ Item to enqueue to the DicomPatient chained List */ @@ -814,7 +805,6 @@ bool DicomDir::AddDicomDirPatientToEnd(DicomDirPatient *dd) } /** - * \ingroup DicomDir * \brief AddDicomDirStudyToEnd * @param dd SQ Item to enqueue to the DicomDirStudy chained List */ @@ -831,7 +821,6 @@ bool DicomDir::AddDicomDirStudyToEnd(DicomDirStudy *dd) } /** - * \ingroup DicomDir * \brief AddDicomDirSerieToEnd * @param dd SQ Item to enqueue to the DicomDirSerie chained List */ @@ -855,7 +844,6 @@ bool DicomDir::AddDicomDirSerieToEnd(DicomDirSerie *dd) } /** - * \ingroup DicomDir * \brief AddDicomDirImageToEnd * @param dd SQ Item to enqueue to the DicomDirImage chained List */ @@ -885,7 +873,6 @@ bool DicomDir::AddDicomDirImageToEnd(DicomDirImage *dd) } /** - * \ingroup DicomDir * \brief for each Header of the chained list, add/update the Patient/Study/Serie/Image info * @param path path of the root directory * @param list chained list of Headers @@ -908,12 +895,12 @@ void DicomDir::SetElements(std::string const & path, VectDocument const &list) it != list.end(); ++it ) { // get the current file characteristics - patCurName = (*it)->GetEntryByNumber(0x0010,0x0010); - patCurID = (*it)->GetEntryByNumber(0x0010,0x0011); - studCurInstanceUID = (*it)->GetEntryByNumber(0x0020,0x000d); - studCurID = (*it)->GetEntryByNumber(0x0020,0x0010); - serCurInstanceUID = (*it)->GetEntryByNumber(0x0020,0x000e); - serCurID = (*it)->GetEntryByNumber(0x0020,0x0011); + patCurName = (*it)->GetEntry(0x0010,0x0010); + patCurID = (*it)->GetEntry(0x0010,0x0011); + studCurInstanceUID = (*it)->GetEntry(0x0020,0x000d); + studCurID = (*it)->GetEntry(0x0020,0x0010); + serCurInstanceUID = (*it)->GetEntry(0x0020,0x000e); + serCurID = (*it)->GetEntry(0x0020,0x0011); if( patCurName != patPrevName || patCurID != patPrevID || first ) { @@ -951,7 +938,6 @@ void DicomDir::SetElements(std::string const & path, VectDocument const &list) } /** - * \ingroup DicomDir * \brief Move the content of the src SQItem to the dst SQItem * Only DocEntry's are moved * @@ -973,13 +959,43 @@ void DicomDir::MoveSQItem(SQItem *dst,SQItem *src) } /** - * \ingroup DicomDir * \brief compares two dgcmHeaders */ bool DicomDir::HeaderLessThan(Document *header1, Document *header2) { return *header1 < *header2; } + + +/** + * \brief Get the first entry while visiting the DicomDirPatients + * \return The next 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 //-----------------------------------------------------------------------------