X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDicomDir.cxx;h=77ba8889623d6ff5ba6e1e7d8dcf4b2340af7aca;hb=c67ffef593e7635d8dfa7d3fe63d702e5afafc3e;hp=95b2800473904fd4475a761adc1f98b6e140d38e;hpb=ad8f0eb6ea1ad66c443b3640cded8a355efa7b42;p=gdcm.git diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 95b28004..77ba8889 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/20 16:16:41 $ - Version: $Revision: 1.111 $ + Date: $Date: 2005/01/26 10:29:17 $ + Version: $Revision: 1.120 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -27,7 +27,7 @@ #include "gdcmUtil.h" #include "gdcmDebug.h" #include "gdcmGlobal.h" -#include "gdcmHeader.h" +#include "gdcmFile.h" #include "gdcmSeqEntry.h" #include "gdcmSQItem.h" #include "gdcmValEntry.h" @@ -89,7 +89,8 @@ DicomDir::DicomDir(std::string const &fileName, bool parseDir ): 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 + + if ( GetFirstEntry() == 0 ) // when user passed a Directory to parse { if (!parseDir) gdcmVerboseMacro( "Entry HT empty for file: "<c_str() ); + header = new File( it->c_str() ); if( !header ) { - gdcmVerboseMacro( "Failure in new Header " << it->c_str() ); + gdcmVerboseMacro( "Failure in new gdcm::File " << it->c_str() ); continue; } if( header->IsReadable() ) { - // Add the file header to the chained list: + // Add the file to the chained list: list.push_back(header); gdcmVerboseMacro( "Readable " << it->c_str() ); } @@ -450,7 +447,7 @@ void DicomDir::CreateDicomDirChainedList(std::string const & path) std::sort(list.begin(), list.end(), DicomDir::HeaderLessThan ); std::string tmp = dirList.GetDirName(); - //for each Header of the chained list, add/update the Patient/Study/Serie/Image info + //for each File of the chained list, add/update the Patient/Study/Serie/Image info SetElements(tmp, list); CallEndMethod(); @@ -458,33 +455,33 @@ void DicomDir::CreateDicomDirChainedList(std::string const & path) itDoc!=list.end(); ++itDoc) { - delete dynamic_cast
(*itDoc); + delete dynamic_cast(*itDoc); } } /** * \brief adds *the* Meta to a partially created DICOMDIR - */ - -DicomDirMeta * DicomDir::NewMeta() + */ +DicomDirMeta *DicomDir::NewMeta() { if( MetaElems ) delete MetaElems; - - if ( TagHT.begin() != TagHT.end() ) // after Document Parsing + DocEntry *entry = GetFirstEntry(); + if( entry ) { MetaElems = new DicomDirMeta(true); - TagDocEntryHT::iterator lastOneButSequence = TagHT.end(); - lastOneButSequence --; - // ALL the 'out of Sequence' Tags belong to Meta Elems - // (we skip 0004|1220 [Directory record sequence] ) - for ( TagDocEntryHT::iterator cc = TagHT.begin(); - cc != lastOneButSequence; - ++cc) + entry = GetFirstEntry(); + while( entry ) { - MetaElems->AddEntry( cc->second ); + if( dynamic_cast(entry) ) + break; + + RemoveEntryNoDestroy(entry); + MetaElems->AddEntry(entry); + + entry = GetFirstEntry(); } } else // after root directory parsing @@ -496,7 +493,8 @@ DicomDirMeta * DicomDir::NewMeta() } /** - * \brief adds a new Patient (with the basic elements) to a partially created DICOMDIR + * \brief adds a new Patient (with the basic elements) to a partially created + * DICOMDIR */ DicomDirPatient *DicomDir::NewPatient() { @@ -505,6 +503,20 @@ DicomDirPatient *DicomDir::NewPatient() return p; } +/** + * \brief Remove all Patients + */ +void DicomDir::ClearPatient() +{ + for(ListDicomDirPatient::iterator cc = Patients.begin(); + cc!= Patients.end(); + ++cc) + { + delete *cc; + } + Patients.clear(); +} + /** * \brief adds to the HTable * the Entries (Dicom Elements) corresponding to the given type @@ -589,7 +601,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, { tmpGr = it->Group; tmpEl = it->Elem; - dictEntry = GetPubDict()->GetDictEntry(tmpGr, tmpEl); + dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl); entry = new ValEntry( dictEntry ); // Be sure it's never a BinEntry ! @@ -599,7 +611,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->GetEntry(tmpGr, tmpEl); + val = header->GetEntryValue(tmpGr, tmpEl); } else { @@ -739,8 +751,6 @@ void DicomDir::CreateDicomDir() } NewMeta(); - - //ListSQItem listItems = s->GetSQItems(); DocEntry *d; std::string v; @@ -806,13 +816,10 @@ void DicomDir::CreateDicomDir() // neither an 'IMAGE' SQItem. Skip to next item. continue; } - - if( si ) - MoveSQItem(si,tmpSI); - tmpSI=s->GetNextSQItem(); } - TagHT.clear(); +// friend hunting : this one will be difficult to remove ! + ClearEntry(); } /** @@ -858,14 +865,6 @@ bool DicomDir::AddSerieToEnd(DicomDirSerie *dd) study->AddSerie(dd); return true; } -/* if( (*itp)->GetDicomDirStudies().size() > 0 ) - { - ListDicomDirStudy::const_iterator itst = - (*itp)->GetDicomDirStudies().end(); - itst--; - (*itst)->AddSerie(dd); - return true; - }*/ } return false; } @@ -891,20 +890,6 @@ bool DicomDir::AddImageToEnd(DicomDirImage *dd) return true; } } -/* 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)->AddImage(dd); - return true; - } - }*/ } return false; } @@ -916,8 +901,8 @@ bool DicomDir::AddImageToEnd(DicomDirImage *dd) */ void DicomDir::SetElements(std::string const & path, VectDocument const &list) { - TagHT.clear(); - Patients.clear(); + ClearEntry(); + ClearPatient(); std::string patPrevName = "", patPrevID = ""; std::string studPrevInstanceUID = "", studPrevID = ""; @@ -932,12 +917,12 @@ void DicomDir::SetElements(std::string const & path, VectDocument const &list) it != list.end(); ++it ) { // get the current file characteristics - 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); + patCurName = (*it)->GetEntryValue(0x0010,0x0010); + patCurID = (*it)->GetEntryValue(0x0010,0x0011); + studCurInstanceUID = (*it)->GetEntryValue(0x0020,0x000d); + studCurID = (*it)->GetEntryValue(0x0020,0x0010); + serCurInstanceUID = (*it)->GetEntryValue(0x0020,0x000e); + serCurID = (*it)->GetEntryValue(0x0020,0x0011); if( patCurName != patPrevName || patCurID != patPrevID || first ) { @@ -980,7 +965,7 @@ void DicomDir::SetElements(std::string const & path, VectDocument const &list) * @param dst destination SQItem * @param src source SQItem */ -void DicomDir::MoveSQItem(SQItem *dst,SQItem *src) +void DicomDir::MoveSQItem(DocEntrySet *dst,DocEntrySet *src) { DocEntry *entry; @@ -995,7 +980,7 @@ void DicomDir::MoveSQItem(SQItem *dst,SQItem *src) } /** - * \brief compares two dgcmHeaders + * \brief compares two files */ bool DicomDir::HeaderLessThan(Document *header1, Document *header2) {