- delete MetaElems;
- }
- MetaElems = new DicomDirMeta();
- return true;
-}
-
-/**
- * \ingroup DicomDir
- * \brief AddDicomDirPatientToEnd
- * @param s SQ Item to enqueue to the DicomPatient chained List
- */
-bool DicomDir::AddDicomDirPatientToEnd(DicomDirPatient *dd)
-{
- Patients.push_back(dd);
- return true;
-}
-
-/**
- * \ingroup DicomDir
- * \brief AddDicomDirStudyToEnd
- * @param s SQ Item to enqueue to the DicomDirStudy chained List
- */
-bool DicomDir::AddDicomDirStudyToEnd(DicomDirStudy *dd)
-{
- if( Patients.size() > 0 )
- {
- ListDicomDirPatient::iterator itp = Patients.end();
- itp--;
- (*itp)->AddDicomDirStudy(dd);
- return true;
- }
- return false;
-}
-
-/**
- * \ingroup DicomDir
- * \brief AddDicomDirSerieToEnd
- * @param s SQ Item to enqueue to the DicomDirSerie chained List
- */
-bool DicomDir::AddDicomDirSerieToEnd(DicomDirSerie *dd)
-{
- if( Patients.size() > 0 )
- {
- ListDicomDirPatient::iterator itp = Patients.end();
- itp--;
-
- if( (*itp)->GetDicomDirStudies().size() > 0 )
- {
- ListDicomDirStudy::const_iterator itst =
- (*itp)->GetDicomDirStudies().end();
- itst--;
- (*itst)->AddDicomDirSerie(dd);
- return true;
- }
- }
- return false;
-}
-
-/**
- * \ingroup DicomDir
- * \brief AddDicomDirImageToEnd
- * @param s SQ Item to enqueue to the DicomDirImage chained List
- */
-bool DicomDir::AddDicomDirImageToEnd(DicomDirImage *dd)
-{
- if( Patients.size() > 0 )
- {
- ListDicomDirPatient::iterator itp = Patients.end();
- itp--;
-
- if( (*itp)->GetDicomDirStudies().size() > 0 )
- {
- ListDicomDirStudy::const_iterator itst =
- (*itp)->GetDicomDirStudies().end();
- itst--;
-
- if( (*itst)->GetDicomDirSeries().size() > 0 )
- {
- ListDicomDirSerie::const_iterator its = (*itst)->GetDicomDirSeries().end();
- its--;
- (*its)->AddDicomDirImage(dd);
- return true;
- }
- }
- }
- return false;
-}
-
-/**
- * \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
- */
-void DicomDir::SetElements(std::string const & path, VectDocument const &list)
-{
- TagHT.clear();
- Patients.clear();
-
- std::string patPrevName = "", patPrevID = "";
- std::string studPrevInstanceUID = "", studPrevID = "";
- std::string serPrevInstanceUID = "", serPrevID = "";
-
- std::string patCurName, patCurID;
- std::string studCurInstanceUID, studCurID;
- std::string serCurInstanceUID, serCurID;
-
- bool first = true;
- for( VectDocument::const_iterator it = list.begin();
- 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);
-
- if( patCurName != patPrevName || patCurID != patPrevID || first )
- {
- SetElement(path, GDCM_DICOMDIR_PATIENT, *it);
- first = true;
- }
-
- // if new Study Deal with 'STUDY' Elements
- if( studCurInstanceUID != studPrevInstanceUID || studCurID != studPrevID
- || first )
- {
- SetElement(path, GDCM_DICOMDIR_STUDY, *it);
- first = true;
- }
-
- // if new Serie Deal with 'SERIE' Elements
- if( serCurInstanceUID != serPrevInstanceUID || serCurID != serPrevID
- || first )
- {
- SetElement(path, GDCM_DICOMDIR_SERIE, *it);
- first = true;
- }
-
- // Always Deal with 'IMAGE' Elements
- SetElement(path, GDCM_DICOMDIR_IMAGE, *it);
-
- patPrevName = patCurName;
- patPrevID = patCurID;
- studPrevInstanceUID = studCurInstanceUID;
- studPrevID = studCurID;
- serPrevInstanceUID = serCurInstanceUID;
- serPrevID = serCurID;
- first = false;
- }
-}
-
-/**
- * \ingroup DicomDir
- * \brief Move the content of the src SQItem to the dst SQItem
- * Only DocEntry's are moved
- *
- */
-void DicomDir::MoveSQItem(SQItem* dst,SQItem *src)
-{
- DocEntry *entry;
-
- src->Initialize();
- entry = src->GetNextEntry();
- while(entry)