1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDir.cxx,v $
6 Date: $Date: 2004/09/27 08:39:05 $
7 Version: $Revision: 1.70 $
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 =========================================================================*/
21 #include <sys/types.h>
29 #include "gdcmDicomDir.h"
30 #include "gdcmDicomDirStudy.h"
31 #include "gdcmDicomDirSerie.h"
32 #include "gdcmDicomDirImage.h"
33 #include "gdcmDirList.h"
35 #include "gdcmDebug.h"
36 #include "gdcmGlobal.h"
37 #include "gdcmHeader.h"
38 #include "gdcmSeqEntry.h"
39 #include "gdcmSQItem.h"
40 #include "gdcmValEntry.h"
42 //-----------------------------------------------------------------------------
43 // For full DICOMDIR description, see:
44 // PS 3.3-2003, pages 731-750
45 //-----------------------------------------------------------------------------
46 // Constructor / Destructor
49 * \ingroup gdcmDicomDir
50 * \brief Constructor : creates an empty gdcmDicomDir
52 gdcmDicomDir::gdcmDicomDir()
55 Initialize(); // sets all private fields to NULL
56 std::string pathBidon = "Bidon"; // Sorry, NULL not allowed ...
57 metaElems = NewMeta();
61 * \brief Constructor Parses recursively the directory and creates the DicomDir
62 * or uses an already built DICOMDIR, depending on 'parseDir' value.
63 * @param fileName name
64 * - of the root directory (parseDir = true)
65 * - of the DICOMDIR (parseDir = false)
66 * @param parseDir boolean
67 * - true if user passed an entry point
68 * and wants to explore recursively the directories
69 * - false if user passed an already built DICOMDIR file
72 gdcmDicomDir::gdcmDicomDir(std::string const & fileName, bool parseDir ):
73 gdcmDocument( fileName )
75 // Whatever user passed (a root directory or a DICOMDIR)
76 // and whatever the value of parseDir was,
77 // gdcmDocument is already executed
78 Initialize(); // sets all private fields to NULL
80 // if user passed a root directory, sure we didn't get anything
82 if ( TagHT.begin() == TagHT.end() ) // when user passed a Directory to parse
84 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry HT empty");
86 if ( fileName.size() == 1 && fileName[0] == '.' )
88 // user passed '.' as Name
89 // we get current directory name
90 char* dummy = new char[1000];
91 getcwd(dummy, (size_t)1000);
92 SetFileName( dummy ); // will be converted into a string
93 delete[] dummy; // no longer needed
96 if ( parseDir ) // user asked for a recursive parsing of a root directory
98 metaElems = NewMeta();
100 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : Parse directory"
101 " and create the DicomDir");
106 /// \todo if parseDir == false, it should be tagged as an error
107 // NON ! il suffit d'appeler ParseDirectory()
108 // apres le constructeur
111 else // Only if user passed a DICOMDIR
113 // Directory record sequence
114 gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220);
117 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record"
118 " sequence (0x0004,0x1220)");
119 /// \todo FIXME : what do we do when the parsed file IS NOT a
127 * \brief Canonical destructor
129 gdcmDicomDir::~gdcmDicomDir()
131 SetStartMethod(NULL);
132 SetProgressMethod(NULL);
134 for(ListDicomDirPatient::iterator cc = patients.begin();
146 //-----------------------------------------------------------------------------
149 * \brief Canonical Printer
151 void gdcmDicomDir::Print(std::ostream &os)
155 metaElems->SetPrintLevel(PrintLevel);
156 metaElems->Print(os);
158 for(ListDicomDirPatient::iterator cc = patients.begin();
159 cc != patients.end();
162 (*cc)->SetPrintLevel( PrintLevel );
167 //-----------------------------------------------------------------------------
170 * \brief This predicate, based on hopefully reasonable heuristics,
171 * decides whether or not the current header was properly parsed
172 * and contains the mandatory information for being considered as
173 * a well formed and usable DicomDir.
174 * @return true when gdcmDocument is the one of a reasonable DicomDir,
177 bool gdcmDicomDir::IsReadable()
179 if( !gdcmDocument::IsReadable() )
187 if( patients.size() <= 0 )
196 * \brief Sets all fields to NULL
199 void gdcmDicomDir::Initialize()
202 progressMethod = NULL;
204 startMethodArgDelete = NULL;
205 progressMethodArgDelete = NULL;
206 endMethodArgDelete = NULL;
219 * \ingroup gdcmDicomDir
220 * \brief fills the whole structure, starting from a root Directory
222 void gdcmDicomDir::ParseDirectory()
224 CreateDicomDirChainedList( GetFileName() );
229 * \ingroup gdcmDicomDir
230 * \brief Set the start method to call when the parsing of the directory starts
231 * @param method Method to call
232 * @param arg Argument to pass to the method
233 * @param argDelete Argument
234 * \warning In python : the arg parameter isn't considered
236 void gdcmDicomDir::SetStartMethod(gdcmMethod* method, void* arg,
237 gdcmMethod* argDelete )
239 if( startArg && startMethodArgDelete )
241 startMethodArgDelete( startArg );
244 startMethod = method;
246 startMethodArgDelete = argDelete;
250 * \ingroup gdcmDicomDir
251 * \brief Set the method to delete the argument
252 * The argument is destroyed when the method is changed or when the
254 * @param method Method to call to delete the argument
256 void gdcmDicomDir::SetStartMethodArgDelete(gdcmMethod* method)
258 startMethodArgDelete = method;
262 * \ingroup gdcmDicomDir
263 * \brief Set the progress method to call when the parsing of the directory progress
264 * @param method Method to call
265 * @param arg Argument to pass to the method
266 * @param argDelete Argument
267 * \warning In python : the arg parameter isn't considered
269 void gdcmDicomDir::SetProgressMethod(gdcmMethod* method, void* arg,
270 gdcmMethod* argDelete )
272 if( progressArg && progressMethodArgDelete )
274 progressMethodArgDelete( progressArg );
277 progressMethod = method;
279 progressMethodArgDelete = argDelete;
283 * \ingroup gdcmDicomDir
284 * \brief Set the method to delete the argument
285 * The argument is destroyed when the method is changed or when the
287 * @param method Method to call to delete the argument
289 void gdcmDicomDir::SetProgressMethodArgDelete(gdcmMethod* method)
291 progressMethodArgDelete = method;
295 * \ingroup gdcmDicomDir
296 * \brief Set the end method to call when the parsing of the directory ends
297 * @param method Method to call
298 * @param arg Argument to pass to the method
299 * @param argDelete Argument
300 * \warning In python : the arg parameter isn't considered
302 void gdcmDicomDir::SetEndMethod(gdcmMethod* method, void* arg,
303 gdcmMethod* argDelete )
305 if( endArg && endMethodArgDelete )
307 endMethodArgDelete( endArg );
312 endMethodArgDelete = argDelete;
316 * \ingroup gdcmDicomDir
317 * \brief Set the method to delete the argument
318 * The argument is destroyed when the method is changed or when the class
320 * @param method Method to call to delete the argument
322 void gdcmDicomDir::SetEndMethodArgDelete(gdcmMethod* method)
324 endMethodArgDelete = method;
328 * \ingroup gdcmDicomDir
329 * \brief writes on disc a DICOMDIR
330 * \ warning does NOT add the missing elements in the header :
331 * it's up to the user doing it !
332 * \todo : to be re-written using the DICOMDIR tree-like structure
333 * *not* the chained list
334 * (does NOT exist if the DICOMDIR is user-forged !)
335 * @param fileName file to be written to
336 * @return false only when fail to open
339 bool gdcmDicomDir::WriteDicomDir(std::string const& fileName)
341 uint16_t sq[4] = { 0x0004, 0x1220, 0xffff, 0xffff };
342 uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0xffff, 0xffff };
344 FILE* fp = fopen(fileName.c_str(), "wb");
347 printf("Failed to open(write) File [%s] \n", fileName.c_str());
351 uint8_t* filePreamble = new uint8_t[128];
352 memset(filePreamble, 0, 128);
353 fwrite(filePreamble,128,1,fp);
354 fwrite("DICM",4,1,fp);
355 delete[] filePreamble;
357 gdcmDicomDirMeta *ptrMeta = GetDicomDirMeta();
358 ptrMeta->Write(fp, gdcmExplicitVR);
360 // force writing 0004|1220 [SQ ], that CANNOT exist within gdcmDicomDirMeta
361 fwrite(&sq[0],8,1,fp); // 0004 1220 ffff ffff
363 for(ListDicomDirPatient::iterator cc = patients.begin();cc!=patients.end();++cc)
365 (*cc)->Write( fp, gdcmExplicitVR );
368 // force writing Sequence Delimitation Item
369 fwrite(&sqt[0],8,1,fp); // fffe e0dd ffff ffff
375 //-----------------------------------------------------------------------------
379 * \ingroup gdcmDicomDir
380 * \brief create a gdcmDocument-like chained list from a root Directory
381 * @param path entry point of the tree-like structure
383 void gdcmDicomDir::CreateDicomDirChainedList(std::string const & path)
386 gdcmDirList fileList(path,1); // gets recursively the file list
387 unsigned int count = 0;
394 for( gdcmDirList::iterator it = fileList.begin();
395 it != fileList.end();
398 progress = (float)(count+1)/(float)fileList.size();
399 CallProgressMethod();
405 header = new gdcmHeader( it->c_str() );
409 "gdcmDicomDir::CreateDicomDirChainedList: "
410 "failure in new Header ",
414 if( header->IsReadable() )
416 // Add the file header to the chained list:
417 list.push_back(header);
419 "gdcmDicomDir::CreateDicomDirChainedList: readable ",
429 // sorts Patient/Study/Serie/
430 std::sort(list.begin(), list.end(), gdcmDicomDir::HeaderLessThan );
432 std::string tmp = fileList.GetDirName();
433 //for each Header of the chained list, add/update the Patient/Study/Serie/Image info
434 SetElements(tmp, list);
439 * \ingroup gdcmDicomDir
440 * \brief adds *the* Meta to a partially created DICOMDIR
443 gdcmDicomDirMeta * gdcmDicomDir::NewMeta()
445 gdcmDicomDirMeta *m = new gdcmDicomDirMeta( &TagHT );
447 if ( TagHT.begin() != TagHT.end() ) // after Document Parsing
449 TagDocEntryHT::iterator lastOneButSequence = TagHT.end();
450 lastOneButSequence --;
451 // ALL the 'out of Sequence' Tags belong to Meta Elems
452 // (we skip 0004|1220 [Directory record sequence] )
453 for ( TagDocEntryHT::iterator cc = TagHT.begin();
454 cc != lastOneButSequence;
457 m->AddDocEntry( cc->second );
460 else // after root directory parsing
462 std::list<gdcmElement> elemList;
463 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements();
464 m->FillObject(elemList);
466 m->SetSQItemNumber(0); // To avoid further missprinting
471 * \brief adds a new Patient (with the basic elements) to a partially created DICOMDIR
473 gdcmDicomDirPatient * gdcmDicomDir::NewPatient()
475 std::list<gdcmElement>::iterator it;
476 uint16_t tmpGr,tmpEl;
477 gdcmDictEntry *dictEntry;
480 std::list<gdcmElement> elemList;
481 elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
482 gdcmSQItem *s = new gdcmSQItem(0);
484 // for all the DicomDirPatient Elements
485 for( it = elemList.begin(); it != elemList.end(); ++it )
489 dictEntry = GetPubDict()->GetDictEntryByNumber(tmpGr, tmpEl);
490 entry = new gdcmValEntry( dictEntry );
491 entry->SetOffset(0); // just to avoid further missprinting
492 entry->SetValue( it->value );
494 // dealing with value length ...
496 if( dictEntry->GetGroup() == 0xfffe)
498 entry->SetLength(entry->GetValue().length());
500 else if( dictEntry->GetVR() == "UL" || dictEntry->GetVR() == "SL" )
502 entry->SetLength( 4 );
504 else if( dictEntry->GetVR() == "US" || dictEntry->GetVR() == "SS" )
508 else if( dictEntry->GetVR() == "SQ" )
510 entry->SetLength( 0xffffffff );
514 entry->SetLength( entry->GetValue().length() );
516 s->AddDocEntry( entry );
519 gdcmDicomDirPatient *p = new gdcmDicomDirPatient(s, &TagHT);
520 patients.push_front( p );
526 * \brief adds to the HTable
527 * the gdcmEntries (Dicom Elements) corresponding to the given type
528 * @param path full path file name (only used when type = GDCM_DICOMDIR_IMAGE
529 * @param type gdcmDicomDirObject type to create (GDCM_DICOMDIR_PATIENT,
530 * GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...)
531 * @param header gdcmHeader of the current file
533 void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,
534 gdcmDocument *header)
536 std::list<gdcmElement> elemList;
537 std::list<gdcmElement>::iterator it;
538 uint16_t tmpGr, tmpEl;
539 gdcmDictEntry *dictEntry;
542 gdcmSQItem *si = new gdcmSQItem(0); // all the items will be at level 1
545 case GDCM_DICOMDIR_IMAGE:
546 elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements();
549 case GDCM_DICOMDIR_SERIE:
550 elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements();
553 case GDCM_DICOMDIR_STUDY:
554 elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
557 case GDCM_DICOMDIR_PATIENT:
558 elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
561 case GDCM_DICOMDIR_META:
562 elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements();
568 // removed all the seems-to-be-useless stuff about Referenced Image Sequence
569 // to avoid further troubles
570 // imageElem 0008 1140 "" // Referenced Image Sequence
571 // imageElem fffe e000 "" // 'no length' item : length to be set to 0xffffffff later
572 // imageElem 0008 1150 "" // Referenced SOP Class UID : to be set/forged later
573 // imageElem 0008 1155 "" // Referenced SOP Instance UID : to be set/forged later
574 // imageElem fffe e00d "" // Item delimitation : length to be set to ZERO later
575 // for all the relevant elements found in their own spot of the DicomDir.dic
576 // FIXME : troubles found when it's a SeqEntry
578 for( it = elemList.begin(); it != elemList.end(); ++it)
582 dictEntry = GetPubDict()->GetDictEntryByNumber(tmpGr, tmpEl);
584 entry = new gdcmValEntry( dictEntry ); // Be sure it's never a BinEntry !
586 entry->SetOffset(0); // just to avoid further missprinting
587 entry->SetLength(0); // just to avoid further missprinting
589 if( header ) // NULL when we Build Up (ex nihilo) a DICOMDIR
590 // or when we add the META elems
591 val = header->GetEntryByNumber(tmpGr, tmpEl);
595 if( val == GDCM_UNFOUND)
597 if( tmpGr == 0x0004 && tmpEl == 0x1130 ) // File-set ID
599 // force to the *end* File Name
600 val = GetName( path );
602 else if( tmpGr == 0x0004 && tmpEl == 0x1500 ) // Only used for image
604 if( header->GetFileName().substr(0, path.length()) != path )
606 dbg.Verbose(0, "gdcmDicomDir::SetElement : the base path"
607 " of file name is incorrect");
608 val = header->GetFileName();
611 val = &(header->GetFileName().c_str()[path.length()]);
618 if ( header->GetEntryLengthByNumber(tmpGr,tmpEl) == 0 )
622 // GDCM_UNFOUND or not !
624 entry->SetValue( val ); // troubles expected when vr=SQ ...
628 if( dictEntry->GetGroup() == 0xfffe )
630 entry->SetLength( entry->GetValue().length() ); // FIXME
632 else if( dictEntry->GetVR() == "UL" || dictEntry->GetVR() == "SL" )
636 else if( dictEntry->GetVR() == "US" || dictEntry->GetVR() == "SS" )
640 else if( dictEntry->GetVR() == "SQ" )
642 entry->SetLength( 0xffffffff );
646 entry->SetLength( entry->GetValue().length() );
650 if ( type == GDCM_DICOMDIR_META ) // fusible : should never print !
652 std::cout << "GDCM_DICOMDIR_META ?!? should never print that"
659 case GDCM_DICOMDIR_IMAGE:
660 AddDicomDirImageToEnd(si);
663 case GDCM_DICOMDIR_SERIE:
664 AddDicomDirSerieToEnd(si);
667 case GDCM_DICOMDIR_STUDY:
668 AddDicomDirStudyToEnd(si);
671 case GDCM_DICOMDIR_PATIENT:
672 AddDicomDirPatientToEnd(si);
678 //int count=1; // find a trick to increment
679 //s->AddEntry(si, count); // Seg Faults
684 * \brief CallStartMethod
686 void gdcmDicomDir::CallStartMethod()
692 startMethod( startArg );
697 * \ingroup gdcmDicomDir
698 * \brief CallProgressMethod
700 void gdcmDicomDir::CallProgressMethod()
704 progressMethod( progressArg );
709 * \ingroup gdcmDicomDir
710 * \brief CallEndMethod
712 void gdcmDicomDir::CallEndMethod()
721 //-----------------------------------------------------------------------------
724 * \ingroup gdcmDicomDir
725 * \brief create a 'gdcmDicomDir' from a DICOMDIR gdcmHeader
727 void gdcmDicomDir::CreateDicomDir()
729 // The list is parsed.
730 // When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found :
731 // 1 - we save the beginning iterator
732 // 2 - we continue to parse
733 // 3 - we find an other tag
734 // + we create the object for the precedent tag
737 // Directory record sequence
738 gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220);
741 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record"
742 " sequence (0x0004,0x1220)");
743 /// \todo FIXME: what to do when the parsed file IS NOT a DICOMDIR file ?
747 gdcmSeqEntry* s = dynamic_cast<gdcmSeqEntry*>(e);
750 dbg.Verbose(0, "gdcmDicomDir::CreateDicomDir: no SeqEntry present");
751 // useless : (0x0004,0x1220) IS a Sequence !
755 gdcmDicomDirType type = gdcmDicomDir::GDCM_DICOMDIR_META;
756 metaElems = NewMeta();
758 ListSQItem listItems = s->GetSQItems();
762 for( ListSQItem::iterator i = listItems.begin();
763 i !=listItems.end(); ++i )
765 d = (*i)->GetDocEntryByNumber(0x0004, 0x1430); // Directory Record Type
766 if ( gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(d) )
768 v = ValEntry->GetValue();
772 dbg.Verbose(0, "gdcmDicomDir::CreateDicomDir: not a ValEntry.");
776 if( v == "PATIENT " )
778 AddDicomDirPatientToEnd( *i );
779 type = gdcmDicomDir::GDCM_DICOMDIR_PATIENT;
781 else if( v == "STUDY " )
783 AddDicomDirStudyToEnd( *i );
784 type = gdcmDicomDir::GDCM_DICOMDIR_STUDY;
786 else if( v == "SERIES" )
788 AddDicomDirSerieToEnd( *i );
789 type = gdcmDicomDir::GDCM_DICOMDIR_SERIE;
791 else if( v == "IMAGE " )
793 AddDicomDirImageToEnd( *i );
794 type = gdcmDicomDir::GDCM_DICOMDIR_IMAGE;
798 // It was not a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
799 // neither an 'IMAGE' SQItem. Skip to next item.
806 * \ingroup gdcmDicomDir
807 * \brief Well ... there is only one occurence
809 void gdcmDicomDir::AddDicomDirMeta()
815 metaElems = new gdcmDicomDirMeta( &TagHT );
819 * \ingroup gdcmDicomDir
820 * \brief AddDicomDirPatientToEnd
821 * @param s SQ Item to enqueue to the DicomPatient chained List
823 void gdcmDicomDir::AddDicomDirPatientToEnd(gdcmSQItem *s)
825 patients.push_back(new gdcmDicomDirPatient(s, &TagHT));
829 * \ingroup gdcmDicomDir
830 * \brief AddDicomDirStudyToEnd
831 * @param s SQ Item to enqueue to the DicomDirStudy chained List
833 void gdcmDicomDir::AddDicomDirStudyToEnd(gdcmSQItem *s)
835 if( patients.size() > 0 )
837 ListDicomDirPatient::iterator itp = patients.end();
839 (*itp)->AddDicomDirStudy(new gdcmDicomDirStudy(s, &TagHT));
844 * \ingroup gdcmDicomDir
845 * \brief AddDicomDirSerieToEnd
846 * @param s SQ Item to enqueue to the DicomDirSerie chained List
848 void gdcmDicomDir::AddDicomDirSerieToEnd(gdcmSQItem *s)
850 if( patients.size() > 0 )
852 ListDicomDirPatient::iterator itp = patients.end();
855 if( (*itp)->GetDicomDirStudies().size() > 0 )
857 ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
859 (*itst)->AddDicomDirSerie(new gdcmDicomDirSerie(s, &TagHT));
865 * \ingroup gdcmDicomDir
866 * \brief AddDicomDirImageToEnd
867 * @param s SQ Item to enqueue to the DicomDirImage chained List
869 void gdcmDicomDir::AddDicomDirImageToEnd(gdcmSQItem *s)
871 if( patients.size() > 0 )
873 ListDicomDirPatient::iterator itp = patients.end();
876 if( (*itp)->GetDicomDirStudies().size() > 0 )
878 ListDicomDirStudy::iterator itst = (*itp)->GetDicomDirStudies().end();
881 if( (*itst)->GetDicomDirSeries().size() > 0 )
883 ListDicomDirSerie::iterator its = (*itst)->GetDicomDirSeries().end();
885 (*its)->AddDicomDirImage(new gdcmDicomDirImage(s, &TagHT));
892 * \ingroup gdcmDicomDir
893 * \brief for each Header of the chained list, add/update the Patient/Study/Serie/Image info
894 * @param path path of the root directory
895 * @param list chained list of Headers
897 void gdcmDicomDir::SetElements(std::string &path, VectDocument &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;
907 for( VectDocument::iterator it = list.begin();
908 it != list.end(); ++it )
910 // get the current file characteristics
911 patCurName = (*it)->GetEntryByNumber(0x0010,0x0010);
912 patCurID = (*it)->GetEntryByNumber(0x0010,0x0011);
913 studCurInstanceUID = (*it)->GetEntryByNumber(0x0020,0x000d);
914 studCurID = (*it)->GetEntryByNumber(0x0020,0x0010);
915 serCurInstanceUID = (*it)->GetEntryByNumber(0x0020,0x000e);
916 serCurID = (*it)->GetEntryByNumber(0x0020,0x0011);
918 if( patCurName != patPrevName || patCurID != patPrevID)
920 SetElement(path, GDCM_DICOMDIR_PATIENT, *it);
923 // if new Study Deal with 'STUDY' Elements
924 if( studCurInstanceUID != studPrevInstanceUID || studCurID != studPrevID )
926 SetElement(path, GDCM_DICOMDIR_STUDY, *it);
929 // if new Serie Deal with 'SERIE' Elements
930 if( serCurInstanceUID != serPrevInstanceUID || serCurID != serPrevID )
932 SetElement(path, GDCM_DICOMDIR_SERIE, *it);
935 // Always Deal with 'IMAGE' Elements
936 SetElement(path, GDCM_DICOMDIR_IMAGE, *it);
938 patPrevName = patCurName;
939 patPrevID = patCurID;
940 studPrevInstanceUID = studCurInstanceUID;
941 studPrevID = studCurID;
942 serPrevInstanceUID = serCurInstanceUID;
943 serPrevID = serCurID;
948 * \ingroup gdcmDicomDir
949 * \brief compares two dgcmHeaders
951 bool gdcmDicomDir::HeaderLessThan(gdcmDocument *header1, gdcmDocument *header2)
953 return *header1 < *header2;
956 //-----------------------------------------------------------------------------