Program: gdcm
Module: $RCSfile: gdcmDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/01/24 14:14:10 $
- Version: $Revision: 1.115 $
+ 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
SetProgressMethod(NULL);
SetEndMethod(NULL);
- for(ListDicomDirPatient::iterator cc = Patients.begin();
- cc!= Patients.end();
- ++cc)
- {
- delete *cc;
- }
+ ClearPatient();
if ( MetaElems )
{
delete MetaElems;
DicomDirPatient *DicomDir::GetNextPatient()
{
gdcmAssertMacro (ItPatient != Patients.end());
- {
- ++ItPatient;
- if ( ItPatient != Patients.end() )
- return *ItPatient;
- }
+
+ ++ItPatient;
+ if ( ItPatient != Patients.end() )
+ return *ItPatient;
return NULL;
}
/**
* \brief adds *the* Meta to a partially created DICOMDIR
- */
-
+ */
DicomDirMeta *DicomDir::NewMeta()
{
if( MetaElems )
delete MetaElems;
- // friend class hunting : we miss GetLastEntry and GetPreviousEntry
- // to be able to remove any direct reference to TagHT
-
- DocEntry *e = GetFirstEntry();
- if (e)
- //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<SeqEntry *>(entry) )
+ break;
+
+ RemoveEntryNoDestroy(entry);
+ MetaElems->AddEntry(entry);
+
+ entry = GetFirstEntry();
}
}
else // after root directory parsing
}
/**
- * \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()
{
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
{
// 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
{
// neither an 'IMAGE' SQItem. Skip to next item.
continue;
}
-
- if( si )
- MoveSQItem(si,tmpSI);
tmpSI=s->GetNextSQItem();
}
// friend hunting : this one will be difficult to remove !
- TagHT.clear();
+ ClearEntry();
}
/**
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;
}
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;
}
*/
void DicomDir::SetElements(std::string const & path, VectDocument const &list)
{
- TagHT.clear();
- Patients.clear();
+ ClearEntry();
+ ClearPatient();
std::string patPrevName = "", patPrevID = "";
std::string studPrevInstanceUID = "", studPrevID = "";
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 )
{
* @param dst destination SQItem
* @param src source SQItem
*/
-void DicomDir::MoveSQItem(SQItem *dst,SQItem *src)
+void DicomDir::MoveSQItem(DocEntrySet *dst,DocEntrySet *src)
{
DocEntry *entry;