1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDir.cxx,v $
6 Date: $Date: 2006/05/30 08:10:19 $
7 Version: $Revision: 1.189 $
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)
148 DicomDir::DicomDir(std::string const &fileName, bool parseDir ):
151 // At this step, Document constructor is already executed,
152 // whatever user passed (either a root directory or a DICOMDIR)
153 // and whatever the value of parseDir was.
154 // (nothing is cheked in Document constructor, to avoid overhead)
157 SetLoadMode (LD_ALL); // concerns only dicom files
158 SetFileName( fileName );
165 * \brief Canonical destructor
167 DicomDir::~DicomDir()
176 //-----------------------------------------------------------------------------
180 * \brief Loader. use SetFileName(fn)
181 * or SetLoadMode(lm) + SetDirectoryName(dn) before !
182 * @return false if file cannot be open or no swap info was found,
183 * or no tag was found.
185 bool DicomDir::Load( )
189 if ( ! this->Document::Load( ) )
192 return DoTheLoadingJob( );
194 //#ifndef GDCM_LEGACY_REMOVE
196 * \brief Loader. (DEPRECATED : kept not to break the API)
197 * @param fileName file to be open for parsing
198 * @return false if file cannot be open or no swap info was found,
199 * or no tag was found.
200 * @deprecated use SetFileName(n) + Load() instead
203 bool DicomDir::Load(std::string const &fileName )
205 // We should clean out anything that already exists.
206 Initialize(); // sets all private fields to NULL
208 SetFileName( fileName );
211 if ( ! this->Document::Load( ) )
214 return DoTheLoadingJob( );
220 * \brief Does the Loading Job (internal use only)
221 * @return false if file cannot be open or no swap info was found,
222 * or no tag was found.
224 bool DicomDir::DoTheLoadingJob( )
231 // Only if user passed a DICOMDIR
232 // ------------------------------
234 if (!Document::Load() )
239 if ( GetFirstEntry() == 0 ) // when user passed a Directory to parse
241 gdcmWarningMacro( "Entry HT empty for file: "<< GetFileName());
244 // Directory record sequence
245 DocEntry *e = GetDocEntry(0x0004, 0x1220);
248 gdcmWarningMacro( "NO 'Directory record sequence' (0x0004,0x1220)"
249 << " in file " << GetFileName());
257 // Only if user passed a root directory
258 // ------------------------------------
259 if ( GetFileName() == "." )
261 // user passed '.' as Name
262 // we get current directory name
264 const char *cwd = getcwd(buf, 2048);
267 SetFileName( buf ); // will be converted into a string
271 gdcmErrorMacro( "Path was too long to fit on 2048 bytes" );
275 gdcmDebugMacro( "Parse directory and create the DicomDir : "
283 * \brief This predicate, based on hopefully reasonable heuristics,
284 * decides whether or not the current document was properly parsed
285 * and contains the mandatory information for being considered as
286 * a well formed and usable DicomDir.
287 * @return true when Document is the one of a reasonable DicomDir,
290 bool DicomDir::IsReadable()
292 if ( Filetype == Unknown )
294 gdcmErrorMacro( "Wrong filetype for " << GetFileName());
299 gdcmWarningMacro( "Meta Elements missing in DicomDir");
302 if ( Patients.size() <= 0 )
304 gdcmWarningMacro( "NO Patient in DicomDir");
312 * \brief adds *the* Meta to a partially created DICOMDIR
314 DicomDirMeta *DicomDir::NewMeta()
319 DocEntry *entry = GetFirstEntry();
322 MetaElems = DicomDirMeta::New(true); // true = empty
324 entry = GetFirstEntry();
327 if ( dynamic_cast<SeqEntry *>(entry) )
330 MetaElems->AddEntry(entry);
333 entry = GetFirstEntry();
336 else // after root directory parsing
338 MetaElems = DicomDirMeta::New(false); // false = not empty
340 MetaElems->SetSQItemNumber(0); // To avoid further missprinting
345 * \brief adds a new Patient (with the basic elements) to a partially created
348 DicomDirPatient *DicomDir::NewPatient()
350 DicomDirPatient *dd = DicomDirPatient::New();
351 AddPatientToEnd( dd );
356 * \brief Remove all Patients
358 void DicomDir::ClearPatient()
360 for(ListDicomDirPatient::iterator cc = Patients.begin();
370 * \brief Get the first entry while visiting the DicomDirPatients
371 * \return The first DicomDirPatient if found, otherwhise NULL
373 DicomDirPatient *DicomDir::GetFirstPatient()
375 ItPatient = Patients.begin();
376 if ( ItPatient != Patients.end() )
382 * \brief Get the next entry while visiting the DicomDirPatients
383 * \note : meaningfull only if GetFirstEntry already called
384 * \return The next DicomDirPatient if found, otherwhise NULL
386 DicomDirPatient *DicomDir::GetNextPatient()
388 gdcmAssertMacro (ItPatient != Patients.end());
391 if ( ItPatient != Patients.end() )
397 * \brief fills the whole structure, starting from a root Directory
399 void DicomDir::ParseDirectory()
401 CreateDicomDirChainedList( GetFileName() );
406 * \brief writes on disc a DICOMDIR
407 * \ warning does NOT add the missing elements in the header :
408 * it's up to the user doing it !
409 * @param fileName file to be written to
410 * @return false only when fail to open
413 bool DicomDir::Write(std::string const &fileName)
416 uint16_t sq[6] = { 0x0004, 0x1220, 0x5153, 0x0000, 0xffff, 0xffff };
417 uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0x0000, 0x0000 };
419 std::ofstream *fp = new std::ofstream(fileName.c_str(),
420 std::ios::out | std::ios::binary);
423 gdcmWarningMacro("Failed to open(write) File: " << fileName.c_str());
427 char filePreamble[128];
428 memset(filePreamble, 0, 128);
429 fp->write(filePreamble, 128);
430 binary_write( *fp, "DICM");
432 DicomDirMeta *ptrMeta = GetMeta();
433 ptrMeta->WriteContent(fp, ExplicitVR);
435 // force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta
438 binary_write(*fp, sq[i]);
441 for(ListDicomDirPatient::iterator cc = Patients.begin();
442 cc != Patients.end();
445 (*cc)->WriteContent( fp, ExplicitVR );
448 // force writing Sequence Delimitation Item
451 binary_write(*fp, sqt[i]); // fffe e0dd 0000 0000
461 * \brief Anonymize a DICOMDIR
465 bool DicomDir::Anonymize()
468 // Something clever to be found to forge the Patient names
469 std::ostringstream s;
471 for(ListDicomDirPatient::iterator cc = Patients.begin();
476 v = (*cc)->GetDataEntry(0x0010, 0x0010) ; // Patient's Name
479 v->SetString(s.str());
482 v = (*cc)->GetDataEntry(0x0010, 0x0020) ; // Patient ID
488 v = (*cc)->GetDataEntry(0x0010, 0x0030) ; // Patient's BirthDate
500 * \brief Copies all the attributes from an other DocEntrySet
501 * @param set entry to copy from
502 * @remarks The contained DocEntries are not copied, only referenced
504 void DicomDir::Copy(DocEntrySet *set)
506 // Remove all previous childs
511 DicomDir *dd = dynamic_cast<DicomDir *>(set);
515 MetaElems->Unregister();
516 MetaElems = dd->MetaElems;
518 MetaElems->Register();
520 Patients = dd->Patients;
521 for(ItPatient = Patients.begin();ItPatient != Patients.end();++ItPatient)
522 (*ItPatient)->Register();
526 //-----------------------------------------------------------------------------
529 * \brief create a Document-like chained list from a root Directory
530 * @param path entry point of the tree-like structure
532 void DicomDir::CreateDicomDirChainedList(std::string const &path)
535 DirList dirList(path,1); // gets recursively the file list
536 unsigned int count = 0;
540 DirListType fileList = dirList.GetFilenames();
541 unsigned int nbFile = fileList.size();
542 for( DirListType::iterator it = fileList.begin();
543 it != fileList.end();
546 Progress = (float)(count+1)/(float)nbFile;
547 CallProgressMethod();
554 f->SetLoadMode(LoadMode); // we allow user not to load Sequences,
555 // or Shadow groups, or ......
556 f->SetFileName( it->c_str() );
559 if ( f->IsReadable() )
561 // Add the file to the chained list:
563 gdcmDebugMacro( "Readable " << it->c_str() );
571 // sorts Patient/Study/Serie/
572 std::sort(list.begin(), list.end(), DicomDir::HeaderLessThan );
574 std::string tmp = dirList.GetDirName();
575 //for each File of the chained list, add/update the Patient/Study/Serie/Image info
576 SetElements(tmp, list);
579 for(VectDocument::iterator itDoc=list.begin();
583 dynamic_cast<File *>(*itDoc)->Delete();
588 //-----------------------------------------------------------------------------
591 * \brief Sets all fields to NULL
593 void DicomDir::Initialize()
602 * \brief create a 'gdcm::DicomDir' from a DICOMDIR Header
604 void DicomDir::CreateDicomDir()
606 // The SeqEntries of "Directory Record Sequence" are parsed.
607 // When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found :
608 // 1 - we save the beginning iterator
609 // 2 - we continue to parse
610 // 3 - we find an other tag
611 // + we create the object for the precedent tag
613 gdcmDebugMacro("Create DicomDir");
615 // Directory record sequence
616 DocEntry *e = GetDocEntry(0x0004, 0x1220);
619 gdcmWarningMacro( "No Directory Record Sequence (0004,1220) found");
623 SeqEntry *s = dynamic_cast<SeqEntry *>(e);
626 gdcmWarningMacro( "Element (0004,1220) is not a Sequence ?!?");
636 SQItem *tmpSI=s->GetFirstSQItem();
639 d = tmpSI->GetDocEntry(0x0004, 0x1430); // Directory Record Type
640 if ( DataEntry *dataEntry = dynamic_cast<DataEntry *>(d) )
642 v = dataEntry->GetString();
646 gdcmWarningMacro( "(0004,1430) not a DataEntry ?!?");
650 // A decent DICOMDIR has much more images than series,
651 // more series than studies, and so on.
652 // This is the right order to perform the tests
656 si = DicomDirImage::New(true);
657 if ( !AddImageToEnd( static_cast<DicomDirImage *>(si)) )
661 gdcmErrorMacro( "Add AddImageToEnd failed");
664 else if ( v == "SERIES" )
666 si = DicomDirSerie::New(true);
667 if ( !AddSerieToEnd( static_cast<DicomDirSerie *>(si)) )
671 gdcmErrorMacro( "Add AddSerieToEnd failed");
674 else if ( v == "VISIT " )
676 si = DicomDirVisit::New(true);
677 if ( !AddVisitToEnd( static_cast<DicomDirVisit *>(si)) )
681 gdcmErrorMacro( "Add AddVisitToEnd failed");
684 else if ( v == "STUDY " )
686 si = DicomDirStudy::New(true);
687 if ( !AddStudyToEnd( static_cast<DicomDirStudy *>(si)) )
691 gdcmErrorMacro( "Add AddStudyToEnd failed");
694 else if ( v == "PATIENT " )
696 si = DicomDirPatient::New(true);
697 if ( !AddPatientToEnd( static_cast<DicomDirPatient *>(si)) )
701 gdcmErrorMacro( "Add PatientToEnd failed");
706 // It was neither a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
707 // nor an 'IMAGE' SQItem. Skip to next item.
708 gdcmDebugMacro( " -------------------------------------------"
709 << "a non PATIENT/STUDY/SERIE/IMAGE SQItem was found : "
712 // FIXME : deal with other item types !
713 tmpSI=s->GetNextSQItem(); // To avoid infinite loop
719 tmpSI=s->GetNextSQItem();
725 * \brief AddPatientToEnd
726 * @param dd SQ Item to enqueue to the DicomPatient chained List
728 bool DicomDir::AddPatientToEnd(DicomDirPatient *dd)
730 Patients.push_back(dd);
735 * \brief AddStudyToEnd
736 * @param dd SQ Item to enqueue to the DicomDirStudy chained List
738 bool DicomDir::AddStudyToEnd(DicomDirStudy *dd)
740 if ( Patients.size() > 0 )
742 ListDicomDirPatient::iterator itp = Patients.end();
744 (*itp)->AddStudy(dd);
751 * \brief AddSerieToEnd
752 * @param dd SQ Item to enqueue to the DicomDirSerie chained List
754 bool DicomDir::AddSerieToEnd(DicomDirSerie *dd)
756 if ( Patients.size() > 0 )
758 ListDicomDirPatient::iterator itp = Patients.end();
761 DicomDirStudy *study = (*itp)->GetLastStudy();
772 * \brief AddVisitToEnd
773 * @param dd SQ Item to enqueue to the DicomDirVisit chained List
775 bool DicomDir::AddVisitToEnd(DicomDirVisit *dd)
777 if ( Patients.size() > 0 )
779 ListDicomDirPatient::iterator itp = Patients.end();
782 DicomDirStudy *study = (*itp)->GetLastStudy();
792 * \brief AddImageToEnd
793 * @param dd SQ Item to enqueue to the DicomDirImage chained List
795 bool DicomDir::AddImageToEnd(DicomDirImage *dd)
797 if ( Patients.size() > 0 )
799 ListDicomDirPatient::iterator itp = Patients.end();
802 DicomDirStudy *study = (*itp)->GetLastStudy();
805 DicomDirSerie *serie = study->GetLastSerie();
817 * \brief for each Header of the chained list,
818 * add/update the Patient/Study/Serie/Image info
819 * @param path path of the root directory
820 * @param list chained list of Headers
822 void DicomDir::SetElements(std::string const &path, VectDocument const &list)
827 std::string patPrevName = "", patPrevID = "";
828 std::string studPrevInstanceUID = "", studPrevID = "";
829 std::string serPrevInstanceUID = "", serPrevID = "";
831 std::string patCurName, patCurID;
832 std::string studCurInstanceUID, studCurID;
833 std::string serCurInstanceUID, serCurID;
836 for( VectDocument::const_iterator it = list.begin();
840 // get the current file characteristics
841 patCurName = (*it)->GetEntryString(0x0010,0x0010);
842 patCurID = (*it)->GetEntryString(0x0010,0x0011);
843 studCurInstanceUID = (*it)->GetEntryString(0x0020,0x000d);
844 studCurID = (*it)->GetEntryString(0x0020,0x0010);
845 serCurInstanceUID = (*it)->GetEntryString(0x0020,0x000e);
846 serCurID = (*it)->GetEntryString(0x0020,0x0011);
848 if ( patCurName != patPrevName || patCurID != patPrevID || first )
850 SetElement(path, GDCM_DICOMDIR_PATIENT, *it);
854 // if new Study, deal with 'STUDY' Elements
855 if ( studCurInstanceUID != studPrevInstanceUID || studCurID != studPrevID
858 SetElement(path, GDCM_DICOMDIR_STUDY, *it);
862 // if new Serie, deal with 'SERIE' Elements
863 if ( serCurInstanceUID != serPrevInstanceUID || serCurID != serPrevID
866 SetElement(path, GDCM_DICOMDIR_SERIE, *it);
869 // Always Deal with 'IMAGE' Elements
870 SetElement(path, GDCM_DICOMDIR_IMAGE, *it);
872 patPrevName = patCurName;
873 patPrevID = patCurID;
874 studPrevInstanceUID = studCurInstanceUID;
875 studPrevID = studCurID;
876 serPrevInstanceUID = serCurInstanceUID;
877 serPrevID = serCurID;
883 * \brief adds to the HTable
884 * the Entries (Dicom Elements) corresponding to the given type
885 * @param path full path file name (only used when type = GDCM_DICOMDIR_IMAGE
886 * @param type DicomDirObject type to create (GDCM_DICOMDIR_PATIENT,
887 * GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...)
888 * @param header Header of the current file
890 void DicomDir::SetElement(std::string const &path, DicomDirType type,
893 ListDicomDirElem elemList;
894 ListDicomDirElem::const_iterator it;
895 uint16_t tmpGr, tmpEl;
896 //DictEntry *dictEntry;
903 case GDCM_DICOMDIR_IMAGE:
904 elemList = Global::GetDicomDirElements()->GetDicomDirImageElements();
905 si = DicomDirImage::New(true);
906 if ( !AddImageToEnd(static_cast<DicomDirImage *>(si)) )
909 gdcmErrorMacro( "Add ImageToEnd failed");
912 case GDCM_DICOMDIR_SERIE:
913 elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements();
914 si = DicomDirSerie::New(true);
915 if ( !AddSerieToEnd(static_cast<DicomDirSerie *>(si)) )
918 gdcmErrorMacro( "Add SerieToEnd failed");
921 case GDCM_DICOMDIR_STUDY:
922 elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements();
923 si = DicomDirStudy::New(true);
924 if ( !AddStudyToEnd(static_cast<DicomDirStudy *>(si)) )
927 gdcmErrorMacro( "Add StudyToEnd failed");
930 case GDCM_DICOMDIR_PATIENT:
931 elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements();
932 si = DicomDirPatient::New(true);
933 if ( !AddPatientToEnd(static_cast<DicomDirPatient *>(si)) )
936 gdcmErrorMacro( "Add PatientToEnd failed");
939 case GDCM_DICOMDIR_META:
943 gdcmErrorMacro( "MetaElements already exist, they will be destroyed");
945 elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements();
946 MetaElems = DicomDirMeta::New(true);
953 // FIXME : troubles found when it's a SeqEntry
955 // removed all the seems-to-be-useless stuff about Referenced Image Sequence
956 // to avoid further troubles
957 // imageElem 0008 1140 "" // Referenced Image Sequence
958 // imageElem fffe e000 "" // 'no length' item : length to be set to 0xffffffff later
959 // imageElem 0008 1150 "" // Referenced SOP Class UID : to be set/forged later
960 // imageElem 0008 1155 "" // Referenced SOP Instance UID : to be set/forged later
961 // imageElem fffe e00d "" // Item delimitation : length to be set to ZERO later
963 std::string referencedVal;
964 // for all the relevant elements found in their own spot of the DicomDir.dic
965 for( it = elemList.begin(); it != elemList.end(); ++it)
969 //dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl);
970 //entry = DataEntry::New( dictEntry );
972 entry = DataEntry::New(tmpGr, tmpEl, GDCM_VRUNKNOWN); /// \todo : modify dicomelements file, to store VR
973 entry->SetOffset(0); // just to avoid further missprinting
977 // NULL when we Build Up (ex nihilo) a DICOMDIR
978 // or when we add the META elems
979 val = header->GetEntryString(tmpGr, tmpEl);
986 if ( val == GDCM_UNFOUND)
988 if ( tmpGr == 0x0004 ) // never present in File !
992 case 0x1130: // File-set ID
993 // force to the *end* File Name
994 val = Util::GetName( path );
997 case 0x1500: // Only used for image
998 if ( header->GetFileName().substr(0, path.length()) != path )
1000 gdcmWarningMacro( "The base path of file name is incorrect");
1001 val = header->GetFileName();
1005 // avoid the first '/' in File name !
1006 if ( header->GetFileName().c_str()[path.length()]
1007 == GDCM_FILESEPARATOR )
1008 val = &(header->GetFileName().c_str()[path.length()+1]);
1010 val = &(header->GetFileName().c_str()[path.length()]);
1014 case 0x1510: // Referenced SOP Class UID in File
1015 referencedVal = header->GetEntryString(0x0008, 0x0016);
1016 // FIXME : probabely something to check
1017 val = referencedVal;
1020 case 0x1511: // Referenced SOP Instance UID in File
1021 referencedVal = header->GetEntryString(0x0008, 0x0018);
1022 // FIXME : probabely something to check
1023 val = referencedVal;
1026 case 0x1512: // Referenced Transfer Syntax UID in File
1027 referencedVal = header->GetEntryString(0x0002, 0x0010);
1028 // FIXME : probabely something to check
1029 val = referencedVal;
1038 // If the entry is not found in the Header, don't write its 'value' in the DICOMDIR !
1045 if ( header->GetEntryLength(tmpGr,tmpEl) == 0 )
1048 // Don't polute the DICOMDIR with empty fields
1057 /* FIX later the pb of creating the 'Implementation Version Name'!
1059 if (val == GDCM_UNFOUND)
1062 if ( tmpGr == 0x0002 && tmpEl == 0x0013)
1064 // 'Implementation Version Name'
1065 std::string val = "GDCM ";
1066 val += Util::GetVersion();
1070 entry->SetString( val ); // troubles expected when vr=SQ ...
1072 if ( type == GDCM_DICOMDIR_META ) // fusible : should never print !
1074 gdcmDebugMacro("GDCM_DICOMDIR_META ?!? should never print that");
1077 si->AddEntry(entry);
1083 * \brief Move the content of the source SQItem to the destination SQItem
1084 * Only DocEntry's are moved
1085 * @param dst destination SQItem
1086 * @param src source SQItem
1088 void DicomDir::MoveSQItem(DocEntrySet *dst, DocEntrySet *src)
1091 // todo : rewrite the whole stuff, without using RemoveEntry an AddEntry,
1093 entry = src->GetFirstEntry();
1096 dst->AddEntry(entry); // use it, *before* removing it!
1097 src->RemoveEntry(entry);
1098 // we destroyed -> the current iterator is not longer valid
1099 entry = src->GetFirstEntry();
1104 * \brief compares two files
1106 bool DicomDir::HeaderLessThan(Document *header1, Document *header2)
1108 return *header1 < *header2;
1111 //-----------------------------------------------------------------------------
1114 * \brief Canonical Printer
1115 * @param os ostream we want to print in
1116 * @param indent Indentation string to be prepended during printing
1118 void DicomDir::Print(std::ostream &os, std::string const & )
1122 MetaElems->SetPrintLevel(PrintLevel);
1123 MetaElems->Print(os);
1125 for(ListDicomDirPatient::iterator cc = Patients.begin();
1126 cc != Patients.end();
1129 (*cc)->SetPrintLevel(PrintLevel);
1134 //-----------------------------------------------------------------------------
1135 } // end namespace gdcm