X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDicomDir.cxx;h=cc41e96dd951fbe7bb27058dcc6448bd4ef11642;hb=3842922fd2263cea5f679c9d283b3b4afead35d2;hp=1ef0feab48d1fa64c560a61a5194a753e16a280b;hpb=a462ce9f1af0894cd930ab04f2e65cd80dfa7084;p=gdcm.git diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 1ef0feab..cc41e96d 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/08 15:03:59 $ - Version: $Revision: 1.97 $ + Date: $Date: 2005/01/19 08:57:14 $ + Version: $Revision: 1.106 $ 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: "<GetSQItems(); @@ -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 @@ -951,35 +938,62 @@ void DicomDir::SetElements(std::string const & path, VectDocument const &list) } /** - * \ingroup DicomDir - * \brief Move the content of the src SQItem to the dst SQItem + * \brief Move the content of the source SQItem to the destination SQItem * Only DocEntry's are moved - * + * @param dst destination SQItem + * @param src source SQItem */ void DicomDir::MoveSQItem(SQItem *dst,SQItem *src) { DocEntry *entry; - src->Initialize(); - entry = src->GetNextEntry(); + entry = src->GetFirstEntry(); while(entry) { src->RemoveEntryNoDestroy(entry); dst->AddEntry(entry); - - src->Initialize(); entry = src->GetNextEntry(); } } /** - * \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 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 //-----------------------------------------------------------------------------