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"
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 // if parseDir == false, it should be tagged as an error
77 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry HT empty");
79 if(strlen(FileName)==1 && FileName[0]=='.') { // user passed '.' as Name
80 // we get current directory name
81 char* dummy= new char[1000];
82 getcwd(dummy, (size_t)1000);
83 SetFileName(dummy); // will be converted into a string
84 delete[] dummy; // no longer needed
89 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : Parse directory"
90 " and create the DicomDir");
95 gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); // Directory record sequence
97 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record sequence (0x0004,0x1220)"
99 // FIXME : what to do when the parsed file IS NOT a DICOMDIR file ?
106 * \ingroup gdcmDicomDir
107 * \brief Constructor : creates an empty gdcmDicomDir
108 * @param exception_on_error whether we want to throw an exception or not
110 gdcmDicomDir::gdcmDicomDir(bool exception_on_error):
111 gdcmDocument(exception_on_error)
114 progressMethod= NULL;
116 startMethodArgDelete= NULL;
117 progressMethodArgDelete=NULL;
118 endMethodArgDelete= NULL;
122 cout << "gdcmDicomDir::gdcmDicomDir(bool exception_on_error) sortie gdcmDocument
127 std::string pathBidon = ""; // Sorry, NULL not allowed ...
128 SetElement(pathBidon, GDCM_DICOMDIR_META, NULL); // Set the META elements
130 cout << "gdcmDicomDir::gdcmDicomDir apres SetElement " << endl;
132 cout << "gdcmDicomDir::gdcmDicomDir apres AddDicomDirMeta " << endl;
138 * \ingroup gdcmDicomDir
139 * \brief Canonical destructor
141 gdcmDicomDir::~gdcmDicomDir()
143 SetStartMethod(NULL);
144 SetProgressMethod(NULL);
150 for(ListDicomDirPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
156 //-----------------------------------------------------------------------------
159 * \ingroup gdcmDicomDir
160 * \brief Canonical Printer
162 void gdcmDicomDir::Print(std::ostream &os)
166 metaElems->SetPrintLevel(printLevel);
167 metaElems->Print(os);
169 for(ListDicomDirPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
171 (*cc)->SetPrintLevel(printLevel);
176 //-----------------------------------------------------------------------------
179 * \ingroup gdcmDicomDir
180 * \brief This predicate, based on hopefully reasonable heuristics,
181 * decides whether or not the current header was properly parsed
182 * and contains the mandatory information for being considered as
183 * a well formed and usable DicomDir.
184 * @return true when gdcmDocument is the one of a reasonable DicomDir,
187 bool gdcmDicomDir::IsReadable(void)
189 if(!gdcmDocument::IsReadable())
193 if(patients.size()<=0)
200 * \ingroup gdcmDicomDir
201 * \brief fills the whole structure, starting from a root Directory
203 void gdcmDicomDir::ParseDirectory(void)
205 CreateDicomDirChainedList(GetFileName());
210 * \ingroup gdcmDicomDir
211 * \brief Set the start method to call when the parsing of the directory starts
212 * @param method Method to call
213 * @param arg Argument to pass to the method
214 * @param argDelete Argument
215 * \warning In python : the arg parameter isn't considered
217 void gdcmDicomDir::SetStartMethod(gdcmMethod *method,void *arg,gdcmMethod *argDelete)
219 if((startArg)&&(startMethodArgDelete))
220 startMethodArgDelete(startArg);
224 startMethodArgDelete=argDelete;
228 * \ingroup gdcmDicomDir
229 * \brief Set the method to delete the argument
230 * The argument is destroyed when the method is changed or when the
232 * @param method Method to call to delete the argument
234 void gdcmDicomDir::SetStartMethodArgDelete(gdcmMethod *method)
236 startMethodArgDelete=method;
240 * \ingroup gdcmDicomDir
241 * \brief Set the progress method to call when the parsing of the directory progress
242 * @param method Method to call
243 * @param arg Argument to pass to the method
244 * @param argDelete Argument
245 * \warning In python : the arg parameter isn't considered
247 void gdcmDicomDir::SetProgressMethod(gdcmMethod *method,void *arg,gdcmMethod *argDelete)
249 if((progressArg)&&(progressMethodArgDelete))
250 progressMethodArgDelete(progressArg);
252 progressMethod=method;
254 progressMethodArgDelete=argDelete;
258 * \ingroup gdcmDicomDir
259 * \brief Set the method to delete the argument
260 * The argument is destroyed when the method is changed or when the
262 * @param method Method to call to delete the argument
264 void gdcmDicomDir::SetProgressMethodArgDelete(gdcmMethod *method)
266 progressMethodArgDelete=method;
270 * \ingroup gdcmDicomDir
271 * \brief Set the end method to call when the parsing of the directory ends
272 * @param method Method to call
273 * @param arg Argument to pass to the method
274 * @param argDelete Argument
275 * \warning In python : the arg parameter isn't considered
277 void gdcmDicomDir::SetEndMethod(gdcmMethod *method, void *arg, gdcmMethod *argDelete)
279 if((endArg)&&(endMethodArgDelete))
280 endMethodArgDelete(endArg);
284 endMethodArgDelete=argDelete;
288 * \ingroup gdcmDicomDir
289 * \brief Set the method to delete the argument
290 * The argument is destroyed when the method is changed or when the class
292 * @param method Method to call to delete the argument
294 void gdcmDicomDir::SetEndMethodArgDelete(gdcmMethod *method)
296 endMethodArgDelete=method;
300 * \ingroup gdcmDicomDir
301 * \brief writes on disc a DICOMDIR
302 * \ warning does NOT add the missing elements in the header :
303 * it's up to the user doing it !
304 * \todo : to be re-written using the DICOMDIR tree-like structure
305 * *not* the chained list
306 * (does NOT exist if the DICOMDIR is user-forged !)
307 * @param fileName file to be written to
308 * @return false only when fail to open
311 bool gdcmDicomDir::Write(std::string fileName)
315 fp1=fopen(fileName.c_str(),"wb");
318 printf("Failed to open(write) File [%s] \n",fileName.c_str());
322 char * filePreamble = new char[128];
323 fwrite(filePreamble,128,1,fp1);
324 fwrite("DICM",4,1,fp1);
325 delete[] filePreamble;
326 UpdateDirectoryRecordSequenceLength();
334 * \brief Writes in a file using the tree-like structure.
335 * @param _fp already open file pointer
338 void gdcmDicomDir::WriteEntries(FILE *_fp)
340 /// \todo (?) tester les echecs en ecriture
341 /// (apres chaque fwrite, dans le WriteEntry)
344 /* TODO : to go on compiling
346 gdcmDicomDirMeta *ptrMeta;
347 ListDicomDirPatient::iterator itPatient;
348 ListDicomDirStudy::iterator itStudy;
349 ListDicomDirSerie::iterator itSerie;
350 ListDicomDirImage::iterator itImage;
353 ptrMeta= GetDicomDirMeta();
354 for(i=ptrMeta->debut();i!=ptrMeta->fin();++i) {
355 WriteEntry(*i,_fp, gdcmExplicitVR);
358 itPatient = GetDicomDirPatients().begin();
359 while ( itPatient != GetDicomDirPatients().end() ) {
360 for(i=(*itPatient)->debut();i!=(*itPatient)->fin();++i) {
361 WriteEntry(*i,_fp, gdcmExplicitVR);
363 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
364 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) {
365 for(i=(*itStudy)->debut();i!=(*itStudy)->fin();++i) {
366 WriteEntry(*i,_fp, gdcmExplicitVR);
368 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
369 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) {
370 for(i=(*itSerie)->debut();i!=(*itSerie)->fin();++i) {
371 WriteEntry(*i,_fp, gdcmExplicitVR);
373 itImage = ((*itSerie)->GetDicomDirImages()).begin();
374 while (itImage != (*itSerie)->GetDicomDirImages().end() ) {
375 for(i=(*itImage)->debut();i!=(*itImage)->fin();++i) {
376 WriteEntry(*i,_fp, gdcmExplicitVR);
389 //-----------------------------------------------------------------------------
393 * \ingroup gdcmDicomDir
394 * \brief create a gdcmDocument-like chained list from a root Directory
395 * @param path entry point of the tree-like structure
397 void gdcmDicomDir::CreateDicomDirChainedList(std::string path)
401 gdcmDirList fileList(path,1); // gets recursively the file list
402 unsigned int count=0;
409 for(gdcmDirList::iterator it=fileList.begin();
413 progress=(float)(count+1)/(float)fileList.size();
414 CallProgressMethod();
418 header=new gdcmHeader(it->c_str());
419 if(header->IsReadable())
420 list.push_back(header); // adds the file header to the chained list
426 // sorts Patient/Study/Serie/
427 std::sort(list.begin(),list.end(),gdcmDicomDir::HeaderLessThan);
429 std::string tmp=fileList.GetDirName();
431 //for each Header of the chained list, add/update the Patient/Study/Serie/Image info
432 SetElements(tmp,list);
438 * \ingroup gdcmDicomDir
439 * \brief adds *the* Meta to a partially created DICOMDIR
442 // FIXME : Heuuuuu ! Il prend les Entries du Document deja parse,
443 // il ne fabrique rien !
445 gdcmDicomDirMeta * gdcmDicomDir::NewMeta(void) {
446 gdcmDicomDirMeta *m = new gdcmDicomDirMeta(&tagHT);
447 for (TagDocEntryHT::iterator cc = tagHT.begin();cc != tagHT.end();++cc) {
448 m->AddDocEntry(cc->second);
455 * \ingroup gdcmDicomDir
456 * \brief adds a new Patient (with the basic elements) to a partially created DICOMDIR
458 gdcmDicomDirPatient * gdcmDicomDir::NewPatient(void) {
459 std::list<gdcmElement> elemList;
460 std::list<gdcmElement>::iterator it;
462 gdcmDictEntry *dictEntry;
465 gdcmSQItem *s = new gdcmSQItem(0);
467 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
469 // TODO : use FillObject !!!
471 // for all the DicomDirPatient Elements
473 for(it=elemList.begin();it!=elemList.end();++it)
477 dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
478 entry=new gdcmValEntry(dictEntry);
479 entry->SetOffset(0); // just to avoid further missprinting
480 entry->SetValue(it->value);
482 // dealing with value length ...
484 if(dictEntry->GetGroup()==0xfffe)
486 entry->SetLength(entry->GetValue().length());
488 else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") )
492 else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") )
496 else if(dictEntry->GetVR()=="SQ")
498 entry->SetLength(0xffffffff);
502 entry->SetLength(entry->GetValue().length());
504 s->AddDocEntry(entry);
507 gdcmDicomDirPatient *p = new gdcmDicomDirPatient(s, &tagHT);
508 patients.push_front(p);
514 * \ingroup gdcmDicomDir
515 * \brief adds to the HTable
516 * the gdcmEntries (Dicom Elements) corresponding to the given type
517 * @param path full path file name (only used when type = GDCM_DICOMDIR_IMAGE
518 * @param type gdcmObject type to create (GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...)
519 * @param header gdcmHeader of the current file
521 void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,gdcmHeader *header)
523 std::list<gdcmElement> elemList;
524 std::list<gdcmElement>::iterator it;
525 guint16 tmpGr, tmpEl;
526 gdcmDictEntry *dictEntry;
532 case GDCM_DICOMDIR_PATIENT:
533 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
535 case GDCM_DICOMDIR_STUDY:
536 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
538 case GDCM_DICOMDIR_SERIE:
539 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements();
541 case GDCM_DICOMDIR_IMAGE:
542 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements();
544 case GDCM_DICOMDIR_META:
545 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements();
551 for(it=elemList.begin();it!=elemList.end();++it)
555 dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
556 entry=new gdcmDocEntry(dictEntry);
557 entry->SetOffset(0); // just to avoid further missprinting
560 val=header->GetEntryByNumber(tmpGr,tmpEl);
564 if(val==GDCM_UNFOUND)
566 if((tmpGr==0x0004) &&(tmpEl==0x1130) ) // File-set ID
568 // force to the *end* File Name
571 else if( (tmpGr==0x0004) && (tmpEl==0x1500) ) // Only used for image
573 if(header->GetFileName().substr(0,path.length())!=path)
575 dbg.Verbose(0, "gdcmDicomDir::SetElement : the base path of file name is incorrect");
576 val=header->GetFileName();
579 val=&(header->GetFileName().c_str()[path.length()]);
589 if (header->GetEntryLengthByNumber(tmpGr,tmpEl)== 0)
593 ((gdcmValEntry *)entry)->SetValue(val);
597 if(dictEntry->GetGroup()==0xfffe)
599 entry->SetLength(((gdcmValEntry *)entry)->GetValue().length());
601 else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") )
605 else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") )
609 else if(dictEntry->GetVR()=="SQ")
611 entry->SetLength(0xffffffff);
615 entry->SetLength(((gdcmValEntry *)entry)->GetValue().length());
618 //AddDocEntry(entry); // both in H Table and in chained list
619 tagHT[entry->GetKey()] = entry; // FIXME : use a SEQUENCE !
623 * \ingroup gdcmDicomDir
624 * \brief CallStartMethod
626 void gdcmDicomDir::CallStartMethod(void)
631 startMethod(startArg);
634 * \ingroup gdcmDicomDir
635 * \brief CallProgressMethod
637 void gdcmDicomDir::CallProgressMethod(void)
640 progressMethod(progressArg);
643 * \ingroup gdcmDicomDir
644 * \brief CallEndMethod
646 void gdcmDicomDir::CallEndMethod(void)
653 //-----------------------------------------------------------------------------
656 * \ingroup gdcmDicomDir
657 * \brief create a 'gdcmDicomDir' from a DICOMDIR gdcmHeader
659 void gdcmDicomDir::CreateDicomDir()
661 // The list is parsed.
662 // When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found :
663 // 1 - we save the beginning iterator
664 // 2 - we continue to parse
665 // 3 - we find an other tag
666 // + we create the object for the precedent tag
669 gdcmDicomDirType type=gdcmDicomDir::GDCM_DICOMDIR_META;
671 gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); // Directory record sequence
673 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record sequence (0x0004,0x1220)"
675 // FIXME : what to do when the parsed file IS NOT a DICOMDIR file ?
679 gdcmDicomDirMeta *m = new gdcmDicomDirMeta(&tagHT);
681 gdcmSeqEntry *s = (gdcmSeqEntry *)e; // FIXME : It is allowed ???
682 ListSQItem listItems = s->GetSQItems();
685 for(ListSQItem::iterator i=listItems.begin(); i !=listItems.end();++i)
687 d=(*i)->GetDocEntryByNumber(0x0004, 0x1430); // Directory Record Type
688 std::string v=((gdcmValEntry *)d)->GetValue();
692 AddDicomDirPatientToEnd(*i);
693 //AddObjectToEnd(type,*i);
694 type=gdcmDicomDir::GDCM_DICOMDIR_PATIENT;
699 AddDicomDirStudyToEnd(*i);
700 // AddObjectToEnd(type,*i);
701 type=gdcmDicomDir::GDCM_DICOMDIR_STUDY;
706 AddDicomDirSerieToEnd(*i);
707 // AddObjectToEnd(type,*i);
708 type=gdcmDicomDir::GDCM_DICOMDIR_SERIE;
713 AddDicomDirImageToEnd(*i);
714 // AddObjectToEnd(type,*i);
715 type=gdcmDicomDir::GDCM_DICOMDIR_IMAGE;
719 continue ; // It was 'non PATIENT', 'non STUDY', 'non SERIE', 'non IMAGE' SQItem
723 * \ingroup gdcmDicomDir
724 * \brief AddObjectToEnd
726 * @param begin iterator on the first DocEntry within the chained List
727 * @param end iterator on the last DocEntry within the chained List
732 /*void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,gdcmSQItem *s)
739 case gdcmDicomDir::GDCM_DICOMDIR_META:
742 case gdcmDicomDir::GDCM_DICOMDIR_PATIENT:
743 AddDicomDirPatientToEnd(s);
745 case gdcmDicomDir::GDCM_DICOMDIR_STUDY:
746 AddDicomDirStudyToEnd(s);
748 case gdcmDicomDir::GDCM_DICOMDIR_SERIE:
749 AddDicomDirSerieToEnd(s);
751 case gdcmDicomDir::GDCM_DICOMDIR_IMAGE:
752 AddDicomDirImageToEnd(s);
754 case gdcmDicomDir::GDCM_DICOMDIR_NONE:
755 AddDicomDirImageToEnd(s); //FIXME
763 * \ingroup gdcmDicomDir
764 * \brief Well ... there is only one occurence
766 void gdcmDicomDir::AddDicomDirMeta()
770 metaElems = new gdcmDicomDirMeta(&tagHT);
774 * \ingroup gdcmDicomDir
775 * \brief AddDicomDirPatientToEnd
776 * @param s SQ Item to enqueue to the DicomPatient chained List
778 void gdcmDicomDir::AddDicomDirPatientToEnd(gdcmSQItem *s)
780 patients.push_back(new gdcmDicomDirPatient(s, &tagHT));
784 * \ingroup gdcmDicomDir
785 * \brief AddDicomDirStudyToEnd
786 * @param s SQ Item to enqueue to the DicomDirStudy chained List
788 void gdcmDicomDir::AddDicomDirStudyToEnd(gdcmSQItem *s)
790 if(patients.size()>0)
792 ListDicomDirPatient::iterator itp=patients.end();
794 (*itp)->AddDicomDirStudy(new gdcmDicomDirStudy(s, &tagHT));
798 * \ingroup gdcmDicomDir
799 * \brief AddDicomDirSerieToEnd
800 * @param s SQ Item to enqueue to the DicomDirSerie chained List
802 void gdcmDicomDir::AddDicomDirSerieToEnd(gdcmSQItem *s)
804 if(patients.size()>0)
806 ListDicomDirPatient::iterator itp=patients.end();
809 if((*itp)->GetDicomDirStudies().size()>0)
811 ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
813 (*itst)->AddDicomDirSerie(new gdcmDicomDirSerie(s, &tagHT));
819 * \ingroup gdcmDicomDir
820 * \brief AddDicomDirImageToEnd
821 * @param s SQ Item to enqueue to the DicomDirImage chained List
823 void gdcmDicomDir::AddDicomDirImageToEnd(gdcmSQItem *s)
825 if(patients.size()>0)
827 ListDicomDirPatient::iterator itp=patients.end();
830 if((*itp)->GetDicomDirStudies().size()>0)
832 ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
835 if((*itst)->GetDicomDirSeries().size()>0)
837 ListDicomDirSerie::iterator its=(*itst)->GetDicomDirSeries().end();
839 (*its)->AddDicomDirImage(new gdcmDicomDirImage(s, &tagHT));
846 * \ingroup gdcmDicomDir
847 * \brief for each Header of the chained list, add/update the Patient/Study/Serie/Image info
848 * @param path path of the root directory
849 * @param list chained list of Headers
851 void gdcmDicomDir::SetElements(std::string &path, ListHeader &list)
853 std::string patPrevName="", patPrevID="";
854 std::string studPrevInstanceUID="", studPrevID="";
855 std::string serPrevInstanceUID="", serPrevID="";
857 std::string patCurName, patCurID;
858 std::string studCurInstanceUID, studCurID;
859 std::string serCurInstanceUID, serCurID;
861 SetElement(path,GDCM_DICOMDIR_META,NULL);
863 for(ListHeader::iterator it=list.begin();it!=list.end();++it)
865 // get the current file characteristics
866 patCurName= (*it)->GetEntryByNumber(0x0010,0x0010);
867 patCurID= (*it)->GetEntryByNumber(0x0010,0x0011);
868 studCurInstanceUID=(*it)->GetEntryByNumber(0x0020,0x000d);
869 studCurID= (*it)->GetEntryByNumber(0x0020,0x0010);
870 serCurInstanceUID= (*it)->GetEntryByNumber(0x0020,0x000e);
871 serCurID= (*it)->GetEntryByNumber(0x0020,0x0011);
873 if(patCurName!=patPrevName || patCurID!=patPrevID)
874 SetElement(path,GDCM_DICOMDIR_PATIENT,*it);
876 // if new Study Deal with 'STUDY' Elements
877 if(studCurInstanceUID!=studPrevInstanceUID || studCurID!=studPrevID)
878 SetElement(path,GDCM_DICOMDIR_STUDY,*it);
880 // if new Serie Deal with 'SERIE' Elements
881 if(serCurInstanceUID!=serPrevInstanceUID || serCurID!=serPrevID)
882 SetElement(path,GDCM_DICOMDIR_SERIE,*it);
884 // Always Deal with 'IMAGE' Elements
885 SetElement(path,GDCM_DICOMDIR_IMAGE,*it);
887 patPrevName= patCurName;
889 studPrevInstanceUID=studCurInstanceUID;
890 studPrevID= studCurID;
891 serPrevInstanceUID= serCurInstanceUID;
897 * \ingroup gdcmDicomDir
898 * \brief compares two dgcmHeaders
900 bool gdcmDicomDir::HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2)
902 return(*header1<*header2);
906 * \ingroup gdcmDicomDir
907 * \brief Sets the accurate value for the (0x0004,0x1220) element of a DICOMDIR
910 void gdcmDicomDir::UpdateDirectoryRecordSequenceLength() {
912 // FIXME : to go on compiling
914 // to be re written !
917 ListTag::iterator it;
920 for(it=listEntries.begin();it!=listEntries.end();++it) {
921 gr = (*it)->GetGroup();
922 el = (*it)->GetElement();
925 if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) {
926 offset += 4; // explicit VR AND OB, OW, SQ : 4 more bytes
928 offset += 2 + 2 + 4 + (*it)->GetLength();
930 offset += 4; // delimiters don't have a value.
933 //bool res=SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
934 SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
939 //-----------------------------------------------------------------------------