2 //-----------------------------------------------------------------------------
14 #include "gdcmDicomDir.h"
15 #include "gdcmDicomDirStudy.h"
16 #include "gdcmDicomDirSerie.h"
17 #include "gdcmDicomDirImage.h"
18 #include "gdcmDirList.h"
20 #include "gdcmDebug.h"
21 #include "gdcmGlobal.h"
22 #include "gdcmHeader.h"
24 #include "gdcmSeqEntry.h"
25 #include "gdcmSQItem.h"
26 #include "gdcmValEntry.h"
28 //-----------------------------------------------------------------------------
29 // For full DICOMDIR description, see:
30 // PS 3.3-2003, pages 731-750
31 //-----------------------------------------------------------------------------
34 // Constructor / Destructor
37 * \brief Constructor Parses recursively the directory and creates the DicomDir
38 * or uses an already built DICOMDIR, depending on 'parseDir' value.
39 * @param FileName name
40 * - of the root directory (parseDir = true)
41 * - of the DICOMDIR (parseDir = false)
42 * @param parseDir boolean
43 * - true if user passed an entry point
44 * and wants to explore recursively the directories
45 * - false if user passed an already built DICOMDIR file
47 * @param exception_on_error whether we want to throw an exception or not
49 gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir,
50 bool exception_on_error):
51 gdcmDocument(FileName,exception_on_error,true) // true : enable SeQuences
53 // que l'on ai passe un root directory ou un DICOMDIR
54 // et quelle que soit la valeur de parseDir,
55 // on a lance gdcmDocument
60 startMethodArgDelete= NULL;
61 progressMethodArgDelete=NULL;
62 endMethodArgDelete= NULL;
72 // gdcmDocument already executed
73 // if user passed a root directory, sure we didn't get anything
75 if( GetEntry().begin()==GetEntry().end() )
77 // if parseDir == false, it should be tagged as an error
78 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry HT empty");
80 if(strlen(FileName)==1 && FileName[0]=='.') { // user passed '.' as Name
81 // we get current directory name
82 char* dummy= new char[1000];
83 getcwd(dummy, (size_t)1000);
84 SetFileName(dummy); // will be converted into a string
85 delete[] dummy; // no longer needed
90 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : Parse directory"
91 " and create the DicomDir");
96 gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); // Directory record sequence
98 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record sequence (0x0004,0x1220)"
100 // FIXME : what to do when the parsed file IS NOT a DICOMDIR file ?
107 * \ingroup gdcmDicomDir
108 * \brief Constructor : creates an empty gdcmDicomDir
109 * @param exception_on_error whether we want to throw an exception or not
111 gdcmDicomDir::gdcmDicomDir(bool exception_on_error):
112 gdcmDocument(exception_on_error)
115 progressMethod= NULL;
117 startMethodArgDelete= NULL;
118 progressMethodArgDelete=NULL;
119 endMethodArgDelete= NULL;
125 std::string pathBidon = ""; // Sorry, NULL not allowed ...
126 SetElement(pathBidon, GDCM_DICOMDIR_META, NULL); // Set the META elements
132 * \ingroup gdcmDicomDir
133 * \brief Canonical destructor
135 gdcmDicomDir::~gdcmDicomDir()
137 SetStartMethod(NULL);
138 SetProgressMethod(NULL);
144 for(ListDicomDirPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
150 //-----------------------------------------------------------------------------
153 * \ingroup gdcmDicomDir
154 * \brief Canonical Printer
156 void gdcmDicomDir::Print(std::ostream &os)
160 metaElems->SetPrintLevel(printLevel);
161 metaElems->Print(os);
163 for(ListDicomDirPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
165 (*cc)->SetPrintLevel(printLevel);
170 //-----------------------------------------------------------------------------
173 * \ingroup gdcmDicomDir
174 * \brief This predicate, based on hopefully reasonable heuristics,
175 * decides whether or not the current header was properly parsed
176 * and contains the mandatory information for being considered as
177 * a well formed and usable DicomDir.
178 * @return true when gdcmDocument is the one of a reasonable DicomDir,
181 bool gdcmDicomDir::IsReadable(void)
183 if(!gdcmDocument::IsReadable())
187 if(patients.size()<=0)
194 * \ingroup gdcmDicomDir
195 * \brief fills the whole structure, starting from a root Directory
197 void gdcmDicomDir::ParseDirectory(void)
199 CreateDicomDirChainedList(GetFileName());
204 * \ingroup gdcmDicomDir
205 * \brief Set the start method to call when the parsing of the directory starts
206 * @param method Method to call
207 * @param arg Argument to pass to the method
208 * @param argDelete Argument
209 * \warning In python : the arg parameter isn't considered
211 void gdcmDicomDir::SetStartMethod(gdcmMethod *method,void *arg,gdcmMethod *argDelete)
213 if((startArg)&&(startMethodArgDelete))
214 startMethodArgDelete(startArg);
218 startMethodArgDelete=argDelete;
222 * \ingroup gdcmDicomDir
223 * \brief Set the method to delete the argument
224 * The argument is destroyed when the method is changed or when the
226 * @param method Method to call to delete the argument
228 void gdcmDicomDir::SetStartMethodArgDelete(gdcmMethod *method)
230 startMethodArgDelete=method;
234 * \ingroup gdcmDicomDir
235 * \brief Set the progress method to call when the parsing of the directory progress
236 * @param method Method to call
237 * @param arg Argument to pass to the method
238 * @param argDelete Argument
239 * \warning In python : the arg parameter isn't considered
241 void gdcmDicomDir::SetProgressMethod(gdcmMethod *method,void *arg,gdcmMethod *argDelete)
243 if((progressArg)&&(progressMethodArgDelete))
244 progressMethodArgDelete(progressArg);
246 progressMethod=method;
248 progressMethodArgDelete=argDelete;
252 * \ingroup gdcmDicomDir
253 * \brief Set the method to delete the argument
254 * The argument is destroyed when the method is changed or when the
256 * @param method Method to call to delete the argument
258 void gdcmDicomDir::SetProgressMethodArgDelete(gdcmMethod *method)
260 progressMethodArgDelete=method;
264 * \ingroup gdcmDicomDir
265 * \brief Set the end method to call when the parsing of the directory ends
266 * @param method Method to call
267 * @param arg Argument to pass to the method
268 * @param argDelete Argument
269 * \warning In python : the arg parameter isn't considered
271 void gdcmDicomDir::SetEndMethod(gdcmMethod *method, void *arg, gdcmMethod *argDelete)
273 if((endArg)&&(endMethodArgDelete))
274 endMethodArgDelete(endArg);
278 endMethodArgDelete=argDelete;
282 * \ingroup gdcmDicomDir
283 * \brief Set the method to delete the argument
284 * The argument is destroyed when the method is changed or when the class
286 * @param method Method to call to delete the argument
288 void gdcmDicomDir::SetEndMethodArgDelete(gdcmMethod *method)
290 endMethodArgDelete=method;
294 * \ingroup gdcmDicomDir
295 * \brief writes on disc a DICOMDIR
296 * \ warning does NOT add the missing elements in the header :
297 * it's up to the user doing it !
298 * \todo : to be re-written using the DICOMDIR tree-like structure
299 * *not* the chained list
300 * (does NOT exist if the DICOMDIR is user-forged !)
301 * @param fileName file to be written to
302 * @return false only when fail to open
305 bool gdcmDicomDir::Write(std::string fileName)
309 fp1=fopen(fileName.c_str(),"wb");
312 printf("Failed to open(write) File [%s] \n",fileName.c_str());
316 char * filePreamble = new char[128];
317 fwrite(filePreamble,128,1,fp1);
318 fwrite("DICM",4,1,fp1);
319 delete[] filePreamble;
320 UpdateDirectoryRecordSequenceLength();
328 * \brief Writes in a file using the tree-like structure.
329 * @param _fp already open file pointer
332 void gdcmDicomDir::WriteEntries(FILE *_fp)
334 /// \todo (?) tester les echecs en ecriture
335 /// (apres chaque fwrite, dans le WriteEntry)
338 /* TODO : to go on compiling
340 gdcmDicomDirMeta *ptrMeta;
341 ListDicomDirPatient::iterator itPatient;
342 ListDicomDirStudy::iterator itStudy;
343 ListDicomDirSerie::iterator itSerie;
344 ListDicomDirImage::iterator itImage;
347 ptrMeta= GetDicomDirMeta();
348 for(i=ptrMeta->debut();i!=ptrMeta->fin();++i) {
349 WriteEntry(*i,_fp, gdcmExplicitVR);
352 itPatient = GetDicomDirPatients().begin();
353 while ( itPatient != GetDicomDirPatients().end() ) {
354 for(i=(*itPatient)->debut();i!=(*itPatient)->fin();++i) {
355 WriteEntry(*i,_fp, gdcmExplicitVR);
357 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
358 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) {
359 for(i=(*itStudy)->debut();i!=(*itStudy)->fin();++i) {
360 WriteEntry(*i,_fp, gdcmExplicitVR);
362 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
363 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) {
364 for(i=(*itSerie)->debut();i!=(*itSerie)->fin();++i) {
365 WriteEntry(*i,_fp, gdcmExplicitVR);
367 itImage = ((*itSerie)->GetDicomDirImages()).begin();
368 while (itImage != (*itSerie)->GetDicomDirImages().end() ) {
369 for(i=(*itImage)->debut();i!=(*itImage)->fin();++i) {
370 WriteEntry(*i,_fp, gdcmExplicitVR);
383 //-----------------------------------------------------------------------------
387 * \ingroup gdcmDicomDir
388 * \brief create a gdcmDocument-like chained list from a root Directory
389 * @param path entry point of the tree-like structure
391 void gdcmDicomDir::CreateDicomDirChainedList(std::string path)
395 gdcmDirList fileList(path,1); // gets recursively the file list
396 unsigned int count=0;
403 for(gdcmDirList::iterator it=fileList.begin();
407 progress=(float)(count+1)/(float)fileList.size();
408 CallProgressMethod();
412 header=new gdcmHeader(it->c_str());
413 if(header->IsReadable())
414 list.push_back(header); // adds the file header to the chained list
420 // sorts Patient/Study/Serie/
421 std::sort(list.begin(),list.end(),gdcmDicomDir::HeaderLessThan);
423 std::string tmp=fileList.GetDirName();
425 //for each Header of the chained list, add/update the Patient/Study/Serie/Image info
426 SetElements(tmp,list);
432 * \ingroup gdcmDicomDir
433 * \brief adds *the* Meta to a partially created DICOMDIR
436 // FIXME : Heuuuuu ! Il prend les Entries du Document deja parse,
437 // il ne fabrique rien !
439 gdcmDicomDirMeta * gdcmDicomDir::NewMeta(void) {
440 gdcmDicomDirMeta *m = new gdcmDicomDirMeta(&tagHT);
441 for (TagDocEntryHT::iterator cc = tagHT.begin();cc != tagHT.end();++cc) {
442 m->AddDocEntry(cc->second);
449 * \ingroup gdcmDicomDir
450 * \brief adds a new Patient (with the basic elements) to a partially created DICOMDIR
452 gdcmDicomDirPatient * gdcmDicomDir::NewPatient(void) {
453 std::list<gdcmElement> elemList;
454 std::list<gdcmElement>::iterator it;
456 gdcmDictEntry *dictEntry;
459 gdcmSQItem *s = new gdcmSQItem(0);
461 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
463 // TODO : use FillObject !!!
465 // for all the DicomDirPatient Elements
467 for(it=elemList.begin();it!=elemList.end();++it)
471 dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
472 entry=new gdcmValEntry(dictEntry);
473 entry->SetOffset(0); // just to avoid further missprinting
474 entry->SetValue(it->value);
476 // dealing with value length ...
478 if(dictEntry->GetGroup()==0xfffe)
480 entry->SetLength(entry->GetValue().length());
482 else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") )
486 else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") )
490 else if(dictEntry->GetVR()=="SQ")
492 entry->SetLength(0xffffffff);
496 entry->SetLength(entry->GetValue().length());
498 s->AddDocEntry(entry);
501 gdcmDicomDirPatient *p = new gdcmDicomDirPatient(s, &tagHT);
502 patients.push_front(p);
508 * \ingroup gdcmDicomDir
509 * \brief adds to the HTable
510 * the gdcmEntries (Dicom Elements) corresponding to the given type
511 * @param path full path file name (only used when type = GDCM_DICOMDIR_IMAGE
512 * @param type gdcmObject type to create (GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...)
513 * @param header gdcmHeader of the current file
515 void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,
516 gdcmDocument *header)
518 std::list<gdcmElement> elemList;
519 std::list<gdcmElement>::iterator it;
520 guint16 tmpGr, tmpEl;
521 gdcmDictEntry *dictEntry;
527 case GDCM_DICOMDIR_PATIENT:
528 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
530 case GDCM_DICOMDIR_STUDY:
531 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
533 case GDCM_DICOMDIR_SERIE:
534 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements();
536 case GDCM_DICOMDIR_IMAGE:
537 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements();
539 case GDCM_DICOMDIR_META:
540 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements();
546 for(it=elemList.begin();it!=elemList.end();++it)
550 dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
551 entry=new gdcmDocEntry(dictEntry);
552 entry->SetOffset(0); // just to avoid further missprinting
555 val=header->GetEntryByNumber(tmpGr,tmpEl);
559 if(val==GDCM_UNFOUND)
561 if((tmpGr==0x0004) &&(tmpEl==0x1130) ) // File-set ID
563 // force to the *end* File Name
566 else if( (tmpGr==0x0004) && (tmpEl==0x1500) ) // Only used for image
568 if(header->GetFileName().substr(0,path.length())!=path)
570 dbg.Verbose(0, "gdcmDicomDir::SetElement : the base path of file name is incorrect");
571 val=header->GetFileName();
574 val=&(header->GetFileName().c_str()[path.length()]);
584 if (header->GetEntryLengthByNumber(tmpGr,tmpEl)== 0)
588 ((gdcmValEntry *)entry)->SetValue(val);
592 if(dictEntry->GetGroup()==0xfffe)
594 entry->SetLength(((gdcmValEntry *)entry)->GetValue().length());
596 else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") )
600 else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") )
604 else if(dictEntry->GetVR()=="SQ")
606 entry->SetLength(0xffffffff);
610 entry->SetLength(((gdcmValEntry *)entry)->GetValue().length());
613 //AddDocEntry(entry); // both in H Table and in chained list
614 tagHT[entry->GetKey()] = entry; // FIXME : use a SEQUENCE !
618 * \ingroup gdcmDicomDir
619 * \brief CallStartMethod
621 void gdcmDicomDir::CallStartMethod(void)
626 startMethod(startArg);
629 * \ingroup gdcmDicomDir
630 * \brief CallProgressMethod
632 void gdcmDicomDir::CallProgressMethod(void)
635 progressMethod(progressArg);
638 * \ingroup gdcmDicomDir
639 * \brief CallEndMethod
641 void gdcmDicomDir::CallEndMethod(void)
648 //-----------------------------------------------------------------------------
651 * \ingroup gdcmDicomDir
652 * \brief create a 'gdcmDicomDir' from a DICOMDIR gdcmHeader
654 void gdcmDicomDir::CreateDicomDir()
656 // The list is parsed.
657 // When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found :
658 // 1 - we save the beginning iterator
659 // 2 - we continue to parse
660 // 3 - we find an other tag
661 // + we create the object for the precedent tag
664 gdcmDicomDirType type=gdcmDicomDir::GDCM_DICOMDIR_META;
666 gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); // Directory record sequence
668 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record sequence (0x0004,0x1220)"
670 // FIXME : what to do when the parsed file IS NOT a DICOMDIR file ?
674 gdcmDicomDirMeta *m = new gdcmDicomDirMeta(&tagHT);
676 gdcmSeqEntry *s = (gdcmSeqEntry *)e; // FIXME : It is allowed ???
677 ListSQItem listItems = s->GetSQItems();
680 for(ListSQItem::iterator i=listItems.begin(); i !=listItems.end();++i)
682 d=(*i)->GetDocEntryByNumber(0x0004, 0x1430); // Directory Record Type
683 std::string v=((gdcmValEntry *)d)->GetValue();
687 AddDicomDirPatientToEnd(*i);
688 //AddObjectToEnd(type,*i);
689 type=gdcmDicomDir::GDCM_DICOMDIR_PATIENT;
694 AddDicomDirStudyToEnd(*i);
695 // AddObjectToEnd(type,*i);
696 type=gdcmDicomDir::GDCM_DICOMDIR_STUDY;
701 AddDicomDirSerieToEnd(*i);
702 // AddObjectToEnd(type,*i);
703 type=gdcmDicomDir::GDCM_DICOMDIR_SERIE;
708 AddDicomDirImageToEnd(*i);
709 // AddObjectToEnd(type,*i);
710 type=gdcmDicomDir::GDCM_DICOMDIR_IMAGE;
714 continue ; // It was 'non PATIENT', 'non STUDY', 'non SERIE', 'non IMAGE' SQItem
718 * \ingroup gdcmDicomDir
719 * \brief AddObjectToEnd
721 * @param begin iterator on the first DocEntry within the chained List
722 * @param end iterator on the last DocEntry within the chained List
727 /*void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,gdcmSQItem *s)
734 case gdcmDicomDir::GDCM_DICOMDIR_META:
737 case gdcmDicomDir::GDCM_DICOMDIR_PATIENT:
738 AddDicomDirPatientToEnd(s);
740 case gdcmDicomDir::GDCM_DICOMDIR_STUDY:
741 AddDicomDirStudyToEnd(s);
743 case gdcmDicomDir::GDCM_DICOMDIR_SERIE:
744 AddDicomDirSerieToEnd(s);
746 case gdcmDicomDir::GDCM_DICOMDIR_IMAGE:
747 AddDicomDirImageToEnd(s);
749 case gdcmDicomDir::GDCM_DICOMDIR_NONE:
750 AddDicomDirImageToEnd(s); //FIXME
758 * \ingroup gdcmDicomDir
759 * \brief Well ... there is only one occurence
761 void gdcmDicomDir::AddDicomDirMeta()
765 metaElems = new gdcmDicomDirMeta(&tagHT);
769 * \ingroup gdcmDicomDir
770 * \brief AddDicomDirPatientToEnd
771 * @param s SQ Item to enqueue to the DicomPatient chained List
773 void gdcmDicomDir::AddDicomDirPatientToEnd(gdcmSQItem *s)
775 patients.push_back(new gdcmDicomDirPatient(s, &tagHT));
779 * \ingroup gdcmDicomDir
780 * \brief AddDicomDirStudyToEnd
781 * @param s SQ Item to enqueue to the DicomDirStudy chained List
783 void gdcmDicomDir::AddDicomDirStudyToEnd(gdcmSQItem *s)
785 if(patients.size()>0)
787 ListDicomDirPatient::iterator itp=patients.end();
789 (*itp)->AddDicomDirStudy(new gdcmDicomDirStudy(s, &tagHT));
793 * \ingroup gdcmDicomDir
794 * \brief AddDicomDirSerieToEnd
795 * @param s SQ Item to enqueue to the DicomDirSerie chained List
797 void gdcmDicomDir::AddDicomDirSerieToEnd(gdcmSQItem *s)
799 if(patients.size()>0)
801 ListDicomDirPatient::iterator itp=patients.end();
804 if((*itp)->GetDicomDirStudies().size()>0)
806 ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
808 (*itst)->AddDicomDirSerie(new gdcmDicomDirSerie(s, &tagHT));
814 * \ingroup gdcmDicomDir
815 * \brief AddDicomDirImageToEnd
816 * @param s SQ Item to enqueue to the DicomDirImage chained List
818 void gdcmDicomDir::AddDicomDirImageToEnd(gdcmSQItem *s)
820 if(patients.size()>0)
822 ListDicomDirPatient::iterator itp=patients.end();
825 if((*itp)->GetDicomDirStudies().size()>0)
827 ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
830 if((*itst)->GetDicomDirSeries().size()>0)
832 ListDicomDirSerie::iterator its=(*itst)->GetDicomDirSeries().end();
834 (*its)->AddDicomDirImage(new gdcmDicomDirImage(s, &tagHT));
841 * \ingroup gdcmDicomDir
842 * \brief for each Header of the chained list, add/update the Patient/Study/Serie/Image info
843 * @param path path of the root directory
844 * @param list chained list of Headers
846 void gdcmDicomDir::SetElements(std::string &path, VectDocument &list)
848 std::string patPrevName="", patPrevID="";
849 std::string studPrevInstanceUID="", studPrevID="";
850 std::string serPrevInstanceUID="", serPrevID="";
852 std::string patCurName, patCurID;
853 std::string studCurInstanceUID, studCurID;
854 std::string serCurInstanceUID, serCurID;
856 SetElement(path,GDCM_DICOMDIR_META,NULL);
858 for(VectDocument::iterator it=list.begin();it!=list.end();++it)
860 // get the current file characteristics
861 patCurName= (*it)->GetEntryByNumber(0x0010,0x0010);
862 patCurID= (*it)->GetEntryByNumber(0x0010,0x0011);
863 studCurInstanceUID=(*it)->GetEntryByNumber(0x0020,0x000d);
864 studCurID= (*it)->GetEntryByNumber(0x0020,0x0010);
865 serCurInstanceUID= (*it)->GetEntryByNumber(0x0020,0x000e);
866 serCurID= (*it)->GetEntryByNumber(0x0020,0x0011);
868 if(patCurName!=patPrevName || patCurID!=patPrevID)
869 SetElement(path,GDCM_DICOMDIR_PATIENT,*it);
871 // if new Study Deal with 'STUDY' Elements
872 if(studCurInstanceUID!=studPrevInstanceUID || studCurID!=studPrevID)
873 SetElement(path,GDCM_DICOMDIR_STUDY,*it);
875 // if new Serie Deal with 'SERIE' Elements
876 if(serCurInstanceUID!=serPrevInstanceUID || serCurID!=serPrevID)
877 SetElement(path,GDCM_DICOMDIR_SERIE,*it);
879 // Always Deal with 'IMAGE' Elements
880 SetElement(path,GDCM_DICOMDIR_IMAGE,*it);
882 patPrevName= patCurName;
884 studPrevInstanceUID=studCurInstanceUID;
885 studPrevID= studCurID;
886 serPrevInstanceUID= serCurInstanceUID;
892 * \ingroup gdcmDicomDir
893 * \brief compares two dgcmHeaders
895 bool gdcmDicomDir::HeaderLessThan(gdcmDocument *header1,gdcmDocument *header2)
897 return(*header1<*header2);
901 * \ingroup gdcmDicomDir
902 * \brief Sets the accurate value for the (0x0004,0x1220) element of a DICOMDIR
905 void gdcmDicomDir::UpdateDirectoryRecordSequenceLength() {
907 // FIXME : to go on compiling
909 // to be re written !
912 ListTag::iterator it;
915 for(it=listEntries.begin();it!=listEntries.end();++it) {
916 gr = (*it)->GetGroup();
917 el = (*it)->GetElement();
920 if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) {
921 offset += 4; // explicit VR AND OB, OW, SQ : 4 more bytes
923 offset += 2 + 2 + 4 + (*it)->GetLength();
925 offset += 4; // delimiters don't have a value.
928 //bool res=SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
929 SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
934 //-----------------------------------------------------------------------------