1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDir.cxx,v $
6 Date: $Date: 2005/10/25 14:52:33 $
7 Version: $Revision: 1.167 $
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"
44 #include <sys/types.h>
47 # define getcwd _getcwd
50 #if defined(_MSC_VER) || defined(__BORLANDC__)
55 // ----------------------------------------------------------------------------
56 // Note for future developpers
57 // ----------------------------------------------------------------------------
59 // Dicom PS 3.3 describes the relationship between Directory Records, as follow
60 // (see also PS 4.3, 2004, page 50 for Entity-Relationship model)
62 // Directory Record Type Directory Record Types which may be included
63 // in the next lower-level directory Entity
65 // (Root directory Entity) PATIENT, TOPIC, PRIVATE
67 // PATIENT STUDY, PRIVATE
69 // STUDY SERIES, VISIT, RESULTS, STUDY COMPONENT, PRIVATE
71 // SERIES IMAGE, OVERLAYS, MODALITY LUT, VOI LUT,
72 // CURVE, STORED PRINT, RT DOSE, RT STRUCTURE SET
73 // RT PLAN, RT TREAT RECORD, PRESENTATION, WAVEFORM,
74 // SR DOCUMENT, KEY OBJECT DOC, SPECTROSCOPY,
75 // RAW DATA, REGISTRATION, FIDUCIAL, PRIVATE,
98 // ----------------------
99 // The current gdcm version only deals with :
101 // (Root directory Entity) PATIENT
108 // DicomDir::CreateDicomDir will have to be completed
109 // Treelike structure management will have to be upgraded
110 // ----------------------------------------------------------------------------
114 //-----------------------------------------------------------------------------
115 // Constructor / Destructor
117 * \brief Constructor : creates an empty DicomDir
122 Initialize(); // sets all private fields to NULL
128 * \brief Canonical destructor
130 DicomDir::~DicomDir()
132 SetStartMethod(NULL,NULL,NULL);
133 SetProgressMethod(NULL,NULL,NULL);
134 SetEndMethod(NULL,NULL,NULL);
143 //-----------------------------------------------------------------------------
147 * \brief Loader. use SetFileName(fn)
148 * or SetLoadMode(lm) + SetDirectoryName(dn) before !
149 * @return false if file cannot be open or no swap info was found,
150 * or no tag was found.
152 bool DicomDir::Load( )
156 if ( ! this->Document::Load( ) )
159 return DoTheLoadingJob( );
162 #ifndef GDCM_LEGACY_REMOVE
164 * \ brief Loader. (DEPRECATED : kept not to break the API)
165 * @ param fileName file to be open for parsing
166 * @ return false if file cannot be open or no swap info was found,
167 * or no tag was found.
168 * @ deprecated use SetFileName(n) + Load() instead
170 bool DicomDir::Load(std::string const &fileName )
172 SetFileName(fileName);
176 /// DEPRECATED : use SetDirectoryName(dname) instead
178 * \brief Loader. (DEPRECATED : kept not to break the API)
179 * @param paseDir Parse Dir
180 * @deprecated use SetDirectoryName(dname) instead
182 void DicomDir::SetParseDir(bool parseDir)
189 * \brief Does the Loading Job (internal use only)
190 * @return false if file cannot be open or no swap info was found,
191 * or no tag was found.
193 bool DicomDir::DoTheLoadingJob( )
200 // Only if user passed a DICOMDIR
201 // ------------------------------
203 if (!Document::Load() )
208 if ( GetFirstEntry() == 0 ) // when user passed a Directory to parse
210 gdcmWarningMacro( "Entry HT empty for file: "<< GetFileName());
213 // Directory record sequence
214 DocEntry *e = GetDocEntry(0x0004, 0x1220);
217 gdcmWarningMacro( "NO 'Directory record sequence' (0x0004,0x1220)"
218 << " in file " << GetFileName());
226 // Only if user passed a root directory
227 // ------------------------------------
228 if ( GetFileName() == "." )
230 // user passed '.' as Name
231 // we get current directory name
233 getcwd(dummy, (size_t)1000);
234 SetFileName( dummy ); // will be converted into a string
237 gdcmWarningMacro( "Parse directory and create the DicomDir : "
245 * \brief This predicate, based on hopefully reasonable heuristics,
246 * decides whether or not the current document was properly parsed
247 * and contains the mandatory information for being considered as
248 * a well formed and usable DicomDir.
249 * @return true when Document is the one of a reasonable DicomDir,
252 bool DicomDir::IsReadable()
254 if ( Filetype == Unknown )
256 gdcmWarningMacro( "Wrong filetype");
261 gdcmWarningMacro( "Meta Elements missing in DicomDir");
264 if ( Patients.size() <= 0 )
266 gdcmWarningMacro( "NO Patient in DicomDir");
274 * \brief adds *the* Meta to a partially created DICOMDIR
276 DicomDirMeta *DicomDir::NewMeta()
281 DocEntry *entry = GetFirstEntry();
284 MetaElems = DicomDirMeta::New(true); // true = empty
286 entry = GetFirstEntry();
289 if ( dynamic_cast<SeqEntry *>(entry) )
292 MetaElems->AddEntry(entry);
295 entry = GetFirstEntry();
298 else // after root directory parsing
300 MetaElems = DicomDirMeta::New(false); // false = not empty
302 MetaElems->SetSQItemNumber(0); // To avoid further missprinting
307 * \brief adds a new Patient (with the basic elements) to a partially created
310 DicomDirPatient *DicomDir::NewPatient()
312 DicomDirPatient *dd = DicomDirPatient::New();
313 AddPatientToEnd( dd );
318 * \brief Remove all Patients
320 void DicomDir::ClearPatient()
322 for(ListDicomDirPatient::iterator cc = Patients.begin();
332 * \brief Get the first entry while visiting the DicomDirPatients
333 * \return The first DicomDirPatient if found, otherwhise NULL
335 DicomDirPatient *DicomDir::GetFirstPatient()
337 ItPatient = Patients.begin();
338 if ( ItPatient != Patients.end() )
344 * \brief Get the next entry while visiting the DicomDirPatients
345 * \note : meaningfull only if GetFirstEntry already called
346 * \return The next DicomDirPatient if found, otherwhise NULL
348 DicomDirPatient *DicomDir::GetNextPatient()
350 gdcmAssertMacro (ItPatient != Patients.end());
353 if ( ItPatient != Patients.end() )
359 * \brief fills the whole structure, starting from a root Directory
361 void DicomDir::ParseDirectory()
363 CreateDicomDirChainedList( GetFileName() );
367 void DicomDir::SetStartMethod( DicomDir::Method *method, void *arg )
369 SetStartMethod(method,arg,NULL);
372 void DicomDir::SetProgressMethod( DicomDir::Method *method, void *arg )
374 SetProgressMethod(method,arg,NULL);
377 void DicomDir::SetEndMethod( DicomDir::Method *method, void *arg )
379 SetEndMethod(method,arg,NULL);
383 * \brief Set the start method to call when the parsing of the
385 * @param method Method to call
386 * @param arg Argument to pass to the method
387 * @param argDelete Argument
388 * \warning In python : the arg parameter isn't considered
390 void DicomDir::SetStartMethod( DicomDir::Method *method, void *arg,
391 DicomDir::Method *argDelete )
393 if ( StartArg && StartMethodArgDelete )
395 StartMethodArgDelete( StartArg );
398 StartMethod = method;
400 StartMethodArgDelete = argDelete;
405 * \brief Set the progress method to call when the parsing of the
407 * @param method Method to call
408 * @param arg Argument to pass to the method
409 * @param argDelete Argument
410 * \warning In python : the arg parameter isn't considered
412 void DicomDir::SetProgressMethod( DicomDir::Method *method, void *arg,
413 DicomDir::Method *argDelete )
415 if ( ProgressArg && ProgressMethodArgDelete )
417 ProgressMethodArgDelete( ProgressArg );
420 ProgressMethod = method;
422 ProgressMethodArgDelete = argDelete;
426 * \brief Set the end method to call when the parsing of the directory ends
427 * @param method Method to call
428 * @param arg Argument to pass to the method
429 * @param argDelete Argument
430 * \warning In python : the arg parameter isn't considered
432 void DicomDir::SetEndMethod( DicomDir::Method *method, void *arg,
433 DicomDir::Method *argDelete )
435 if ( EndArg && EndMethodArgDelete )
437 EndMethodArgDelete( EndArg );
442 EndMethodArgDelete = argDelete;
446 * \brief Set the method to delete the argument
447 * The argument is destroyed when the method is changed or when the
449 * @param method Method to call to delete the argument
451 void DicomDir::SetStartMethodArgDelete( DicomDir::Method *method )
453 StartMethodArgDelete = method;
457 * \brief Set the method to delete the argument
458 * The argument is destroyed when the method is changed or when the
460 * @param method Method to call to delete the argument
462 void DicomDir::SetProgressMethodArgDelete( DicomDir::Method *method )
464 ProgressMethodArgDelete = method;
468 * \brief Set the method to delete the argument
469 * The argument is destroyed when the method is changed or when
470 * the class is destroyed
471 * @param method Method to call to delete the argument
473 void DicomDir::SetEndMethodArgDelete( DicomDir::Method *method )
475 EndMethodArgDelete = method;
479 * \brief writes on disc a DICOMDIR
480 * \ warning does NOT add the missing elements in the header :
481 * it's up to the user doing it !
482 * @param fileName file to be written to
483 * @return false only when fail to open
486 bool DicomDir::Write(std::string const &fileName)
489 uint16_t sq[4] = { 0x0004, 0x1220, 0xffff, 0xffff };
490 uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0xffff, 0xffff };
492 std::ofstream *fp = new std::ofstream(fileName.c_str(),
493 std::ios::out | std::ios::binary);
496 gdcmWarningMacro("Failed to open(write) File: " << fileName.c_str());
500 char filePreamble[128];
501 memset(filePreamble, 0, 128);
502 fp->write(filePreamble, 128);
503 binary_write( *fp, "DICM");
505 DicomDirMeta *ptrMeta = GetMeta();
506 ptrMeta->WriteContent(fp, ExplicitVR);
508 // force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta
511 binary_write(*fp, sq[i]);
514 for(ListDicomDirPatient::iterator cc = Patients.begin();
515 cc != Patients.end();
518 (*cc)->WriteContent( fp, ExplicitVR );
521 // force writing Sequence Delimitation Item
524 binary_write(*fp, sqt[i]); // fffe e0dd ffff ffff
534 * \brief Anonymize a DICOMDIR
538 bool DicomDir::Anonymize()
541 // Something clever to be found to forge the Patient names
542 std::ostringstream s;
544 for(ListDicomDirPatient::iterator cc = Patients.begin();
549 v = (*cc)->GetDataEntry(0x0010, 0x0010) ; // Patient's Name
552 v->SetString(s.str());
555 v = (*cc)->GetDataEntry(0x0010, 0x0020) ; // Patient ID
561 v = (*cc)->GetDataEntry(0x0010, 0x0030) ; // Patient's BirthDate
572 //-----------------------------------------------------------------------------
575 * \brief create a Document-like chained list from a root Directory
576 * @param path entry point of the tree-like structure
578 void DicomDir::CreateDicomDirChainedList(std::string const &path)
581 DirList dirList(path,1); // gets recursively the file list
582 unsigned int count = 0;
586 DirListType fileList = dirList.GetFilenames();
588 for( DirListType::iterator it = fileList.begin();
589 it != fileList.end();
592 Progress = (float)(count+1)/(float)fileList.size();
593 CallProgressMethod();
600 f->SetLoadMode(LoadMode); // we allow user not to load Sequences, or Shadow
602 f->SetFileName( it->c_str() );
605 if ( f->IsReadable() )
607 // Add the file to the chained list:
609 gdcmWarningMacro( "Readable " << it->c_str() );
617 // sorts Patient/Study/Serie/
618 std::sort(list.begin(), list.end(), DicomDir::HeaderLessThan );
620 std::string tmp = dirList.GetDirName();
621 //for each File of the chained list, add/update the Patient/Study/Serie/Image info
622 SetElements(tmp, list);
625 for(VectDocument::iterator itDoc=list.begin();
629 dynamic_cast<File *>(*itDoc)->Delete();
634 * \brief CallStartMethod
636 void DicomDir::CallStartMethod()
642 StartMethod( StartArg );
647 * \brief CallProgressMethod
649 void DicomDir::CallProgressMethod()
651 if ( ProgressMethod )
653 ProgressMethod( ProgressArg );
658 * \brief CallEndMethod
660 void DicomDir::CallEndMethod()
669 //-----------------------------------------------------------------------------
672 * \brief Sets all fields to NULL
674 void DicomDir::Initialize()
677 ProgressMethod = NULL;
679 StartMethodArgDelete = NULL;
680 ProgressMethodArgDelete = NULL;
681 EndMethodArgDelete = NULL;
693 * \brief create a 'gdcm::DicomDir' from a DICOMDIR Header
695 void DicomDir::CreateDicomDir()
697 // The SeqEntries of "Directory Record Sequence" are parsed.
698 // When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found :
699 // 1 - we save the beginning iterator
700 // 2 - we continue to parse
701 // 3 - we find an other tag
702 // + we create the object for the precedent tag
704 gdcmDebugMacro("Create DicomDir");
706 // Directory record sequence
707 DocEntry *e = GetDocEntry(0x0004, 0x1220);
710 gdcmWarningMacro( "No Directory Record Sequence (0004,1220) found");
714 SeqEntry *s = dynamic_cast<SeqEntry *>(e);
717 gdcmWarningMacro( "Element (0004,1220) is not a Sequence ?!?");
727 SQItem *tmpSI=s->GetFirstSQItem();
730 d = tmpSI->GetDocEntry(0x0004, 0x1430); // Directory Record Type
731 if ( DataEntry *dataEntry = dynamic_cast<DataEntry *>(d) )
733 v = dataEntry->GetString();
737 gdcmWarningMacro( "(0004,1430) not a DataEntry ?!?");
741 // A decent DICOMDIR has much more images than series,
742 // more series than studies, and so on.
743 // This is the right order to preform the tests
747 si = DicomDirImage::New(true);
748 if ( !AddImageToEnd( static_cast<DicomDirImage *>(si)) )
752 gdcmErrorMacro( "Add AddImageToEnd failed");
755 else if ( v == "SERIES" )
757 si = DicomDirSerie::New(true);
758 if ( !AddSerieToEnd( static_cast<DicomDirSerie *>(si)) )
762 gdcmErrorMacro( "Add AddSerieToEnd failed");
765 else if ( v == "VISIT " )
767 si = DicomDirVisit::New(true);
768 if ( !AddVisitToEnd( static_cast<DicomDirVisit *>(si)) )
772 gdcmErrorMacro( "Add AddVisitToEnd failed");
775 else if ( v == "STUDY " )
777 si = DicomDirStudy::New(true);
778 if ( !AddStudyToEnd( static_cast<DicomDirStudy *>(si)) )
782 gdcmErrorMacro( "Add AddStudyToEnd failed");
785 else if ( v == "PATIENT " )
787 si = DicomDirPatient::New(true);
788 if ( !AddPatientToEnd( static_cast<DicomDirPatient *>(si)) )
792 gdcmErrorMacro( "Add PatientToEnd failed");
797 // It was neither a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
798 // nor an 'IMAGE' SQItem. Skip to next item.
799 gdcmWarningMacro( " -------------------------------------------"
800 << "a non PATIENT/STUDY/SERIE/IMAGE SQItem was found : "
803 // FIXME : deal with other item types !
804 tmpSI=s->GetNextSQItem(); // To avoid infinite loop
808 si->MoveObject(tmpSI); // New code : Copies the List
810 tmpSI=s->GetNextSQItem();
816 * \brief AddPatientToEnd
817 * @param dd SQ Item to enqueue to the DicomPatient chained List
819 bool DicomDir::AddPatientToEnd(DicomDirPatient *dd)
821 Patients.push_back(dd);
826 * \brief AddStudyToEnd
827 * @param dd SQ Item to enqueue to the DicomDirStudy chained List
829 bool DicomDir::AddStudyToEnd(DicomDirStudy *dd)
831 if ( Patients.size() > 0 )
833 ListDicomDirPatient::iterator itp = Patients.end();
835 (*itp)->AddStudy(dd);
842 * \brief AddSerieToEnd
843 * @param dd SQ Item to enqueue to the DicomDirSerie chained List
845 bool DicomDir::AddSerieToEnd(DicomDirSerie *dd)
847 if ( Patients.size() > 0 )
849 ListDicomDirPatient::iterator itp = Patients.end();
852 DicomDirStudy *study = (*itp)->GetLastStudy();
863 * \brief AddVisitToEnd
864 * @param dd SQ Item to enqueue to the DicomDirVisit chained List
866 bool DicomDir::AddVisitToEnd(DicomDirVisit *dd)
868 if ( Patients.size() > 0 )
870 ListDicomDirPatient::iterator itp = Patients.end();
873 DicomDirStudy *study = (*itp)->GetLastStudy();
883 * \brief AddImageToEnd
884 * @param dd SQ Item to enqueue to the DicomDirImage chained List
886 bool DicomDir::AddImageToEnd(DicomDirImage *dd)
888 if ( Patients.size() > 0 )
890 ListDicomDirPatient::iterator itp = Patients.end();
893 DicomDirStudy *study = (*itp)->GetLastStudy();
896 DicomDirSerie *serie = study->GetLastSerie();
908 * \brief for each Header of the chained list,
909 * add/update the Patient/Study/Serie/Image info
910 * @param path path of the root directory
911 * @param list chained list of Headers
913 void DicomDir::SetElements(std::string const &path, VectDocument const &list)
918 std::string patPrevName = "", patPrevID = "";
919 std::string studPrevInstanceUID = "", studPrevID = "";
920 std::string serPrevInstanceUID = "", serPrevID = "";
922 std::string patCurName, patCurID;
923 std::string studCurInstanceUID, studCurID;
924 std::string serCurInstanceUID, serCurID;
927 for( VectDocument::const_iterator it = list.begin();
931 // get the current file characteristics
932 patCurName = (*it)->GetEntryString(0x0010,0x0010);
933 patCurID = (*it)->GetEntryString(0x0010,0x0011);
934 studCurInstanceUID = (*it)->GetEntryString(0x0020,0x000d);
935 studCurID = (*it)->GetEntryString(0x0020,0x0010);
936 serCurInstanceUID = (*it)->GetEntryString(0x0020,0x000e);
937 serCurID = (*it)->GetEntryString(0x0020,0x0011);
939 if ( patCurName != patPrevName || patCurID != patPrevID || first )
941 SetElement(path, GDCM_DICOMDIR_PATIENT, *it);
945 // if new Study, deal with 'STUDY' Elements
946 if ( studCurInstanceUID != studPrevInstanceUID || studCurID != studPrevID
949 SetElement(path, GDCM_DICOMDIR_STUDY, *it);
953 // if new Serie, deal with 'SERIE' Elements
954 if ( serCurInstanceUID != serPrevInstanceUID || serCurID != serPrevID
957 SetElement(path, GDCM_DICOMDIR_SERIE, *it);
960 // Always Deal with 'IMAGE' Elements
961 SetElement(path, GDCM_DICOMDIR_IMAGE, *it);
963 patPrevName = patCurName;
964 patPrevID = patCurID;
965 studPrevInstanceUID = studCurInstanceUID;
966 studPrevID = studCurID;
967 serPrevInstanceUID = serCurInstanceUID;
968 serPrevID = serCurID;
974 * \brief adds to the HTable
975 * the Entries (Dicom Elements) corresponding to the given type
976 * @param path full path file name (only used when type = GDCM_DICOMDIR_IMAGE
977 * @param type DicomDirObject type to create (GDCM_DICOMDIR_PATIENT,
978 * GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...)
979 * @param header Header of the current file
981 void DicomDir::SetElement(std::string const &path, DicomDirType type,
984 ListDicomDirElem elemList;
985 ListDicomDirElem::const_iterator it;
986 uint16_t tmpGr, tmpEl;
987 DictEntry *dictEntry;
994 case GDCM_DICOMDIR_IMAGE:
995 elemList = Global::GetDicomDirElements()->GetDicomDirImageElements();
996 si = DicomDirImage::New(true);
997 if ( !AddImageToEnd(static_cast<DicomDirImage *>(si)) )
1000 gdcmErrorMacro( "Add ImageToEnd failed");
1003 case GDCM_DICOMDIR_SERIE:
1004 elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements();
1005 si = DicomDirSerie::New(true);
1006 if ( !AddSerieToEnd(static_cast<DicomDirSerie *>(si)) )
1009 gdcmErrorMacro( "Add SerieToEnd failed");
1012 case GDCM_DICOMDIR_STUDY:
1013 elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements();
1014 si = DicomDirStudy::New(true);
1015 if ( !AddStudyToEnd(static_cast<DicomDirStudy *>(si)) )
1018 gdcmErrorMacro( "Add StudyToEnd failed");
1021 case GDCM_DICOMDIR_PATIENT:
1022 elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements();
1023 si = DicomDirPatient::New(true);
1024 if ( !AddPatientToEnd(static_cast<DicomDirPatient *>(si)) )
1027 gdcmErrorMacro( "Add PatientToEnd failed");
1030 case GDCM_DICOMDIR_META:
1033 MetaElems->Delete();
1034 gdcmErrorMacro( "MetaElements already exist, they will be destroyed");
1036 elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements();
1037 MetaElems = DicomDirMeta::New(true);
1043 // removed all the seems-to-be-useless stuff about Referenced Image Sequence
1044 // to avoid further troubles
1045 // imageElem 0008 1140 "" // Referenced Image Sequence
1046 // imageElem fffe e000 "" // 'no length' item : length to be set to 0xffffffff later
1047 // imageElem 0008 1150 "" // Referenced SOP Class UID : to be set/forged later
1048 // imageElem 0008 1155 "" // Referenced SOP Instance UID : to be set/forged later
1049 // imageElem fffe e00d "" // Item delimitation : length to be set to ZERO later
1051 // FIXME : troubles found when it's a SeqEntry
1053 // for all the relevant elements found in their own spot of the DicomDir.dic
1054 for( it = elemList.begin(); it != elemList.end(); ++it)
1058 dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl);
1060 entry = DataEntry::New( dictEntry );
1061 entry->SetOffset(0); // just to avoid further missprinting
1065 // NULL when we Build Up (ex nihilo) a DICOMDIR
1066 // or when we add the META elems
1067 val = header->GetEntryString(tmpGr, tmpEl);
1074 if ( val == GDCM_UNFOUND)
1076 if ( tmpGr == 0x0004 && tmpEl == 0x1130 ) // File-set ID
1078 // force to the *end* File Name
1079 val = Util::GetName( path );
1081 else if ( tmpGr == 0x0004 && tmpEl == 0x1500 ) // Only used for image
1083 if ( header->GetFileName().substr(0, path.length()) != path )
1085 gdcmWarningMacro( "The base path of file name is incorrect");
1086 val = header->GetFileName();
1090 val = &(header->GetFileName().c_str()[path.length()]);
1100 if ( header->GetEntryLength(tmpGr,tmpEl) == 0 )
1104 entry->SetString( val ); // troubles expected when vr=SQ ...
1106 if ( type == GDCM_DICOMDIR_META ) // fusible : should never print !
1108 gdcmWarningMacro("GDCM_DICOMDIR_META ?!? should never print that");
1110 si->AddEntry(entry);
1116 * \brief Move the content of the source SQItem to the destination SQItem
1117 * Only DocEntry's are moved
1118 * @param dst destination SQItem
1119 * @param src source SQItem
1121 void DicomDir::MoveSQItem(DocEntrySet *dst,DocEntrySet *src)
1125 entry = src->GetFirstEntry();
1128 src->RemoveEntry(entry);
1129 dst->AddEntry(entry);
1130 // we destroyed -> the current iterator is not longer valid
1131 entry = src->GetFirstEntry();
1136 * \brief compares two files
1138 bool DicomDir::HeaderLessThan(Document *header1, Document *header2)
1140 return *header1 < *header2;
1143 //-----------------------------------------------------------------------------
1146 * \brief Canonical Printer
1147 * @param os ostream we want to print in
1148 * @param indent Indentation string to be prepended during printing
1150 void DicomDir::Print(std::ostream &os, std::string const & )
1154 MetaElems->SetPrintLevel(PrintLevel);
1155 MetaElems->Print(os);
1157 for(ListDicomDirPatient::iterator cc = Patients.begin();
1158 cc != Patients.end();
1161 (*cc)->SetPrintLevel(PrintLevel);
1166 //-----------------------------------------------------------------------------
1167 } // end namespace gdcm