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 //-----------------------------------------------------------------------------
24 // For full DICOMDIR description, see:
25 // PS 3.3-2003, pages 731-750
26 //-----------------------------------------------------------------------------
29 // Constructor / Destructor
32 * \brief Constructor Parses recursively the directory and creates the DicomDir
33 * or uses an already built DICOMDIR, depending on 'parseDir' value.
34 * @param FileName name
35 * - of the root directory (parseDir = true)
36 * - of the DICOMDIR (parseDir = false)
37 * @param parseDir boolean
38 * - true if user passed an entry point
39 * and wants to explore recursively the directories
40 * - false if user passed an already built DICOMDIR file
42 * @param exception_on_error whether we want to throw an exception or not
44 gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir,
45 bool exception_on_error):
46 gdcmParser(FileName,exception_on_error,true) // true : enable SeQuences
48 // que l'on ai passe un root directory ou un DICOMDIR
49 // et quelle que soit la valeur de parseDir,
50 // on a lance gdcmParser
55 startMethodArgDelete= NULL;
56 progressMethodArgDelete=NULL;
57 endMethodArgDelete= NULL;
67 // gdcmParser already executed
68 // if user passed a root directory, sure we didn't get anything
70 if( GetListEntry().begin()==GetListEntry().end() )
72 // if parseDir == false, it should be tagged as an error
73 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry list empty");
75 if(strlen(FileName)==1 && FileName[0]=='.') { // user passed '.' as Name
76 // we get current directory name
77 char*dummy=(char*) malloc(1000);
78 getcwd(dummy,(size_t)1000);
79 SetFileName(dummy); // will be converted into a string
80 free(dummy); // no longer needed
85 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : Parse directory"
86 " and create the DicomDir");
92 CheckBoundaries(); // to maintain consistency between
93 // home-made gdcmDicomDir
94 // and the ones comming from a DICOMDIR file
99 * \ingroup gdcmDicomDir
100 * \brief Constructor : creates an empty gdcmDicomDir
101 * @param exception_on_error whether we want to throw an exception or not
103 gdcmDicomDir::gdcmDicomDir(bool exception_on_error):
104 gdcmParser(exception_on_error)
107 progressMethod= NULL;
109 startMethodArgDelete= NULL;
110 progressMethodArgDelete=NULL;
111 endMethodArgDelete= NULL;
118 std::string pathBidon = ""; // Sorry, NULL not allowed ...
119 SetElement(pathBidon, GDCM_DICOMDIR_META, NULL); // Set the META elements
121 AddDicomDirMetaToEnd(listEntries.begin(),--listEntries.end());
126 * \ingroup gdcmDicomDir
127 * \brief Canonical destructor
129 gdcmDicomDir::~gdcmDicomDir()
131 SetStartMethod(NULL);
132 SetProgressMethod(NULL);
138 for(ListDicomDirPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
144 //-----------------------------------------------------------------------------
147 * \ingroup gdcmDicomDir
148 * \brief Canonical Printer
150 void gdcmDicomDir::Print(std::ostream &os)
154 metaElems->SetPrintLevel(printLevel);
155 metaElems->Print(os);
157 for(ListDicomDirPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
159 (*cc)->SetPrintLevel(printLevel);
164 //-----------------------------------------------------------------------------
167 * \ingroup gdcmDicomDir
168 * \brief This predicate, based on hopefully reasonable heuristics,
169 * decides whether or not the current header was properly parsed
170 * and contains the mandatory information for being considered as
171 * a well formed and usable DicomDir.
172 * @return true when gdcmParser is the one of a reasonable DicomDir,
175 bool gdcmDicomDir::IsReadable(void)
177 if(!gdcmParser::IsReadable())
181 if(patients.size()<=0)
188 * \ingroup gdcmDicomDir
189 * \brief fills the whole structure, starting from a root Directory
191 void gdcmDicomDir::ParseDirectory(void)
193 CreateDicomDirChainedList(GetFileName());
198 * \ingroup gdcmDicomDir
199 * \brief Set the start method to call when the parsing of the directory starts
200 * @param method Method to call
201 * @param arg Argument to pass to the method
202 * @param argDelete Argument
203 * \warning In python : the arg parameter isn't considered
205 void gdcmDicomDir::SetStartMethod(gdcmMethod *method,void *arg,gdcmMethod *argDelete)
207 if((startArg)&&(startMethodArgDelete))
208 startMethodArgDelete(startArg);
212 startMethodArgDelete=argDelete;
216 * \ingroup gdcmDicomDir
217 * \brief Set the method to delete the argument
218 * The argument is destroyed when the method is changed or when the
220 * @param method Method to call to delete the argument
222 void gdcmDicomDir::SetStartMethodArgDelete(gdcmMethod *method)
224 startMethodArgDelete=method;
228 * \ingroup gdcmDicomDir
229 * \brief Set the progress method to call when the parsing of the directory progress
230 * @param method Method to call
231 * @param arg Argument to pass to the method
232 * @param argDelete Argument
233 * \warning In python : the arg parameter isn't considered
235 void gdcmDicomDir::SetProgressMethod(gdcmMethod *method,void *arg,gdcmMethod *argDelete)
237 if((progressArg)&&(progressMethodArgDelete))
238 progressMethodArgDelete(progressArg);
240 progressMethod=method;
242 progressMethodArgDelete=argDelete;
246 * \ingroup gdcmDicomDir
247 * \brief Set the method to delete the argument
248 * The argument is destroyed when the method is changed or when the
250 * @param method Method to call to delete the argument
252 void gdcmDicomDir::SetProgressMethodArgDelete(gdcmMethod *method)
254 progressMethodArgDelete=method;
258 * \ingroup gdcmDicomDir
259 * \brief Set the end method to call when the parsing of the directory ends
260 * @param method Method to call
261 * @param arg Argument to pass to the method
262 * @param argDelete Argument
263 * \warning In python : the arg parameter isn't considered
265 void gdcmDicomDir::SetEndMethod(gdcmMethod *method, void *arg, gdcmMethod *argDelete)
267 if((endArg)&&(endMethodArgDelete))
268 endMethodArgDelete(endArg);
272 endMethodArgDelete=argDelete;
276 * \ingroup gdcmDicomDir
277 * \brief Set the method to delete the argument
278 * The argument is destroyed when the method is changed or when the class
280 * @param method Method to call to delete the argument
282 void gdcmDicomDir::SetEndMethodArgDelete(gdcmMethod *method)
284 endMethodArgDelete=method;
288 * \ingroup gdcmDicomDir
289 * \brief writes on disc a DICOMDIR
290 * \ warning does NOT add the missing elements in the header :
291 * it's up to the user doing it !
292 * \todo : to be re-written using the DICOMDIR tree-like structure
293 * *not* the chained list
294 * (does NOT exist if the DICOMDIR is user-forged !)
295 * @param fileName file to be written to
296 * @return false only when fail to open
299 bool gdcmDicomDir::Write(std::string fileName)
303 fp1=fopen(fileName.c_str(),"wb");
306 printf("Failed to open(write) File [%s] \n",fileName.c_str());
311 filePreamble=(char*)calloc(128,1);
312 fwrite(filePreamble,128,1,fp1);
313 fwrite("DICM",4,1,fp1);
315 UpdateDirectoryRecordSequenceLength();
316 WriteDicomDirEntries(fp1);
323 * \ingroup gdcmParser
324 * \brief writes on disc according to the DICOMDIR format
325 * using the tree-like structure
326 * @param _fp already open file pointer
329 void gdcmDicomDir::WriteDicomDirEntries(FILE *_fp)
331 // TODO (?) tester les echecs en ecriture
332 // (apres chaque fwrite, dans le WriteEntry)
334 gdcmDicomDirMeta *ptrMeta;
335 ListDicomDirPatient::iterator itPatient;
336 ListDicomDirStudy::iterator itStudy;
337 ListDicomDirSerie::iterator itSerie;
338 ListDicomDirImage::iterator itImage;
341 ptrMeta= GetDicomDirMeta();
342 for(i=ptrMeta->debut();i!=ptrMeta->fin();++i) {
343 WriteEntry(*i,_fp,DICOMDIR);
346 itPatient = GetDicomDirPatients().begin();
347 while ( itPatient != GetDicomDirPatients().end() ) {
348 for(i=(*itPatient)->debut();i!=(*itPatient)->fin();++i) {
349 WriteEntry(*i,_fp,DICOMDIR);
351 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
352 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) {
353 for(i=(*itStudy)->debut();i!=(*itStudy)->fin();++i) {
354 WriteEntry(*i,_fp,DICOMDIR);
356 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
357 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) {
358 for(i=(*itSerie)->debut();i!=(*itSerie)->fin();++i) {
359 WriteEntry(*i,_fp,DICOMDIR);
361 itImage = ((*itSerie)->GetDicomDirImages()).begin();
362 while (itImage != (*itSerie)->GetDicomDirImages().end() ) {
363 for(i=(*itImage)->debut();i!=(*itImage)->fin();++i) {
364 WriteEntry(*i,_fp,DICOMDIR);
376 //-----------------------------------------------------------------------------
380 * \ingroup gdcmDicomDir
381 * \brief create a gdcmHeader-like chained list from a root Directory
382 * @param path entry point of the tree-like structure
384 void gdcmDicomDir::CreateDicomDirChainedList(std::string path)
388 gdcmDirList fileList(path,1); // gets recursively the file list
389 unsigned int count=0;
396 for(gdcmDirList::iterator it=fileList.begin();
400 progress=(float)(count+1)/(float)fileList.size();
401 CallProgressMethod();
405 header=new gdcmHeader(it->c_str());
406 if(header->IsReadable())
407 list.push_back(header); // adds the file header to the chained list
413 // sorts Patient/Study/Serie/
414 std::sort(list.begin(),list.end(),gdcmDicomDir::HeaderLessThan);
416 std::string tmp=fileList.GetDirName();
418 //for each Header of the chained list, add/update the Patient/Study/Serie/Image info
419 SetElements(tmp,list);
425 * \ingroup gdcmDicomDir
426 * \brief modifies the limits of a gdcmObject, created from a DICOMDIR file
429 void gdcmDicomDir::CheckBoundaries()
431 ListDicomDirPatient::iterator itPatient;
432 ListDicomDirStudy::iterator itStudy;
433 ListDicomDirSerie::iterator itSerie;
434 ListDicomDirImage::iterator itImage;
435 ListTag::iterator i,j;
437 GetDicomDirMeta()->ResetBoundaries(0);
439 itPatient = GetDicomDirPatients().begin();
440 while ( itPatient != GetDicomDirPatients().end() ) {
441 (*itPatient)->ResetBoundaries(1);
442 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
443 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) {
444 (*itStudy)->ResetBoundaries(1);
445 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
446 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) {
447 (*itSerie)->ResetBoundaries(1);
448 itImage = ((*itSerie)->GetDicomDirImages()).begin();
449 while (itImage != (*itSerie)->GetDicomDirImages().end() ) {
450 (*itImage)->ResetBoundaries(1);
463 * \ingroup gdcmDicomDir
464 * \brief adds a new Patient to a partially created DICOMDIR
466 gdcmDicomDirPatient * gdcmDicomDir::NewPatient(void) {
467 std::list<gdcmElement> elemList;
468 std::list<gdcmElement>::iterator it;
470 gdcmDictEntry *dictEntry;
471 gdcmHeaderEntry *entry;
473 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
474 std::list<gdcmHeaderEntry *>::iterator debInsertion, finInsertion, i,j;
476 debInsertion = metaElems->fin();
478 finInsertion=debInsertion;
480 // for all the DicomDirPatient Elements
481 for(it=elemList.begin();it!=elemList.end();++it)
485 dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
486 entry=new gdcmHeaderEntry(dictEntry);
487 entry->SetOffset(0); // just to avoid missprinting
488 entry->SetValue(it->value);
490 if(dictEntry->GetGroup()==0xfffe)
492 entry->SetLength(entry->GetValue().length());
494 else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") )
498 else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") )
502 else if(dictEntry->GetVR()=="SQ")
504 entry->SetLength(0xffffffff);
508 entry->SetLength(entry->GetValue().length());
511 tagHT.insert( PairHT(entry->GetKey(),entry) ); // add in the (multimap) H Table
512 listEntries.insert(debInsertion ,entry); // en tete de liste des Patients
519 gdcmDicomDirPatient *p = new gdcmDicomDirPatient(i, --debInsertion,
520 &tagHT, &listEntries);
521 patients.push_front(p);
526 * \ingroup gdcmDicomDir
527 * \brief CallStartMethod
529 void gdcmDicomDir::CallStartMethod(void)
534 startMethod(startArg);
537 * \ingroup gdcmDicomDir
538 * \brief CallProgressMethod
540 void gdcmDicomDir::CallProgressMethod(void)
543 progressMethod(progressArg);
546 * \ingroup gdcmDicomDir
547 * \brief CallEndMethod
549 void gdcmDicomDir::CallEndMethod(void)
556 //-----------------------------------------------------------------------------
559 * \ingroup gdcmDicomDir
560 * \brief create a 'gdcmDicomDir' from a DICOMDIR gdcmHeader
562 void gdcmDicomDir::CreateDicomDir()
564 // The list is parsed.
565 // When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found :
566 // 1 - we save the beginning iterator
567 // 2 - we continue to parse
568 // 3 - we find an other tag
569 // + we create the object for the precedent tag
572 gdcmDicomDirType type=gdcmDicomDir::GDCM_DICOMDIR_META;
573 ListTag::iterator begin;
574 ListTag::iterator end, end2;
576 begin=listEntries.begin();
578 for(ListTag::iterator i=end;i !=listEntries.end();++i)
580 std::string v=(*i)->GetValue();
584 AddObjectToEnd(type,begin,--end2);
585 type=gdcmDicomDir::GDCM_DICOMDIR_PATIENT;
592 AddObjectToEnd(type,begin,--end2);
593 type=gdcmDicomDir::GDCM_DICOMDIR_STUDY;
600 AddObjectToEnd(type,begin,--end2);
601 type=gdcmDicomDir::GDCM_DICOMDIR_SERIE;
608 AddObjectToEnd(type,begin,--end2);
609 type=gdcmDicomDir::GDCM_DICOMDIR_IMAGE;
614 end=end2=listEntries.end();
616 AddObjectToEnd(type,begin,--end2);
619 * \ingroup gdcmDicomDir
620 * \brief AddObjectToEnd
622 * @param begin iterator on the first HeaderEntry within the chained List
623 * @param end iterator on the last HeaderEntry within the chained List
625 void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin,ListTag::iterator end)
632 case gdcmDicomDir::GDCM_DICOMDIR_META:
633 AddDicomDirMetaToEnd(begin,end);
635 case gdcmDicomDir::GDCM_DICOMDIR_PATIENT:
636 AddDicomDirPatientToEnd(begin,end);
638 case gdcmDicomDir::GDCM_DICOMDIR_STUDY:
639 AddDicomDirStudyToEnd(begin,end);
641 case gdcmDicomDir::GDCM_DICOMDIR_SERIE:
642 AddDicomDirSerieToEnd(begin,end);
644 case gdcmDicomDir::GDCM_DICOMDIR_IMAGE:
645 AddDicomDirImageToEnd(begin,end);
651 * \ingroup gdcmDicomDir
652 * \brief Well ... Not realy to end, there is only one occurence
653 * @param begin iterator on the first HeaderEntry within the chained List
654 * @param end iterator on the last HeaderEntry within the chained List
656 void gdcmDicomDir::AddDicomDirMetaToEnd(ListTag::iterator begin,ListTag::iterator end)
660 metaElems = new gdcmDicomDirMeta(begin,end,&tagHT,&listEntries);
664 * \ingroup gdcmDicomDir
665 * \brief AddDicomDirPatientToEnd
666 * @param begin iterator on the first HeaderEntry within the chained List
667 * @param end iterator on the last HeaderEntry within the chained List
669 void gdcmDicomDir::AddDicomDirPatientToEnd(ListTag::iterator begin,ListTag::iterator end)
671 patients.push_back(new gdcmDicomDirPatient(begin,end,&tagHT, &listEntries));
675 * \ingroup gdcmDicomDir
676 * \brief AddDicomDirStudyToEnd
677 * @param begin iterator on the first HeaderEntry within the chained List
678 * @param end iterator on the last HeaderEntry within the chained List
680 void gdcmDicomDir::AddDicomDirStudyToEnd(ListTag::iterator begin,ListTag::iterator end)
682 if(patients.size()>0)
684 ListDicomDirPatient::iterator itp=patients.end();
686 (*itp)->AddDicomDirStudy(new gdcmDicomDirStudy(begin,end,&tagHT, &listEntries));
690 * \ingroup gdcmDicomDir
691 * \brief AddDicomDirSerieToEnd
692 * @param begin iterator on the first HeaderEntry within the chained List
693 * @param end iterator on the last HeaderEntry within the chained List
695 void gdcmDicomDir::AddDicomDirSerieToEnd(ListTag::iterator begin,ListTag::iterator end)
697 if(patients.size()>0)
699 ListDicomDirPatient::iterator itp=patients.end();
702 if((*itp)->GetDicomDirStudies().size()>0)
704 ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
706 (*itst)->AddDicomDirSerie(new gdcmDicomDirSerie(begin,end,&tagHT, &listEntries));
712 * \ingroup gdcmDicomDir
713 * \brief AddDicomDirImageToEnd
714 * @param begin iterator on the first HeaderEntry within the chained List
715 * @param end iterator on the last HeaderEntry within the chained List
717 void gdcmDicomDir::AddDicomDirImageToEnd(ListTag::iterator begin,ListTag::iterator end)
719 if(patients.size()>0)
721 ListDicomDirPatient::iterator itp=patients.end();
724 if((*itp)->GetDicomDirStudies().size()>0)
726 ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
729 if((*itst)->GetDicomDirSeries().size()>0)
731 ListDicomDirSerie::iterator its=(*itst)->GetDicomDirSeries().end();
733 (*its)->AddDicomDirImage(new gdcmDicomDirImage(begin,end,&tagHT, &listEntries));
740 * \ingroup gdcmDicomDir
741 * \brief for each Header of the chained list, add/update the Patient/Study/Serie/Image info
742 * @param path path of the root directory
743 * @param list chained list of Headers
745 void gdcmDicomDir::SetElements(std::string &path, ListHeader &list)
747 std::string patPrevName="", patPrevID="";
748 std::string studPrevInstanceUID="", studPrevID="";
749 std::string serPrevInstanceUID="", serPrevID="";
751 std::string patCurName, patCurID;
752 std::string studCurInstanceUID, studCurID;
753 std::string serCurInstanceUID, serCurID;
755 SetElement(path,GDCM_DICOMDIR_META,NULL);
757 ListTag::iterator debPat=listEntries.begin();
758 for(ListHeader::iterator it=list.begin();it!=list.end();++it)
760 // get the current file characteristics
761 patCurName= (*it)->GetEntryByNumber(0x0010,0x0010);
762 patCurID= (*it)->GetEntryByNumber(0x0010,0x0011);
763 studCurInstanceUID=(*it)->GetEntryByNumber(0x0020,0x000d);
764 studCurID= (*it)->GetEntryByNumber(0x0020,0x0010);
765 serCurInstanceUID= (*it)->GetEntryByNumber(0x0020,0x000e);
766 serCurID= (*it)->GetEntryByNumber(0x0020,0x0011);
768 if(patCurName!=patPrevName || patCurID!=patPrevID)
769 SetElement(path,GDCM_DICOMDIR_PATIENT,*it);
771 // if new Study Deal with 'STUDY' Elements
772 if(studCurInstanceUID!=studPrevInstanceUID || studCurID!=studPrevID)
773 SetElement(path,GDCM_DICOMDIR_STUDY,*it);
775 // if new Serie Deal with 'SERIE' Elements
776 if(serCurInstanceUID!=serPrevInstanceUID || serCurID!=serPrevID)
777 SetElement(path,GDCM_DICOMDIR_SERIE,*it);
779 // Always Deal with 'IMAGE' Elements
780 SetElement(path,GDCM_DICOMDIR_IMAGE,*it);
782 patPrevName= patCurName;
784 studPrevInstanceUID=studCurInstanceUID;
785 studPrevID= studCurID;
786 serPrevInstanceUID= serCurInstanceUID;
792 * \ingroup gdcmDicomDir
793 * \brief adds to the HTable and at the end of the Chained List
794 * the gdcmEntries (Dicom Elements) corresponding to the given type
795 * @param path full path file name(only used when type = GDCM_DICOMDIR_IMAGE
796 * @param type gdcmObject type to create (GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...)
797 * @param header gdcmHeader of the current file
799 void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,gdcmHeader *header)
801 std::list<gdcmElement> elemList;
802 std::list<gdcmElement>::iterator it;
803 guint16 tmpGr, tmpEl;
804 gdcmDictEntry *dictEntry;
805 gdcmHeaderEntry *entry;
810 case GDCM_DICOMDIR_PATIENT:
811 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
813 case GDCM_DICOMDIR_STUDY:
814 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
816 case GDCM_DICOMDIR_SERIE:
817 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements();
819 case GDCM_DICOMDIR_IMAGE:
820 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements();
822 case GDCM_DICOMDIR_META:
823 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements();
829 for(it=elemList.begin();it!=elemList.end();++it)
833 dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
834 entry=new gdcmHeaderEntry(dictEntry);
835 entry->SetOffset(0); // just to avoid missprinting
838 val=header->GetEntryByNumber(tmpGr,tmpEl);
842 if(val==GDCM_UNFOUND)
844 if((tmpGr==0x0004) &&(tmpEl==0x1130) ) // File-set ID
846 // force to the *end* File Name
849 else if( (tmpGr==0x0004) && (tmpEl==0x1500) ) // Only used for image
851 if(header->GetFileName().substr(0,path.length())!=path)
853 dbg.Verbose(0, "gdcmDicomDir::SetElement : the base path of file name is incorrect");
854 val=header->GetFileName();
857 val=&(header->GetFileName().c_str()[path.length()]);
867 if (header->GetEntryLengthByNumber(tmpGr,tmpEl)== 0)
871 entry->SetValue(val);
875 if(dictEntry->GetGroup()==0xfffe)
877 entry->SetLength(entry->GetValue().length());
879 else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") )
883 else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") )
887 else if(dictEntry->GetVR()=="SQ")
889 entry->SetLength(0xffffffff);
893 entry->SetLength(entry->GetValue().length());
896 //AddHeaderEntry(entry); // both in H Table and in chained list
897 tagHT.insert( PairHT( entry->GetKey(),entry) );
898 listEntries.push_back(entry);
899 //wasUpdated = 1; // is private
903 * \ingroup gdcmDicomDir
904 * \brief compares two dgcmHeaders
906 bool gdcmDicomDir::HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2)
908 return(*header1<*header2);
912 * \ingroup gdcmDicomDir
913 * \brief Sets the accurate value for the (0x0004,0x1220) element of a DICOMDIR
916 void gdcmDicomDir::UpdateDirectoryRecordSequenceLength() {
918 ListTag::iterator it;
921 for(it=listEntries.begin();it!=listEntries.end();++it) {
922 gr = (*it)->GetGroup();
923 el = (*it)->GetElement();
926 if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) {
927 offset += 4; // explicit VR AND OB, OW, SQ : 4 more bytes
929 offset += 2 + 2 + 4 + (*it)->GetLength();
931 offset += 4; // delimiters don't have a value.
934 bool res=SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
938 //-----------------------------------------------------------------------------