1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDir.cxx,v $
6 Date: $Date: 2006/02/16 20:06:13 $
7 Version: $Revision: 1.186 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 //-----------------------------------------------------------------------------
20 // For full DICOMDIR description, see:
21 // PS 3.3-2003, pages 731-750
22 //-----------------------------------------------------------------------------
23 #include "gdcmDicomDir.h"
24 #include "gdcmDicomDirObject.h"
25 #include "gdcmDicomDirStudy.h"
26 #include "gdcmDicomDirSerie.h"
27 #include "gdcmDicomDirVisit.h"
28 #include "gdcmDicomDirImage.h"
29 #include "gdcmDicomDirPatient.h"
30 #include "gdcmDicomDirMeta.h"
31 #include "gdcmDicomDirElement.h"
32 #include "gdcmDirList.h"
34 #include "gdcmDebug.h"
35 #include "gdcmGlobal.h"
37 #include "gdcmSeqEntry.h"
38 #include "gdcmSQItem.h"
39 #include "gdcmDataEntry.h"
40 #include "gdcmCommandManager.h"
45 #include <sys/types.h>
48 # define getcwd _getcwd
51 #if defined(_MSC_VER) || defined(__BORLANDC__)
57 #if defined(__BORLANDC__)
58 #include <mem.h> // for memset
61 // ----------------------------------------------------------------------------
62 // Note for future developpers
63 // ----------------------------------------------------------------------------
65 // Dicom PS 3.3 describes the relationship between Directory Records, as follow
66 // (see also PS 4.3, 2004, page 50 for Entity-Relationship model)
68 // Directory Record Type Directory Record Types which may be included
69 // in the next lower-level directory Entity
71 // (Root directory Entity) PATIENT, TOPIC, PRIVATE
73 // PATIENT STUDY, PRIVATE
75 // STUDY SERIES, VISIT, RESULTS, STUDY COMPONENT, PRIVATE
77 // SERIES IMAGE, OVERLAYS, MODALITY LUT, VOI LUT,
78 // CURVE, STORED PRINT, RT DOSE, RT STRUCTURE SET
79 // RT PLAN, RT TREAT RECORD, PRESENTATION, WAVEFORM,
80 // SR DOCUMENT, KEY OBJECT DOC, SPECTROSCOPY,
81 // RAW DATA, REGISTRATION, FIDUCIAL, PRIVATE,
104 // ----------------------
105 // The current gdcm version only deals with :
107 // (Root directory Entity) PATIENT
114 // DicomDir::CreateDicomDir will have to be completed
115 // Treelike structure management will have to be upgraded
116 // ----------------------------------------------------------------------------
120 //-----------------------------------------------------------------------------
121 // Constructor / Destructor
123 * \brief Constructor : creates an empty DicomDir
127 Initialize(); // sets all private fields to NULL
132 #ifndef GDCM_LEGACY_REMOVE
134 * \brief Constructor Parses recursively the directory and creates the DicomDir
135 * or uses an already built DICOMDIR, depending on 'parseDir' value.
136 * @param fileName name
137 * - of the root directory (parseDir = true)
138 * - of the DICOMDIR (parseDir = false)
139 * @param parseDir boolean
140 * - true if user passed an entry point
141 * and wants to explore recursively the directories
142 * - false if user passed an already built DICOMDIR file
143 * and wants to use it
144 * @deprecated use : new DicomDir() + [ SetLoadMode(lm) + ] SetDirectoryName(name)
145 * or : new DicomDir() + SetFileName(name)
147 DicomDir::DicomDir(std::string const &fileName, bool parseDir ):
150 // At this step, Document constructor is already executed,
151 // whatever user passed (either a root directory or a DICOMDIR)
152 // and whatever the value of parseDir was.
153 // (nothing is cheked in Document constructor, to avoid overhead)
156 SetLoadMode (LD_ALL); // concerns only dicom files
157 SetFileName( fileName );
163 * \brief Canonical destructor
165 DicomDir::~DicomDir()
174 //-----------------------------------------------------------------------------
178 * \brief Loader. use SetFileName(fn)
179 * or SetLoadMode(lm) + SetDirectoryName(dn) before !
180 * @return false if file cannot be open or no swap info was found,
181 * or no tag was found.
183 bool DicomDir::Load( )
187 if ( ! this->Document::Load( ) )
190 return DoTheLoadingJob( );
192 #ifndef GDCM_LEGACY_REMOVE
194 * \brief Loader. (DEPRECATED : kept not to break the API)
195 * @param fileName file to be open for parsing
196 * @return false if file cannot be open or no swap info was found,
197 * or no tag was found.
198 * @deprecated use SetFileName(n) + Load() instead
200 bool DicomDir::Load(std::string const &fileName )
202 // We should clean out anything that already exists.
203 Initialize(); // sets all private fields to NULL
205 SetFileName( fileName );
208 if ( ! this->Document::Load( ) )
211 return DoTheLoadingJob( );
216 * \brief Does the Loading Job (internal use only)
217 * @return false if file cannot be open or no swap info was found,
218 * or no tag was found.
220 bool DicomDir::DoTheLoadingJob( )
227 // Only if user passed a DICOMDIR
228 // ------------------------------
230 if (!Document::Load() )
235 if ( GetFirstEntry() == 0 ) // when user passed a Directory to parse
237 gdcmWarningMacro( "Entry HT empty for file: "<< GetFileName());
240 // Directory record sequence
241 DocEntry *e = GetDocEntry(0x0004, 0x1220);
244 gdcmWarningMacro( "NO 'Directory record sequence' (0x0004,0x1220)"
245 << " in file " << GetFileName());
253 // Only if user passed a root directory
254 // ------------------------------------
255 if ( GetFileName() == "." )
257 // user passed '.' as Name
258 // we get current directory name
260 const char *cwd = getcwd(buf, 2048);
263 SetFileName( buf ); // will be converted into a string
267 gdcmErrorMacro( "Path was too long to fit on 2048 bytes" );
271 gdcmDebugMacro( "Parse directory and create the DicomDir : "
279 * \brief This predicate, based on hopefully reasonable heuristics,
280 * decides whether or not the current document was properly parsed
281 * and contains the mandatory information for being considered as
282 * a well formed and usable DicomDir.
283 * @return true when Document is the one of a reasonable DicomDir,
286 bool DicomDir::IsReadable()
288 if ( Filetype == Unknown )
290 gdcmErrorMacro( "Wrong filetype for " << GetFileName());
295 gdcmWarningMacro( "Meta Elements missing in DicomDir");
298 if ( Patients.size() <= 0 )
300 gdcmWarningMacro( "NO Patient in DicomDir");
308 * \brief adds *the* Meta to a partially created DICOMDIR
310 DicomDirMeta *DicomDir::NewMeta()
315 DocEntry *entry = GetFirstEntry();
318 MetaElems = DicomDirMeta::New(true); // true = empty
320 entry = GetFirstEntry();
323 if ( dynamic_cast<SeqEntry *>(entry) )
326 MetaElems->AddEntry(entry);
329 entry = GetFirstEntry();
332 else // after root directory parsing
334 MetaElems = DicomDirMeta::New(false); // false = not empty
336 MetaElems->SetSQItemNumber(0); // To avoid further missprinting
341 * \brief adds a new Patient (with the basic elements) to a partially created
344 DicomDirPatient *DicomDir::NewPatient()
346 DicomDirPatient *dd = DicomDirPatient::New();
347 AddPatientToEnd( dd );
352 * \brief Remove all Patients
354 void DicomDir::ClearPatient()
356 for(ListDicomDirPatient::iterator cc = Patients.begin();
366 * \brief Get the first entry while visiting the DicomDirPatients
367 * \return The first DicomDirPatient if found, otherwhise NULL
369 DicomDirPatient *DicomDir::GetFirstPatient()
371 ItPatient = Patients.begin();
372 if ( ItPatient != Patients.end() )
378 * \brief Get the next entry while visiting the DicomDirPatients
379 * \note : meaningfull only if GetFirstEntry already called
380 * \return The next DicomDirPatient if found, otherwhise NULL
382 DicomDirPatient *DicomDir::GetNextPatient()
384 gdcmAssertMacro (ItPatient != Patients.end());
387 if ( ItPatient != Patients.end() )
393 * \brief fills the whole structure, starting from a root Directory
395 void DicomDir::ParseDirectory()
397 CreateDicomDirChainedList( GetFileName() );
402 * \brief writes on disc a DICOMDIR
403 * \ warning does NOT add the missing elements in the header :
404 * it's up to the user doing it !
405 * @param fileName file to be written to
406 * @return false only when fail to open
409 bool DicomDir::Write(std::string const &fileName)
412 uint16_t sq[6] = { 0x0004, 0x1220, 0x5153, 0x0000, 0xffff, 0xffff };
413 uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0x0000, 0x0000 };
415 std::ofstream *fp = new std::ofstream(fileName.c_str(),
416 std::ios::out | std::ios::binary);
419 gdcmWarningMacro("Failed to open(write) File: " << fileName.c_str());
423 char filePreamble[128];
424 memset(filePreamble, 0, 128);
425 fp->write(filePreamble, 128);
426 binary_write( *fp, "DICM");
428 DicomDirMeta *ptrMeta = GetMeta();
429 ptrMeta->WriteContent(fp, ExplicitVR);
431 // force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta
434 binary_write(*fp, sq[i]);
437 for(ListDicomDirPatient::iterator cc = Patients.begin();
438 cc != Patients.end();
441 (*cc)->WriteContent( fp, ExplicitVR );
444 // force writing Sequence Delimitation Item
447 binary_write(*fp, sqt[i]); // fffe e0dd 0000 0000
457 * \brief Anonymize a DICOMDIR
461 bool DicomDir::Anonymize()
464 // Something clever to be found to forge the Patient names
465 std::ostringstream s;
467 for(ListDicomDirPatient::iterator cc = Patients.begin();
472 v = (*cc)->GetDataEntry(0x0010, 0x0010) ; // Patient's Name
475 v->SetString(s.str());
478 v = (*cc)->GetDataEntry(0x0010, 0x0020) ; // Patient ID
484 v = (*cc)->GetDataEntry(0x0010, 0x0030) ; // Patient's BirthDate
496 * \brief Copies all the attributes from an other DocEntrySet
497 * @param set entry to copy from
498 * @remarks The contained DocEntries are not copied, only referenced
500 void DicomDir::Copy(DocEntrySet *set)
502 // Remove all previous childs
507 DicomDir *dd = dynamic_cast<DicomDir *>(set);
511 MetaElems->Unregister();
512 MetaElems = dd->MetaElems;
514 MetaElems->Register();
516 Patients = dd->Patients;
517 for(ItPatient = Patients.begin();ItPatient != Patients.end();++ItPatient)
518 (*ItPatient)->Register();
522 //-----------------------------------------------------------------------------
525 * \brief create a Document-like chained list from a root Directory
526 * @param path entry point of the tree-like structure
528 void DicomDir::CreateDicomDirChainedList(std::string const &path)
531 DirList dirList(path,1); // gets recursively the file list
532 unsigned int count = 0;
536 DirListType fileList = dirList.GetFilenames();
537 unsigned int nbFile = fileList.size();
538 for( DirListType::iterator it = fileList.begin();
539 it != fileList.end();
542 Progress = (float)(count+1)/(float)nbFile;
543 CallProgressMethod();
550 f->SetLoadMode(LoadMode); // we allow user not to load Sequences,
551 // or Shadow groups, or ......
552 f->SetFileName( it->c_str() );
555 if ( f->IsReadable() )
557 // Add the file to the chained list:
559 gdcmDebugMacro( "Readable " << it->c_str() );
567 // sorts Patient/Study/Serie/
568 std::sort(list.begin(), list.end(), DicomDir::HeaderLessThan );
570 std::string tmp = dirList.GetDirName();
571 //for each File of the chained list, add/update the Patient/Study/Serie/Image info
572 SetElements(tmp, list);
575 for(VectDocument::iterator itDoc=list.begin();
579 dynamic_cast<File *>(*itDoc)->Delete();
584 //-----------------------------------------------------------------------------
587 * \brief Sets all fields to NULL
589 void DicomDir::Initialize()
598 * \brief create a 'gdcm::DicomDir' from a DICOMDIR Header
600 void DicomDir::CreateDicomDir()
602 // The SeqEntries of "Directory Record Sequence" are parsed.
603 // When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found :
604 // 1 - we save the beginning iterator
605 // 2 - we continue to parse
606 // 3 - we find an other tag
607 // + we create the object for the precedent tag
609 gdcmDebugMacro("Create DicomDir");
611 // Directory record sequence
612 DocEntry *e = GetDocEntry(0x0004, 0x1220);
615 gdcmWarningMacro( "No Directory Record Sequence (0004,1220) found");
619 SeqEntry *s = dynamic_cast<SeqEntry *>(e);
622 gdcmWarningMacro( "Element (0004,1220) is not a Sequence ?!?");
632 SQItem *tmpSI=s->GetFirstSQItem();
635 d = tmpSI->GetDocEntry(0x0004, 0x1430); // Directory Record Type
636 if ( DataEntry *dataEntry = dynamic_cast<DataEntry *>(d) )
638 v = dataEntry->GetString();
642 gdcmWarningMacro( "(0004,1430) not a DataEntry ?!?");
646 // A decent DICOMDIR has much more images than series,
647 // more series than studies, and so on.
648 // This is the right order to perform the tests
652 si = DicomDirImage::New(true);
653 if ( !AddImageToEnd( static_cast<DicomDirImage *>(si)) )
657 gdcmErrorMacro( "Add AddImageToEnd failed");
660 else if ( v == "SERIES" )
662 si = DicomDirSerie::New(true);
663 if ( !AddSerieToEnd( static_cast<DicomDirSerie *>(si)) )
667 gdcmErrorMacro( "Add AddSerieToEnd failed");
670 else if ( v == "VISIT " )
672 si = DicomDirVisit::New(true);
673 if ( !AddVisitToEnd( static_cast<DicomDirVisit *>(si)) )
677 gdcmErrorMacro( "Add AddVisitToEnd failed");
680 else if ( v == "STUDY " )
682 si = DicomDirStudy::New(true);
683 if ( !AddStudyToEnd( static_cast<DicomDirStudy *>(si)) )
687 gdcmErrorMacro( "Add AddStudyToEnd failed");
690 else if ( v == "PATIENT " )
692 si = DicomDirPatient::New(true);
693 if ( !AddPatientToEnd( static_cast<DicomDirPatient *>(si)) )
697 gdcmErrorMacro( "Add PatientToEnd failed");
702 // It was neither a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
703 // nor an 'IMAGE' SQItem. Skip to next item.
704 gdcmDebugMacro( " -------------------------------------------"
705 << "a non PATIENT/STUDY/SERIE/IMAGE SQItem was found : "
708 // FIXME : deal with other item types !
709 tmpSI=s->GetNextSQItem(); // To avoid infinite loop
715 tmpSI=s->GetNextSQItem();
721 * \brief AddPatientToEnd
722 * @param dd SQ Item to enqueue to the DicomPatient chained List
724 bool DicomDir::AddPatientToEnd(DicomDirPatient *dd)
726 Patients.push_back(dd);
731 * \brief AddStudyToEnd
732 * @param dd SQ Item to enqueue to the DicomDirStudy chained List
734 bool DicomDir::AddStudyToEnd(DicomDirStudy *dd)
736 if ( Patients.size() > 0 )
738 ListDicomDirPatient::iterator itp = Patients.end();
740 (*itp)->AddStudy(dd);
747 * \brief AddSerieToEnd
748 * @param dd SQ Item to enqueue to the DicomDirSerie chained List
750 bool DicomDir::AddSerieToEnd(DicomDirSerie *dd)
752 if ( Patients.size() > 0 )
754 ListDicomDirPatient::iterator itp = Patients.end();
757 DicomDirStudy *study = (*itp)->GetLastStudy();
768 * \brief AddVisitToEnd
769 * @param dd SQ Item to enqueue to the DicomDirVisit chained List
771 bool DicomDir::AddVisitToEnd(DicomDirVisit *dd)
773 if ( Patients.size() > 0 )
775 ListDicomDirPatient::iterator itp = Patients.end();
778 DicomDirStudy *study = (*itp)->GetLastStudy();
788 * \brief AddImageToEnd
789 * @param dd SQ Item to enqueue to the DicomDirImage chained List
791 bool DicomDir::AddImageToEnd(DicomDirImage *dd)
793 if ( Patients.size() > 0 )
795 ListDicomDirPatient::iterator itp = Patients.end();
798 DicomDirStudy *study = (*itp)->GetLastStudy();
801 DicomDirSerie *serie = study->GetLastSerie();
813 * \brief for each Header of the chained list,
814 * add/update the Patient/Study/Serie/Image info
815 * @param path path of the root directory
816 * @param list chained list of Headers
818 void DicomDir::SetElements(std::string const &path, VectDocument const &list)
823 std::string patPrevName = "", patPrevID = "";
824 std::string studPrevInstanceUID = "", studPrevID = "";
825 std::string serPrevInstanceUID = "", serPrevID = "";
827 std::string patCurName, patCurID;
828 std::string studCurInstanceUID, studCurID;
829 std::string serCurInstanceUID, serCurID;
832 for( VectDocument::const_iterator it = list.begin();
836 // get the current file characteristics
837 patCurName = (*it)->GetEntryString(0x0010,0x0010);
838 patCurID = (*it)->GetEntryString(0x0010,0x0011);
839 studCurInstanceUID = (*it)->GetEntryString(0x0020,0x000d);
840 studCurID = (*it)->GetEntryString(0x0020,0x0010);
841 serCurInstanceUID = (*it)->GetEntryString(0x0020,0x000e);
842 serCurID = (*it)->GetEntryString(0x0020,0x0011);
844 if ( patCurName != patPrevName || patCurID != patPrevID || first )
846 SetElement(path, GDCM_DICOMDIR_PATIENT, *it);
850 // if new Study, deal with 'STUDY' Elements
851 if ( studCurInstanceUID != studPrevInstanceUID || studCurID != studPrevID
854 SetElement(path, GDCM_DICOMDIR_STUDY, *it);
858 // if new Serie, deal with 'SERIE' Elements
859 if ( serCurInstanceUID != serPrevInstanceUID || serCurID != serPrevID
862 SetElement(path, GDCM_DICOMDIR_SERIE, *it);
865 // Always Deal with 'IMAGE' Elements
866 SetElement(path, GDCM_DICOMDIR_IMAGE, *it);
868 patPrevName = patCurName;
869 patPrevID = patCurID;
870 studPrevInstanceUID = studCurInstanceUID;
871 studPrevID = studCurID;
872 serPrevInstanceUID = serCurInstanceUID;
873 serPrevID = serCurID;
879 * \brief adds to the HTable
880 * the Entries (Dicom Elements) corresponding to the given type
881 * @param path full path file name (only used when type = GDCM_DICOMDIR_IMAGE
882 * @param type DicomDirObject type to create (GDCM_DICOMDIR_PATIENT,
883 * GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...)
884 * @param header Header of the current file
886 void DicomDir::SetElement(std::string const &path, DicomDirType type,
889 ListDicomDirElem elemList;
890 ListDicomDirElem::const_iterator it;
891 uint16_t tmpGr, tmpEl;
892 DictEntry *dictEntry;
899 case GDCM_DICOMDIR_IMAGE:
900 elemList = Global::GetDicomDirElements()->GetDicomDirImageElements();
901 si = DicomDirImage::New(true);
902 if ( !AddImageToEnd(static_cast<DicomDirImage *>(si)) )
905 gdcmErrorMacro( "Add ImageToEnd failed");
908 case GDCM_DICOMDIR_SERIE:
909 elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements();
910 si = DicomDirSerie::New(true);
911 if ( !AddSerieToEnd(static_cast<DicomDirSerie *>(si)) )
914 gdcmErrorMacro( "Add SerieToEnd failed");
917 case GDCM_DICOMDIR_STUDY:
918 elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements();
919 si = DicomDirStudy::New(true);
920 if ( !AddStudyToEnd(static_cast<DicomDirStudy *>(si)) )
923 gdcmErrorMacro( "Add StudyToEnd failed");
926 case GDCM_DICOMDIR_PATIENT:
927 elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements();
928 si = DicomDirPatient::New(true);
929 if ( !AddPatientToEnd(static_cast<DicomDirPatient *>(si)) )
932 gdcmErrorMacro( "Add PatientToEnd failed");
935 case GDCM_DICOMDIR_META:
939 gdcmErrorMacro( "MetaElements already exist, they will be destroyed");
941 elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements();
942 MetaElems = DicomDirMeta::New(true);
949 // FIXME : troubles found when it's a SeqEntry
951 // removed all the seems-to-be-useless stuff about Referenced Image Sequence
952 // to avoid further troubles
953 // imageElem 0008 1140 "" // Referenced Image Sequence
954 // imageElem fffe e000 "" // 'no length' item : length to be set to 0xffffffff later
955 // imageElem 0008 1150 "" // Referenced SOP Class UID : to be set/forged later
956 // imageElem 0008 1155 "" // Referenced SOP Instance UID : to be set/forged later
957 // imageElem fffe e00d "" // Item delimitation : length to be set to ZERO later
959 std::string referencedVal;
960 // for all the relevant elements found in their own spot of the DicomDir.dic
961 for( it = elemList.begin(); it != elemList.end(); ++it)
965 dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl);
967 entry = DataEntry::New( dictEntry );
968 entry->SetOffset(0); // just to avoid further missprinting
972 // NULL when we Build Up (ex nihilo) a DICOMDIR
973 // or when we add the META elems
974 val = header->GetEntryString(tmpGr, tmpEl);
981 if ( val == GDCM_UNFOUND)
983 if ( tmpGr == 0x0004 ) // never present in File !
987 case 0x1130: // File-set ID
988 // force to the *end* File Name
989 val = Util::GetName( path );
992 case 0x1500: // Only used for image
993 if ( header->GetFileName().substr(0, path.length()) != path )
995 gdcmWarningMacro( "The base path of file name is incorrect");
996 val = header->GetFileName();
1000 // avoid the first '/' in File name !
1001 if ( header->GetFileName().c_str()[path.length()]
1002 == GDCM_FILESEPARATOR )
1003 val = &(header->GetFileName().c_str()[path.length()+1]);
1005 val = &(header->GetFileName().c_str()[path.length()]);
1009 case 0x1510: // Referenced SOP Class UID in File
1010 referencedVal = header->GetEntryString(0x0008, 0x0016);
1011 // FIXME : probabely something to check
1012 val = referencedVal;
1015 case 0x1511: // Referenced SOP Instance UID in File
1016 referencedVal = header->GetEntryString(0x0008, 0x0018);
1017 // FIXME : probabely something to check
1018 val = referencedVal;
1021 case 0x1512: // Referenced Transfer Syntax UID in File
1022 referencedVal = header->GetEntryString(0x0002, 0x0010);
1023 // FIXME : probabely something to check
1024 val = referencedVal;
1033 // If the entry is not found in the Header, don't write its 'value' in the DICOMDIR !
1040 if ( header->GetEntryLength(tmpGr,tmpEl) == 0 )
1043 // Don't polute the DICOMDIR with empty fields
1052 /* FIX later the pb of creating the 'Implementation Version Name'!
1054 if (val == GDCM_UNFOUND)
1057 if ( tmpGr == 0x0002 && tmpEl == 0x0013)
1059 // 'Implementation Version Name'
1060 std::string val = "GDCM ";
1061 val += Util::GetVersion();
1065 entry->SetString( val ); // troubles expected when vr=SQ ...
1067 if ( type == GDCM_DICOMDIR_META ) // fusible : should never print !
1069 gdcmDebugMacro("GDCM_DICOMDIR_META ?!? should never print that");
1072 si->AddEntry(entry);
1078 * \brief Move the content of the source SQItem to the destination SQItem
1079 * Only DocEntry's are moved
1080 * @param dst destination SQItem
1081 * @param src source SQItem
1083 void DicomDir::MoveSQItem(DocEntrySet *dst, DocEntrySet *src)
1086 // todo : rewrite the whole stuff, without using RemoveEntry an AddEntry,
1088 entry = src->GetFirstEntry();
1091 dst->AddEntry(entry); // use it, *before* removing it!
1092 src->RemoveEntry(entry);
1093 // we destroyed -> the current iterator is not longer valid
1094 entry = src->GetFirstEntry();
1099 * \brief compares two files
1101 bool DicomDir::HeaderLessThan(Document *header1, Document *header2)
1103 return *header1 < *header2;
1106 //-----------------------------------------------------------------------------
1109 * \brief Canonical Printer
1110 * @param os ostream we want to print in
1111 * @param indent Indentation string to be prepended during printing
1113 void DicomDir::Print(std::ostream &os, std::string const & )
1117 MetaElems->SetPrintLevel(PrintLevel);
1118 MetaElems->Print(os);
1120 for(ListDicomDirPatient::iterator cc = Patients.begin();
1121 cc != Patients.end();
1124 (*cc)->SetPrintLevel(PrintLevel);
1129 //-----------------------------------------------------------------------------
1130 } // end namespace gdcm