1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDir.cxx,v $
6 Date: $Date: 2005/11/21 09:46:25 $
7 Version: $Revision: 1.173 $
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( );
163 * \brief Does the Loading Job (internal use only)
164 * @return false if file cannot be open or no swap info was found,
165 * or no tag was found.
167 bool DicomDir::DoTheLoadingJob( )
174 // Only if user passed a DICOMDIR
175 // ------------------------------
177 if (!Document::Load() )
182 if ( GetFirstEntry() == 0 ) // when user passed a Directory to parse
184 gdcmWarningMacro( "Entry HT empty for file: "<< GetFileName());
187 // Directory record sequence
188 DocEntry *e = GetDocEntry(0x0004, 0x1220);
191 gdcmWarningMacro( "NO 'Directory record sequence' (0x0004,0x1220)"
192 << " in file " << GetFileName());
200 // Only if user passed a root directory
201 // ------------------------------------
202 if ( GetFileName() == "." )
204 // user passed '.' as Name
205 // we get current directory name
207 const char *cwd = getcwd(buf, 2048);
210 SetFileName( buf ); // will be converted into a string
214 gdcmErrorMacro( "Path was too long to fit on 2048 bytes" );
218 gdcmDebugMacro( "Parse directory and create the DicomDir : "
226 * \brief This predicate, based on hopefully reasonable heuristics,
227 * decides whether or not the current document was properly parsed
228 * and contains the mandatory information for being considered as
229 * a well formed and usable DicomDir.
230 * @return true when Document is the one of a reasonable DicomDir,
233 bool DicomDir::IsReadable()
235 if ( Filetype == Unknown )
237 gdcmErrorMacro( "Wrong filetype for " << GetFileName());
242 gdcmWarningMacro( "Meta Elements missing in DicomDir");
245 if ( Patients.size() <= 0 )
247 gdcmWarningMacro( "NO Patient in DicomDir");
255 * \brief adds *the* Meta to a partially created DICOMDIR
257 DicomDirMeta *DicomDir::NewMeta()
262 DocEntry *entry = GetFirstEntry();
265 MetaElems = DicomDirMeta::New(true); // true = empty
267 entry = GetFirstEntry();
270 if ( dynamic_cast<SeqEntry *>(entry) )
273 MetaElems->AddEntry(entry);
276 entry = GetFirstEntry();
279 else // after root directory parsing
281 MetaElems = DicomDirMeta::New(false); // false = not empty
283 MetaElems->SetSQItemNumber(0); // To avoid further missprinting
288 * \brief adds a new Patient (with the basic elements) to a partially created
291 DicomDirPatient *DicomDir::NewPatient()
293 DicomDirPatient *dd = DicomDirPatient::New();
294 AddPatientToEnd( dd );
299 * \brief Remove all Patients
301 void DicomDir::ClearPatient()
303 for(ListDicomDirPatient::iterator cc = Patients.begin();
313 * \brief Get the first entry while visiting the DicomDirPatients
314 * \return The first DicomDirPatient if found, otherwhise NULL
316 DicomDirPatient *DicomDir::GetFirstPatient()
318 ItPatient = Patients.begin();
319 if ( ItPatient != Patients.end() )
325 * \brief Get the next entry while visiting the DicomDirPatients
326 * \note : meaningfull only if GetFirstEntry already called
327 * \return The next DicomDirPatient if found, otherwhise NULL
329 DicomDirPatient *DicomDir::GetNextPatient()
331 gdcmAssertMacro (ItPatient != Patients.end());
334 if ( ItPatient != Patients.end() )
340 * \brief fills the whole structure, starting from a root Directory
342 void DicomDir::ParseDirectory()
344 CreateDicomDirChainedList( GetFileName() );
348 void DicomDir::SetStartMethod( DicomDir::Method *method, void *arg )
350 SetStartMethod(method,arg,NULL);
353 void DicomDir::SetProgressMethod( DicomDir::Method *method, void *arg )
355 SetProgressMethod(method,arg,NULL);
358 void DicomDir::SetEndMethod( DicomDir::Method *method, void *arg )
360 SetEndMethod(method,arg,NULL);
364 * \brief Set the start method to call when the parsing of the
366 * @param method Method to call
367 * @param arg Argument to pass to the method
368 * @param argDelete Argument
369 * \warning In python : the arg parameter isn't considered
371 void DicomDir::SetStartMethod( DicomDir::Method *method, void *arg,
372 DicomDir::Method *argDelete )
374 if ( StartArg && StartMethodArgDelete )
376 StartMethodArgDelete( StartArg );
379 StartMethod = method;
381 StartMethodArgDelete = argDelete;
386 * \brief Set the progress method to call when the parsing of the
388 * @param method Method to call
389 * @param arg Argument to pass to the method
390 * @param argDelete Argument
391 * \warning In python : the arg parameter isn't considered
393 void DicomDir::SetProgressMethod( DicomDir::Method *method, void *arg,
394 DicomDir::Method *argDelete )
396 if ( ProgressArg && ProgressMethodArgDelete )
398 ProgressMethodArgDelete( ProgressArg );
401 ProgressMethod = method;
403 ProgressMethodArgDelete = argDelete;
407 * \brief Set the end method to call when the parsing of the directory ends
408 * @param method Method to call
409 * @param arg Argument to pass to the method
410 * @param argDelete Argument
411 * \warning In python : the arg parameter isn't considered
413 void DicomDir::SetEndMethod( DicomDir::Method *method, void *arg,
414 DicomDir::Method *argDelete )
416 if ( EndArg && EndMethodArgDelete )
418 EndMethodArgDelete( EndArg );
423 EndMethodArgDelete = argDelete;
427 * \brief Set the method to delete the argument
428 * The argument is destroyed when the method is changed or when the
430 * @param method Method to call to delete the argument
432 void DicomDir::SetStartMethodArgDelete( DicomDir::Method *method )
434 StartMethodArgDelete = method;
438 * \brief Set the method to delete the argument
439 * The argument is destroyed when the method is changed or when the
441 * @param method Method to call to delete the argument
443 void DicomDir::SetProgressMethodArgDelete( DicomDir::Method *method )
445 ProgressMethodArgDelete = method;
449 * \brief Set the method to delete the argument
450 * The argument is destroyed when the method is changed or when
451 * the class is destroyed
452 * @param method Method to call to delete the argument
454 void DicomDir::SetEndMethodArgDelete( DicomDir::Method *method )
456 EndMethodArgDelete = method;
460 * \brief writes on disc a DICOMDIR
461 * \ warning does NOT add the missing elements in the header :
462 * it's up to the user doing it !
463 * @param fileName file to be written to
464 * @return false only when fail to open
467 bool DicomDir::Write(std::string const &fileName)
470 uint16_t sq[6] = { 0x0004, 0x1220, 0x5153, 0x0000, 0xffff, 0xffff };
471 uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0xffff, 0xffff };
473 std::ofstream *fp = new std::ofstream(fileName.c_str(),
474 std::ios::out | std::ios::binary);
477 gdcmWarningMacro("Failed to open(write) File: " << fileName.c_str());
481 char filePreamble[128];
482 memset(filePreamble, 0, 128);
483 fp->write(filePreamble, 128);
484 binary_write( *fp, "DICM");
486 DicomDirMeta *ptrMeta = GetMeta();
487 ptrMeta->WriteContent(fp, ExplicitVR);
489 // force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta
492 binary_write(*fp, sq[i]);
495 for(ListDicomDirPatient::iterator cc = Patients.begin();
496 cc != Patients.end();
499 (*cc)->WriteContent( fp, ExplicitVR );
502 // force writing Sequence Delimitation Item
505 binary_write(*fp, sqt[i]); // fffe e0dd ffff ffff
515 * \brief Anonymize a DICOMDIR
519 bool DicomDir::Anonymize()
522 // Something clever to be found to forge the Patient names
523 std::ostringstream s;
525 for(ListDicomDirPatient::iterator cc = Patients.begin();
530 v = (*cc)->GetDataEntry(0x0010, 0x0010) ; // Patient's Name
533 v->SetString(s.str());
536 v = (*cc)->GetDataEntry(0x0010, 0x0020) ; // Patient ID
542 v = (*cc)->GetDataEntry(0x0010, 0x0030) ; // Patient's BirthDate
553 //-----------------------------------------------------------------------------
556 * \brief create a Document-like chained list from a root Directory
557 * @param path entry point of the tree-like structure
559 void DicomDir::CreateDicomDirChainedList(std::string const &path)
562 DirList dirList(path,1); // gets recursively the file list
563 unsigned int count = 0;
567 DirListType fileList = dirList.GetFilenames();
569 for( DirListType::iterator it = fileList.begin();
570 it != fileList.end();
573 Progress = (float)(count+1)/(float)fileList.size();
574 CallProgressMethod();
581 f->SetLoadMode(LoadMode); // we allow user not to load Sequences,
582 // or Shadow groups, or ......
583 f->SetFileName( it->c_str() );
586 if ( f->IsReadable() )
588 // Add the file to the chained list:
590 gdcmDebugMacro( "Readable " << it->c_str() );
598 // sorts Patient/Study/Serie/
599 std::sort(list.begin(), list.end(), DicomDir::HeaderLessThan );
601 std::string tmp = dirList.GetDirName();
602 //for each File of the chained list, add/update the Patient/Study/Serie/Image info
603 SetElements(tmp, list);
606 for(VectDocument::iterator itDoc=list.begin();
610 dynamic_cast<File *>(*itDoc)->Delete();
615 * \brief CallStartMethod
617 void DicomDir::CallStartMethod()
623 StartMethod( StartArg );
628 * \brief CallProgressMethod
630 void DicomDir::CallProgressMethod()
632 if ( ProgressMethod )
634 ProgressMethod( ProgressArg );
639 * \brief CallEndMethod
641 void DicomDir::CallEndMethod()
650 //-----------------------------------------------------------------------------
653 * \brief Sets all fields to NULL
655 void DicomDir::Initialize()
658 ProgressMethod = NULL;
660 StartMethodArgDelete = NULL;
661 ProgressMethodArgDelete = NULL;
662 EndMethodArgDelete = NULL;
674 * \brief create a 'gdcm::DicomDir' from a DICOMDIR Header
676 void DicomDir::CreateDicomDir()
678 // The SeqEntries of "Directory Record Sequence" are parsed.
679 // When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found :
680 // 1 - we save the beginning iterator
681 // 2 - we continue to parse
682 // 3 - we find an other tag
683 // + we create the object for the precedent tag
685 gdcmDebugMacro("Create DicomDir");
687 // Directory record sequence
688 DocEntry *e = GetDocEntry(0x0004, 0x1220);
691 gdcmWarningMacro( "No Directory Record Sequence (0004,1220) found");
695 SeqEntry *s = dynamic_cast<SeqEntry *>(e);
698 gdcmWarningMacro( "Element (0004,1220) is not a Sequence ?!?");
708 SQItem *tmpSI=s->GetFirstSQItem();
711 d = tmpSI->GetDocEntry(0x0004, 0x1430); // Directory Record Type
712 if ( DataEntry *dataEntry = dynamic_cast<DataEntry *>(d) )
714 v = dataEntry->GetString();
718 gdcmWarningMacro( "(0004,1430) not a DataEntry ?!?");
722 // A decent DICOMDIR has much more images than series,
723 // more series than studies, and so on.
724 // This is the right order to preform the tests
728 si = DicomDirImage::New(true);
729 if ( !AddImageToEnd( static_cast<DicomDirImage *>(si)) )
733 gdcmErrorMacro( "Add AddImageToEnd failed");
736 else if ( v == "SERIES" )
738 si = DicomDirSerie::New(true);
739 if ( !AddSerieToEnd( static_cast<DicomDirSerie *>(si)) )
743 gdcmErrorMacro( "Add AddSerieToEnd failed");
746 else if ( v == "VISIT " )
748 si = DicomDirVisit::New(true);
749 if ( !AddVisitToEnd( static_cast<DicomDirVisit *>(si)) )
753 gdcmErrorMacro( "Add AddVisitToEnd failed");
756 else if ( v == "STUDY " )
758 si = DicomDirStudy::New(true);
759 if ( !AddStudyToEnd( static_cast<DicomDirStudy *>(si)) )
763 gdcmErrorMacro( "Add AddStudyToEnd failed");
766 else if ( v == "PATIENT " )
768 si = DicomDirPatient::New(true);
769 if ( !AddPatientToEnd( static_cast<DicomDirPatient *>(si)) )
773 gdcmErrorMacro( "Add PatientToEnd failed");
778 // It was neither a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
779 // nor an 'IMAGE' SQItem. Skip to next item.
780 gdcmDebugMacro( " -------------------------------------------"
781 << "a non PATIENT/STUDY/SERIE/IMAGE SQItem was found : "
784 // FIXME : deal with other item types !
785 tmpSI=s->GetNextSQItem(); // To avoid infinite loop
789 si->MoveObject(tmpSI); // New code : Copies the List
791 tmpSI=s->GetNextSQItem();
797 * \brief AddPatientToEnd
798 * @param dd SQ Item to enqueue to the DicomPatient chained List
800 bool DicomDir::AddPatientToEnd(DicomDirPatient *dd)
802 Patients.push_back(dd);
807 * \brief AddStudyToEnd
808 * @param dd SQ Item to enqueue to the DicomDirStudy chained List
810 bool DicomDir::AddStudyToEnd(DicomDirStudy *dd)
812 if ( Patients.size() > 0 )
814 ListDicomDirPatient::iterator itp = Patients.end();
816 (*itp)->AddStudy(dd);
823 * \brief AddSerieToEnd
824 * @param dd SQ Item to enqueue to the DicomDirSerie chained List
826 bool DicomDir::AddSerieToEnd(DicomDirSerie *dd)
828 if ( Patients.size() > 0 )
830 ListDicomDirPatient::iterator itp = Patients.end();
833 DicomDirStudy *study = (*itp)->GetLastStudy();
844 * \brief AddVisitToEnd
845 * @param dd SQ Item to enqueue to the DicomDirVisit chained List
847 bool DicomDir::AddVisitToEnd(DicomDirVisit *dd)
849 if ( Patients.size() > 0 )
851 ListDicomDirPatient::iterator itp = Patients.end();
854 DicomDirStudy *study = (*itp)->GetLastStudy();
864 * \brief AddImageToEnd
865 * @param dd SQ Item to enqueue to the DicomDirImage chained List
867 bool DicomDir::AddImageToEnd(DicomDirImage *dd)
869 if ( Patients.size() > 0 )
871 ListDicomDirPatient::iterator itp = Patients.end();
874 DicomDirStudy *study = (*itp)->GetLastStudy();
877 DicomDirSerie *serie = study->GetLastSerie();
889 * \brief for each Header of the chained list,
890 * add/update the Patient/Study/Serie/Image info
891 * @param path path of the root directory
892 * @param list chained list of Headers
894 void DicomDir::SetElements(std::string const &path, VectDocument const &list)
899 std::string patPrevName = "", patPrevID = "";
900 std::string studPrevInstanceUID = "", studPrevID = "";
901 std::string serPrevInstanceUID = "", serPrevID = "";
903 std::string patCurName, patCurID;
904 std::string studCurInstanceUID, studCurID;
905 std::string serCurInstanceUID, serCurID;
908 for( VectDocument::const_iterator it = list.begin();
912 // get the current file characteristics
913 patCurName = (*it)->GetEntryString(0x0010,0x0010);
914 patCurID = (*it)->GetEntryString(0x0010,0x0011);
915 studCurInstanceUID = (*it)->GetEntryString(0x0020,0x000d);
916 studCurID = (*it)->GetEntryString(0x0020,0x0010);
917 serCurInstanceUID = (*it)->GetEntryString(0x0020,0x000e);
918 serCurID = (*it)->GetEntryString(0x0020,0x0011);
920 if ( patCurName != patPrevName || patCurID != patPrevID || first )
922 SetElement(path, GDCM_DICOMDIR_PATIENT, *it);
926 // if new Study, deal with 'STUDY' Elements
927 if ( studCurInstanceUID != studPrevInstanceUID || studCurID != studPrevID
930 SetElement(path, GDCM_DICOMDIR_STUDY, *it);
934 // if new Serie, deal with 'SERIE' Elements
935 if ( serCurInstanceUID != serPrevInstanceUID || serCurID != serPrevID
938 SetElement(path, GDCM_DICOMDIR_SERIE, *it);
941 // Always Deal with 'IMAGE' Elements
942 SetElement(path, GDCM_DICOMDIR_IMAGE, *it);
944 patPrevName = patCurName;
945 patPrevID = patCurID;
946 studPrevInstanceUID = studCurInstanceUID;
947 studPrevID = studCurID;
948 serPrevInstanceUID = serCurInstanceUID;
949 serPrevID = serCurID;
955 * \brief adds to the HTable
956 * the Entries (Dicom Elements) corresponding to the given type
957 * @param path full path file name (only used when type = GDCM_DICOMDIR_IMAGE
958 * @param type DicomDirObject type to create (GDCM_DICOMDIR_PATIENT,
959 * GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...)
960 * @param header Header of the current file
962 void DicomDir::SetElement(std::string const &path, DicomDirType type,
965 ListDicomDirElem elemList;
966 ListDicomDirElem::const_iterator it;
967 uint16_t tmpGr, tmpEl;
968 DictEntry *dictEntry;
975 case GDCM_DICOMDIR_IMAGE:
976 elemList = Global::GetDicomDirElements()->GetDicomDirImageElements();
977 si = DicomDirImage::New(true);
978 if ( !AddImageToEnd(static_cast<DicomDirImage *>(si)) )
981 gdcmErrorMacro( "Add ImageToEnd failed");
984 case GDCM_DICOMDIR_SERIE:
985 elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements();
986 si = DicomDirSerie::New(true);
987 if ( !AddSerieToEnd(static_cast<DicomDirSerie *>(si)) )
990 gdcmErrorMacro( "Add SerieToEnd failed");
993 case GDCM_DICOMDIR_STUDY:
994 elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements();
995 si = DicomDirStudy::New(true);
996 if ( !AddStudyToEnd(static_cast<DicomDirStudy *>(si)) )
999 gdcmErrorMacro( "Add StudyToEnd failed");
1002 case GDCM_DICOMDIR_PATIENT:
1003 elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements();
1004 si = DicomDirPatient::New(true);
1005 if ( !AddPatientToEnd(static_cast<DicomDirPatient *>(si)) )
1008 gdcmErrorMacro( "Add PatientToEnd failed");
1011 case GDCM_DICOMDIR_META:
1014 MetaElems->Delete();
1015 gdcmErrorMacro( "MetaElements already exist, they will be destroyed");
1017 elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements();
1018 MetaElems = DicomDirMeta::New(true);
1025 // FIXME : troubles found when it's a SeqEntry
1027 // removed all the seems-to-be-useless stuff about Referenced Image Sequence
1028 // to avoid further troubles
1029 // imageElem 0008 1140 "" // Referenced Image Sequence
1030 // imageElem fffe e000 "" // 'no length' item : length to be set to 0xffffffff later
1031 // imageElem 0008 1150 "" // Referenced SOP Class UID : to be set/forged later
1032 // imageElem 0008 1155 "" // Referenced SOP Instance UID : to be set/forged later
1033 // imageElem fffe e00d "" // Item delimitation : length to be set to ZERO later
1035 std::string referencedVal;
1036 // for all the relevant elements found in their own spot of the DicomDir.dic
1037 for( it = elemList.begin(); it != elemList.end(); ++it)
1041 dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl);
1043 entry = DataEntry::New( dictEntry );
1044 entry->SetOffset(0); // just to avoid further missprinting
1048 // NULL when we Build Up (ex nihilo) a DICOMDIR
1049 // or when we add the META elems
1051 val = header->GetEntryString(tmpGr, tmpEl);
1058 if ( val == GDCM_UNFOUND)
1060 if ( tmpGr == 0x0004 ) // never present in File !
1064 case 0x1130: // File-set ID
1065 // force to the *end* File Name
1066 val = Util::GetName( path );
1069 case 0x1500: // Only used for image
1070 if ( header->GetFileName().substr(0, path.length()) != path )
1072 gdcmWarningMacro( "The base path of file name is incorrect");
1073 val = header->GetFileName();
1077 val = &(header->GetFileName().c_str()[path.length()+1]);
1081 case 0x1510: // Referenced SOP Class UID in File
1082 referencedVal = header->GetEntryString(0x0008, 0x0016);
1083 // FIXME : probabely something to check
1084 val = referencedVal;
1087 case 0x1511: // Referenced SOP Instance UID in File
1088 referencedVal = header->GetEntryString(0x0008, 0x0018);
1089 // FIXME : probabely something to check
1090 val = referencedVal;
1093 case 0x1512: // Referenced Transfer Syntax UID in File
1094 referencedVal = header->GetEntryString(0x0002, 0x0010);
1095 // FIXME : probabely something to check
1096 val = referencedVal;
1106 if ( header->GetEntryLength(tmpGr,tmpEl) == 0 )
1110 /* FIX later the pb of creating the 'Implementation Version Name'!
1112 if (val == GDCM_UNFOUND)
1115 if ( tmpGr == 0x0002 && tmpEl == 0x0013)
1117 // 'Implementation Version Name'
1118 std::string val = "GDCM ";
1119 val += Util::GetVersion();
1122 entry->SetString( val ); // troubles expected when vr=SQ ...
1124 if ( type == GDCM_DICOMDIR_META ) // fusible : should never print !
1126 gdcmDebugMacro("GDCM_DICOMDIR_META ?!? should never print that");
1128 si->AddEntry(entry);
1134 * \brief Move the content of the source SQItem to the destination SQItem
1135 * Only DocEntry's are moved
1136 * @param dst destination SQItem
1137 * @param src source SQItem
1139 void DicomDir::MoveSQItem(DocEntrySet *dst,DocEntrySet *src)
1143 entry = src->GetFirstEntry();
1146 src->RemoveEntry(entry);
1147 dst->AddEntry(entry);
1148 // we destroyed -> the current iterator is not longer valid
1149 entry = src->GetFirstEntry();
1154 * \brief compares two files
1156 bool DicomDir::HeaderLessThan(Document *header1, Document *header2)
1158 return *header1 < *header2;
1161 //-----------------------------------------------------------------------------
1164 * \brief Canonical Printer
1165 * @param os ostream we want to print in
1166 * @param indent Indentation string to be prepended during printing
1168 void DicomDir::Print(std::ostream &os, std::string const & )
1172 MetaElems->SetPrintLevel(PrintLevel);
1173 MetaElems->Print(os);
1175 for(ListDicomDirPatient::iterator cc = Patients.begin();
1176 cc != Patients.end();
1179 (*cc)->SetPrintLevel(PrintLevel);
1184 //-----------------------------------------------------------------------------
1185 } // end namespace gdcm