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"
23 #include "gdcmSeqEntry.h"
24 #include "gdcmSQItem.h"
25 #include "gdcmValEntry.h"
27 //-----------------------------------------------------------------------------
28 // For full DICOMDIR description, see:
29 // PS 3.3-2003, pages 731-750
30 //-----------------------------------------------------------------------------
33 // Constructor / Destructor
36 * \brief Constructor Parses recursively the directory and creates the DicomDir
37 * or uses an already built DICOMDIR, depending on 'parseDir' value.
38 * @param FileName name
39 * - of the root directory (parseDir = true)
40 * - of the DICOMDIR (parseDir = false)
41 * @param parseDir boolean
42 * - true if user passed an entry point
43 * and wants to explore recursively the directories
44 * - false if user passed an already built DICOMDIR file
46 * @param exception_on_error whether we want to throw an exception or not
48 gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir,
49 bool exception_on_error):
50 gdcmDocument(FileName,exception_on_error,true) // true : enable SeQuences
52 // que l'on ai passe un root directory ou un DICOMDIR
53 // et quelle que soit la valeur de parseDir,
54 // on a lance gdcmDocument
59 startMethodArgDelete= NULL;
60 progressMethodArgDelete=NULL;
61 endMethodArgDelete= NULL;
71 // gdcmDocument already executed
72 // if user passed a root directory, sure we didn't get anything
74 if( GetEntry().begin() == GetEntry().end() )
76 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry HT empty");
78 if(strlen(FileName)==1 && FileName[0]=='.') { // user passed '.' as Name
79 // we get current directory name
80 char* dummy= new char[1000];
81 getcwd(dummy, (size_t)1000);
82 SetFileName(dummy); // will be converted into a string
83 delete[] dummy; // no longer needed
88 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : Parse directory"
89 " and create the DicomDir");
92 /// \todo if parseDir == false, it should be tagged as an error
97 // Directory record sequence
98 gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220);
100 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record"
101 " sequence (0x0004,0x1220)");
102 /// \todo FIXME : what to do when the parsed file IS NOT a
110 * \ingroup gdcmDicomDir
111 * \brief Constructor : creates an empty gdcmDicomDir
112 * @param exception_on_error whether we want to throw an exception or not
114 gdcmDicomDir::gdcmDicomDir(bool exception_on_error):
115 gdcmDocument(exception_on_error)
118 progressMethod= NULL;
120 startMethodArgDelete= NULL;
121 progressMethodArgDelete=NULL;
122 endMethodArgDelete= NULL;
128 std::string pathBidon = "Bidon"; // Sorry, NULL not allowed ...
129 SetElement(pathBidon, GDCM_DICOMDIR_META, NULL); // Set the META elements
135 * \ingroup gdcmDicomDir
136 * \brief Canonical destructor
138 gdcmDicomDir::~gdcmDicomDir()
140 SetStartMethod(NULL);
141 SetProgressMethod(NULL);
147 for(ListDicomDirPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
153 //-----------------------------------------------------------------------------
156 * \ingroup gdcmDicomDir
157 * \brief Canonical Printer
159 void gdcmDicomDir::Print(std::ostream &os)
163 metaElems->SetPrintLevel(printLevel);
164 metaElems->Print(os);
166 for(ListDicomDirPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
168 (*cc)->SetPrintLevel(printLevel);
173 //-----------------------------------------------------------------------------
176 * \ingroup gdcmDicomDir
177 * \brief This predicate, based on hopefully reasonable heuristics,
178 * decides whether or not the current header was properly parsed
179 * and contains the mandatory information for being considered as
180 * a well formed and usable DicomDir.
181 * @return true when gdcmDocument is the one of a reasonable DicomDir,
184 bool gdcmDicomDir::IsReadable(void)
186 if(!gdcmDocument::IsReadable())
190 if(patients.size()<=0)
197 * \ingroup gdcmDicomDir
198 * \brief fills the whole structure, starting from a root Directory
200 void gdcmDicomDir::ParseDirectory(void)
202 CreateDicomDirChainedList(GetFileName());
207 * \ingroup gdcmDicomDir
208 * \brief Set the start method to call when the parsing of the directory starts
209 * @param method Method to call
210 * @param arg Argument to pass to the method
211 * @param argDelete Argument
212 * \warning In python : the arg parameter isn't considered
214 void gdcmDicomDir::SetStartMethod(gdcmMethod *method,void *arg,gdcmMethod *argDelete)
216 if((startArg)&&(startMethodArgDelete))
217 startMethodArgDelete(startArg);
221 startMethodArgDelete=argDelete;
225 * \ingroup gdcmDicomDir
226 * \brief Set the method to delete the argument
227 * The argument is destroyed when the method is changed or when the
229 * @param method Method to call to delete the argument
231 void gdcmDicomDir::SetStartMethodArgDelete(gdcmMethod *method)
233 startMethodArgDelete=method;
237 * \ingroup gdcmDicomDir
238 * \brief Set the progress method to call when the parsing of the directory progress
239 * @param method Method to call
240 * @param arg Argument to pass to the method
241 * @param argDelete Argument
242 * \warning In python : the arg parameter isn't considered
244 void gdcmDicomDir::SetProgressMethod(gdcmMethod *method,void *arg,gdcmMethod *argDelete)
246 if((progressArg)&&(progressMethodArgDelete))
247 progressMethodArgDelete(progressArg);
249 progressMethod=method;
251 progressMethodArgDelete=argDelete;
255 * \ingroup gdcmDicomDir
256 * \brief Set the method to delete the argument
257 * The argument is destroyed when the method is changed or when the
259 * @param method Method to call to delete the argument
261 void gdcmDicomDir::SetProgressMethodArgDelete(gdcmMethod *method)
263 progressMethodArgDelete=method;
267 * \ingroup gdcmDicomDir
268 * \brief Set the end method to call when the parsing of the directory ends
269 * @param method Method to call
270 * @param arg Argument to pass to the method
271 * @param argDelete Argument
272 * \warning In python : the arg parameter isn't considered
274 void gdcmDicomDir::SetEndMethod(gdcmMethod *method, void *arg, gdcmMethod *argDelete)
276 if((endArg)&&(endMethodArgDelete))
277 endMethodArgDelete(endArg);
281 endMethodArgDelete=argDelete;
285 * \ingroup gdcmDicomDir
286 * \brief Set the method to delete the argument
287 * The argument is destroyed when the method is changed or when the class
289 * @param method Method to call to delete the argument
291 void gdcmDicomDir::SetEndMethodArgDelete(gdcmMethod *method)
293 endMethodArgDelete=method;
297 * \ingroup gdcmDicomDir
298 * \brief writes on disc a DICOMDIR
299 * \ warning does NOT add the missing elements in the header :
300 * it's up to the user doing it !
301 * \todo : to be re-written using the DICOMDIR tree-like structure
302 * *not* the chained list
303 * (does NOT exist if the DICOMDIR is user-forged !)
304 * @param fileName file to be written to
305 * @return false only when fail to open
308 bool gdcmDicomDir::Write(std::string fileName)
312 fp1=fopen(fileName.c_str(),"wb");
315 printf("Failed to open(write) File [%s] \n",fileName.c_str());
319 char * filePreamble = new char[128];
320 fwrite(filePreamble,128,1,fp1);
321 fwrite("DICM",4,1,fp1);
322 delete[] filePreamble;
323 UpdateDirectoryRecordSequenceLength();
331 * \brief Writes in a file using the tree-like structure.
332 * @param _fp already open file pointer
335 void gdcmDicomDir::WriteEntries(FILE *_fp)
337 /// \todo (?) tester les echecs en ecriture
338 /// (apres chaque fwrite, dans le WriteEntry)
341 /* TODO : to go on compiling
343 gdcmDicomDirMeta *ptrMeta;
344 ListDicomDirPatient::iterator itPatient;
345 ListDicomDirStudy::iterator itStudy;
346 ListDicomDirSerie::iterator itSerie;
347 ListDicomDirImage::iterator itImage;
350 ptrMeta= GetDicomDirMeta();
351 for(i=ptrMeta->debut();i!=ptrMeta->fin();++i) {
352 WriteEntry(*i,_fp, gdcmExplicitVR);
355 itPatient = GetDicomDirPatients().begin();
356 while ( itPatient != GetDicomDirPatients().end() ) {
357 for(i=(*itPatient)->debut();i!=(*itPatient)->fin();++i) {
358 WriteEntry(*i,_fp, gdcmExplicitVR);
360 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
361 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) {
362 for(i=(*itStudy)->debut();i!=(*itStudy)->fin();++i) {
363 WriteEntry(*i,_fp, gdcmExplicitVR);
365 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
366 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) {
367 for(i=(*itSerie)->debut();i!=(*itSerie)->fin();++i) {
368 WriteEntry(*i,_fp, gdcmExplicitVR);
370 itImage = ((*itSerie)->GetDicomDirImages()).begin();
371 while (itImage != (*itSerie)->GetDicomDirImages().end() ) {
372 for(i=(*itImage)->debut();i!=(*itImage)->fin();++i) {
373 WriteEntry(*i,_fp, gdcmExplicitVR);
386 //-----------------------------------------------------------------------------
390 * \ingroup gdcmDicomDir
391 * \brief create a gdcmDocument-like chained list from a root Directory
392 * @param path entry point of the tree-like structure
394 void gdcmDicomDir::CreateDicomDirChainedList(std::string path)
398 gdcmDirList fileList(path,1); // gets recursively the file list
399 unsigned int count=0;
406 for(gdcmDirList::iterator it=fileList.begin();
410 progress=(float)(count+1)/(float)fileList.size();
411 CallProgressMethod();
415 header=new gdcmHeader(it->c_str());
416 if(header->IsReadable())
417 list.push_back(header); // adds the file header to the chained list
423 // sorts Patient/Study/Serie/
424 std::sort(list.begin(),list.end(),gdcmDicomDir::HeaderLessThan);
426 std::string tmp=fileList.GetDirName();
428 //for each Header of the chained list, add/update the Patient/Study/Serie/Image info
429 SetElements(tmp,list);
435 * \ingroup gdcmDicomDir
436 * \brief adds *the* Meta to a partially created DICOMDIR
439 // FIXME : Heuuuuu ! Il prend les Entries du Document deja parse,
440 // il ne fabrique rien !
442 gdcmDicomDirMeta * gdcmDicomDir::NewMeta(void) {
443 gdcmDicomDirMeta *m = new gdcmDicomDirMeta(&tagHT);
444 for (TagDocEntryHT::iterator cc = tagHT.begin();cc != tagHT.end();++cc) {
445 m->AddDocEntry(cc->second);
452 * \ingroup gdcmDicomDir
453 * \brief adds a new Patient (with the basic elements) to a partially created DICOMDIR
455 gdcmDicomDirPatient * gdcmDicomDir::NewPatient(void) {
456 std::list<gdcmElement> elemList;
457 std::list<gdcmElement>::iterator it;
459 gdcmDictEntry *dictEntry;
462 gdcmSQItem *s = new gdcmSQItem(0);
464 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
466 // TODO : use FillObject !!!
468 // for all the DicomDirPatient Elements
470 for(it=elemList.begin();it!=elemList.end();++it)
474 dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
475 entry=new gdcmValEntry(dictEntry);
476 entry->SetOffset(0); // just to avoid further missprinting
477 entry->SetValue(it->value);
479 // dealing with value length ...
481 if(dictEntry->GetGroup()==0xfffe)
483 entry->SetLength(entry->GetValue().length());
485 else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") )
489 else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") )
493 else if(dictEntry->GetVR()=="SQ")
495 entry->SetLength(0xffffffff);
499 entry->SetLength(entry->GetValue().length());
501 s->AddDocEntry(entry);
504 gdcmDicomDirPatient *p = new gdcmDicomDirPatient(s, &tagHT);
505 patients.push_front(p);
510 * \brief adds to the HTable
511 * the gdcmEntries (Dicom Elements) corresponding to the given type
512 * @param path full path file name (only used when type = GDCM_DICOMDIR_IMAGE
513 * @param type gdcmObject type to create (GDCM_DICOMDIR_PATIENT,
514 * GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...)
515 * @param header gdcmHeader of the current file
517 void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,
518 gdcmDocument *header)
520 std::list<gdcmElement> elemList;
521 std::list<gdcmElement>::iterator it;
522 guint16 tmpGr, tmpEl;
523 gdcmDictEntry *dictEntry;
529 case GDCM_DICOMDIR_PATIENT:
530 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
532 case GDCM_DICOMDIR_STUDY:
533 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
535 case GDCM_DICOMDIR_SERIE:
536 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements();
538 case GDCM_DICOMDIR_IMAGE:
539 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements();
541 case GDCM_DICOMDIR_META:
542 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements();
548 for(it=elemList.begin();it!=elemList.end();++it)
552 dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
553 entry=new gdcmValEntry(dictEntry);
554 entry->SetOffset(0); // just to avoid further missprinting
557 val=header->GetEntryByNumber(tmpGr,tmpEl);
561 if(val==GDCM_UNFOUND)
563 if((tmpGr==0x0004) &&(tmpEl==0x1130) ) // File-set ID
565 // force to the *end* File Name
568 else if( (tmpGr==0x0004) && (tmpEl==0x1500) ) // Only used for image
570 if(header->GetFileName().substr(0,path.length())!=path)
572 dbg.Verbose(0, "gdcmDicomDir::SetElement : the base path"
573 " of file name is incorrect");
574 val=header->GetFileName();
578 val=&(header->GetFileName().c_str()[path.length()]);
588 if (header->GetEntryLengthByNumber(tmpGr,tmpEl)== 0)
592 entry->SetValue(val);
596 if(dictEntry->GetGroup()==0xfffe)
598 entry->SetLength(entry->GetValue().length());
600 else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") )
604 else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") )
608 else if(dictEntry->GetVR()=="SQ")
610 entry->SetLength(0xffffffff);
614 entry->SetLength(entry->GetValue().length());
617 //AddDocEntry(entry); // both in H Table and in chained list
618 tagHT[entry->GetKey()] = entry; // FIXME : use a SEQUENCE !
623 * \brief CallStartMethod
625 void gdcmDicomDir::CallStartMethod(void)
630 startMethod(startArg);
633 * \ingroup gdcmDicomDir
634 * \brief CallProgressMethod
636 void gdcmDicomDir::CallProgressMethod(void)
639 progressMethod(progressArg);
642 * \ingroup gdcmDicomDir
643 * \brief CallEndMethod
645 void gdcmDicomDir::CallEndMethod(void)
652 //-----------------------------------------------------------------------------
655 * \ingroup gdcmDicomDir
656 * \brief create a 'gdcmDicomDir' from a DICOMDIR gdcmHeader
658 void gdcmDicomDir::CreateDicomDir()
660 // The list is parsed.
661 // When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found :
662 // 1 - we save the beginning iterator
663 // 2 - we continue to parse
664 // 3 - we find an other tag
665 // + we create the object for the precedent tag
668 gdcmDicomDirType type=gdcmDicomDir::GDCM_DICOMDIR_META;
670 // Directory record sequence
671 gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220);
674 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record"
675 " sequence (0x0004,0x1220)");
676 /// \todo FIXME: what to do when the parsed file IS NOT a DICOMDIR file ?
680 gdcmSeqEntry* s = dynamic_cast<gdcmSeqEntry*>(e);
683 dbg.Verbose(0, "gdcmDicomDir::CreateDicomDir: no SeqEntry present");
687 ListSQItem listItems = s->GetSQItems();
688 gdcmDicomDirMeta *m = new gdcmDicomDirMeta(&tagHT);
692 for(ListSQItem::iterator i=listItems.begin(); i !=listItems.end();++i)
694 d=(*i)->GetDocEntryByNumber(0x0004, 0x1430); // Directory Record Type
695 if (gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(d) )
697 v = ValEntry->GetValue();
701 dbg.Verbose(0, "gdcmDicomDir::CreateDicomDir: not a ValEntry.");
707 AddDicomDirPatientToEnd(*i);
708 //AddObjectToEnd(type,*i);
709 type=gdcmDicomDir::GDCM_DICOMDIR_PATIENT;
714 AddDicomDirStudyToEnd(*i);
715 // AddObjectToEnd(type,*i);
716 type=gdcmDicomDir::GDCM_DICOMDIR_STUDY;
721 AddDicomDirSerieToEnd(*i);
722 // AddObjectToEnd(type,*i);
723 type=gdcmDicomDir::GDCM_DICOMDIR_SERIE;
728 AddDicomDirImageToEnd(*i);
729 // AddObjectToEnd(type,*i);
730 type=gdcmDicomDir::GDCM_DICOMDIR_IMAGE;
734 // It was not a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
735 // neither an 'IMAGE' SQItem. Skip to next item.
740 * \ingroup gdcmDicomDir
741 * \brief AddObjectToEnd
743 * @param begin iterator on the first DocEntry within the chained List
744 * @param end iterator on the last DocEntry within the chained List
749 /*void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,gdcmSQItem *s)
756 case gdcmDicomDir::GDCM_DICOMDIR_META:
759 case gdcmDicomDir::GDCM_DICOMDIR_PATIENT:
760 AddDicomDirPatientToEnd(s);
762 case gdcmDicomDir::GDCM_DICOMDIR_STUDY:
763 AddDicomDirStudyToEnd(s);
765 case gdcmDicomDir::GDCM_DICOMDIR_SERIE:
766 AddDicomDirSerieToEnd(s);
768 case gdcmDicomDir::GDCM_DICOMDIR_IMAGE:
769 AddDicomDirImageToEnd(s);
771 case gdcmDicomDir::GDCM_DICOMDIR_NONE:
772 AddDicomDirImageToEnd(s); //FIXME
780 * \ingroup gdcmDicomDir
781 * \brief Well ... there is only one occurence
783 void gdcmDicomDir::AddDicomDirMeta()
787 metaElems = new gdcmDicomDirMeta(&tagHT);
791 * \ingroup gdcmDicomDir
792 * \brief AddDicomDirPatientToEnd
793 * @param s SQ Item to enqueue to the DicomPatient chained List
795 void gdcmDicomDir::AddDicomDirPatientToEnd(gdcmSQItem *s)
797 patients.push_back(new gdcmDicomDirPatient(s, &tagHT));
801 * \ingroup gdcmDicomDir
802 * \brief AddDicomDirStudyToEnd
803 * @param s SQ Item to enqueue to the DicomDirStudy chained List
805 void gdcmDicomDir::AddDicomDirStudyToEnd(gdcmSQItem *s)
807 if(patients.size()>0)
809 ListDicomDirPatient::iterator itp=patients.end();
811 (*itp)->AddDicomDirStudy(new gdcmDicomDirStudy(s, &tagHT));
815 * \ingroup gdcmDicomDir
816 * \brief AddDicomDirSerieToEnd
817 * @param s SQ Item to enqueue to the DicomDirSerie chained List
819 void gdcmDicomDir::AddDicomDirSerieToEnd(gdcmSQItem *s)
821 if(patients.size()>0)
823 ListDicomDirPatient::iterator itp=patients.end();
826 if((*itp)->GetDicomDirStudies().size()>0)
828 ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
830 (*itst)->AddDicomDirSerie(new gdcmDicomDirSerie(s, &tagHT));
836 * \ingroup gdcmDicomDir
837 * \brief AddDicomDirImageToEnd
838 * @param s SQ Item to enqueue to the DicomDirImage chained List
840 void gdcmDicomDir::AddDicomDirImageToEnd(gdcmSQItem *s)
842 if(patients.size()>0)
844 ListDicomDirPatient::iterator itp=patients.end();
847 if((*itp)->GetDicomDirStudies().size()>0)
849 ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
852 if((*itst)->GetDicomDirSeries().size()>0)
854 ListDicomDirSerie::iterator its=(*itst)->GetDicomDirSeries().end();
856 (*its)->AddDicomDirImage(new gdcmDicomDirImage(s, &tagHT));
863 * \ingroup gdcmDicomDir
864 * \brief for each Header of the chained list, add/update the Patient/Study/Serie/Image info
865 * @param path path of the root directory
866 * @param list chained list of Headers
868 void gdcmDicomDir::SetElements(std::string &path, VectDocument &list)
870 std::string patPrevName="", patPrevID="";
871 std::string studPrevInstanceUID="", studPrevID="";
872 std::string serPrevInstanceUID="", serPrevID="";
874 std::string patCurName, patCurID;
875 std::string studCurInstanceUID, studCurID;
876 std::string serCurInstanceUID, serCurID;
878 SetElement(path,GDCM_DICOMDIR_META,NULL);
880 for(VectDocument::iterator it=list.begin();it!=list.end();++it)
882 // get the current file characteristics
883 patCurName= (*it)->GetEntryByNumber(0x0010,0x0010);
884 patCurID= (*it)->GetEntryByNumber(0x0010,0x0011);
885 studCurInstanceUID=(*it)->GetEntryByNumber(0x0020,0x000d);
886 studCurID= (*it)->GetEntryByNumber(0x0020,0x0010);
887 serCurInstanceUID= (*it)->GetEntryByNumber(0x0020,0x000e);
888 serCurID= (*it)->GetEntryByNumber(0x0020,0x0011);
890 if(patCurName!=patPrevName || patCurID!=patPrevID)
891 SetElement(path,GDCM_DICOMDIR_PATIENT,*it);
893 // if new Study Deal with 'STUDY' Elements
894 if(studCurInstanceUID!=studPrevInstanceUID || studCurID!=studPrevID)
895 SetElement(path,GDCM_DICOMDIR_STUDY,*it);
897 // if new Serie Deal with 'SERIE' Elements
898 if(serCurInstanceUID!=serPrevInstanceUID || serCurID!=serPrevID)
899 SetElement(path,GDCM_DICOMDIR_SERIE,*it);
901 // Always Deal with 'IMAGE' Elements
902 SetElement(path,GDCM_DICOMDIR_IMAGE,*it);
904 patPrevName= patCurName;
906 studPrevInstanceUID=studCurInstanceUID;
907 studPrevID= studCurID;
908 serPrevInstanceUID= serCurInstanceUID;
914 * \ingroup gdcmDicomDir
915 * \brief compares two dgcmHeaders
917 bool gdcmDicomDir::HeaderLessThan(gdcmDocument *header1,gdcmDocument *header2)
919 return(*header1<*header2);
923 * \ingroup gdcmDicomDir
924 * \brief Sets the accurate value for the (0x0004,0x1220) element of a DICOMDIR
927 void gdcmDicomDir::UpdateDirectoryRecordSequenceLength() {
929 // FIXME : to go on compiling
931 // to be re written !
934 ListTag::iterator it;
937 for(it=listEntries.begin();it!=listEntries.end();++it) {
938 gr = (*it)->GetGroup();
939 el = (*it)->GetElement();
942 if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) {
943 offset += 4; // explicit VR AND OB, OW, SQ : 4 more bytes
945 offset += 2 + 2 + 4 + (*it)->GetLength();
947 offset += 4; // delimiters don't have a value.
950 //bool res=SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
951 SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
956 //-----------------------------------------------------------------------------