1 /*=========================================================================
4 Module: $RCSfile: gdcmDicomDir.cxx,v $
6 Date: $Date: 2004/10/10 00:42:54 $
7 Version: $Revision: 1.72 $
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 =========================================================================*/
19 #include "gdcmDicomDir.h"
20 #include "gdcmDicomDirStudy.h"
21 #include "gdcmDicomDirSerie.h"
22 #include "gdcmDicomDirImage.h"
23 #include "gdcmDirList.h"
25 #include "gdcmDebug.h"
26 #include "gdcmGlobal.h"
27 #include "gdcmHeader.h"
28 #include "gdcmSeqEntry.h"
29 #include "gdcmSQItem.h"
30 #include "gdcmValEntry.h"
34 #include <sys/types.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
91 getcwd(dummy, (size_t)1000);
92 SetFileName( dummy ); // will be converted into a string
95 if ( parseDir ) // user asked for a recursive parsing of a root directory
97 MetaElems = NewMeta();
99 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : Parse directory"
100 " and create the DicomDir");
105 /// \todo if parseDir == false, it should be tagged as an error
106 // NON ! il suffit d'appeler ParseDirectory()
107 // apres le constructeur
110 else // Only if user passed a DICOMDIR
112 // Directory record sequence
113 gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220);
116 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record"
117 " sequence (0x0004,0x1220)");
118 /// \todo FIXME : what do we do when the parsed file IS NOT a
126 * \brief Canonical destructor
128 gdcmDicomDir::~gdcmDicomDir()
130 SetStartMethod(NULL);
131 SetProgressMethod(NULL);
133 for(ListDicomDirPatient::iterator cc = Patients.begin();
145 //-----------------------------------------------------------------------------
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();
158 cc != Patients.end();
161 (*cc)->SetPrintLevel( PrintLevel );
166 //-----------------------------------------------------------------------------
169 * \brief This predicate, based on hopefully reasonable heuristics,
170 * decides whether or not the current header was properly parsed
171 * and contains the mandatory information for being considered as
172 * a well formed and usable DicomDir.
173 * @return true when gdcmDocument is the one of a reasonable DicomDir,
176 bool gdcmDicomDir::IsReadable()
178 if( !gdcmDocument::IsReadable() )
186 if( Patients.size() <= 0 )
195 * \brief Sets all fields to NULL
198 void gdcmDicomDir::Initialize()
201 ProgressMethod = NULL;
203 StartMethodArgDelete = NULL;
204 ProgressMethodArgDelete = NULL;
205 EndMethodArgDelete = NULL;
218 * \ingroup gdcmDicomDir
219 * \brief fills the whole structure, starting from a root Directory
221 void gdcmDicomDir::ParseDirectory()
223 CreateDicomDirChainedList( GetFileName() );
228 * \ingroup gdcmDicomDir
229 * \brief Set the start method to call when the parsing of the directory starts
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::SetStartMethod(gdcmMethod* method, void* arg,
236 gdcmMethod* argDelete )
238 if( StartArg && StartMethodArgDelete )
240 StartMethodArgDelete( StartArg );
243 StartMethod = method;
245 StartMethodArgDelete = argDelete;
249 * \ingroup gdcmDicomDir
250 * \brief Set the method to delete the argument
251 * The argument is destroyed when the method is changed or when the
253 * @param method Method to call to delete the argument
255 void gdcmDicomDir::SetStartMethodArgDelete(gdcmMethod* method)
257 StartMethodArgDelete = method;
261 * \ingroup gdcmDicomDir
262 * \brief Set the progress method to call when the parsing of the directory progress
263 * @param method Method to call
264 * @param arg Argument to pass to the method
265 * @param argDelete Argument
266 * \warning In python : the arg parameter isn't considered
268 void gdcmDicomDir::SetProgressMethod(gdcmMethod* method, void* arg,
269 gdcmMethod* argDelete )
271 if( ProgressArg && ProgressMethodArgDelete )
273 ProgressMethodArgDelete( ProgressArg );
276 ProgressMethod = method;
278 ProgressMethodArgDelete = 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
286 * @param method Method to call to delete the argument
288 void gdcmDicomDir::SetProgressMethodArgDelete(gdcmMethod* method)
290 ProgressMethodArgDelete = method;
294 * \ingroup gdcmDicomDir
295 * \brief Set the end method to call when the parsing of the directory ends
296 * @param method Method to call
297 * @param arg Argument to pass to the method
298 * @param argDelete Argument
299 * \warning In python : the arg parameter isn't considered
301 void gdcmDicomDir::SetEndMethod(gdcmMethod* method, void* arg,
302 gdcmMethod* argDelete )
304 if( EndArg && EndMethodArgDelete )
306 EndMethodArgDelete( EndArg );
311 EndMethodArgDelete = argDelete;
315 * \ingroup gdcmDicomDir
316 * \brief Set the method to delete the argument
317 * The argument is destroyed when the method is changed or when the class
319 * @param method Method to call to delete the argument
321 void gdcmDicomDir::SetEndMethodArgDelete(gdcmMethod* method)
323 EndMethodArgDelete = method;
327 * \ingroup gdcmDicomDir
328 * \brief writes on disc a DICOMDIR
329 * \ warning does NOT add the missing elements in the header :
330 * it's up to the user doing it !
331 * \todo : to be re-written using the DICOMDIR tree-like structure
332 * *not* the chained list
333 * (does NOT exist if the DICOMDIR is user-forged !)
334 * @param fileName file to be written to
335 * @return false only when fail to open
338 bool gdcmDicomDir::WriteDicomDir(std::string const& fileName)
340 uint16_t sq[4] = { 0x0004, 0x1220, 0xffff, 0xffff };
341 uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0xffff, 0xffff };
343 FILE* fp = fopen(fileName.c_str(), "wb");
346 printf("Failed to open(write) File [%s] \n", fileName.c_str());
350 uint8_t filePreamble[128];
351 memset(filePreamble, 0, 128);
352 fwrite(filePreamble,128,1,fp);
353 fwrite("DICM",4,1,fp);
355 gdcmDicomDirMeta *ptrMeta = GetDicomDirMeta();
356 ptrMeta->Write(fp, gdcmExplicitVR);
358 // force writing 0004|1220 [SQ ], that CANNOT exist within gdcmDicomDirMeta
359 fwrite(&sq[0],8,1,fp); // 0004 1220 ffff ffff
361 for(ListDicomDirPatient::iterator cc = Patients.begin();
362 cc != Patients.end();
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
591 // NULL when we Build Up (ex nihilo) a DICOMDIR
592 // or when we add the META elems
593 val = header->GetEntryByNumber(tmpGr, tmpEl);
600 if( val == GDCM_UNFOUND)
602 if( tmpGr == 0x0004 && tmpEl == 0x1130 ) // File-set ID
604 // force to the *end* File Name
605 val = gdcmUtil::GetName( path );
607 else if( tmpGr == 0x0004 && tmpEl == 0x1500 ) // Only used for image
609 if( header->GetFileName().substr(0, path.length()) != path )
611 dbg.Verbose(0, "gdcmDicomDir::SetElement : the base path"
612 " of file name is incorrect");
613 val = header->GetFileName();
617 val = &(header->GetFileName().c_str()[path.length()]);
627 if ( header->GetEntryLengthByNumber(tmpGr,tmpEl) == 0 )
631 // GDCM_UNFOUND or not !
633 entry->SetValue( val ); // troubles expected when vr=SQ ...
637 if( dictEntry->GetGroup() == 0xfffe )
639 entry->SetLength( entry->GetValue().length() ); // FIXME
641 else if( dictEntry->GetVR() == "UL" || dictEntry->GetVR() == "SL" )
645 else if( dictEntry->GetVR() == "US" || dictEntry->GetVR() == "SS" )
649 else if( dictEntry->GetVR() == "SQ" )
651 entry->SetLength( 0xffffffff );
655 entry->SetLength( entry->GetValue().length() );
659 if ( type == GDCM_DICOMDIR_META ) // fusible : should never print !
661 std::cout << "GDCM_DICOMDIR_META ?!? should never print that"
668 case GDCM_DICOMDIR_IMAGE:
669 AddDicomDirImageToEnd(si);
672 case GDCM_DICOMDIR_SERIE:
673 AddDicomDirSerieToEnd(si);
676 case GDCM_DICOMDIR_STUDY:
677 AddDicomDirStudyToEnd(si);
680 case GDCM_DICOMDIR_PATIENT:
681 AddDicomDirPatientToEnd(si);
687 //int count=1; // find a trick to increment
688 //s->AddEntry(si, count); // Seg Faults
693 * \brief CallStartMethod
695 void gdcmDicomDir::CallStartMethod()
701 StartMethod( StartArg );
706 * \ingroup gdcmDicomDir
707 * \brief CallProgressMethod
709 void gdcmDicomDir::CallProgressMethod()
713 ProgressMethod( ProgressArg );
718 * \ingroup gdcmDicomDir
719 * \brief CallEndMethod
721 void gdcmDicomDir::CallEndMethod()
730 //-----------------------------------------------------------------------------
733 * \ingroup gdcmDicomDir
734 * \brief create a 'gdcmDicomDir' from a DICOMDIR gdcmHeader
736 void gdcmDicomDir::CreateDicomDir()
738 // The list is parsed.
739 // When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found :
740 // 1 - we save the beginning iterator
741 // 2 - we continue to parse
742 // 3 - we find an other tag
743 // + we create the object for the precedent tag
746 // Directory record sequence
747 gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220);
750 dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record"
751 " sequence (0x0004,0x1220)");
752 /// \todo FIXME: what to do when the parsed file IS NOT a DICOMDIR file ?
756 gdcmSeqEntry* s = dynamic_cast<gdcmSeqEntry*>(e);
759 dbg.Verbose(0, "gdcmDicomDir::CreateDicomDir: no SeqEntry present");
760 // useless : (0x0004,0x1220) IS a Sequence !
764 gdcmDicomDirType type = gdcmDicomDir::GDCM_DICOMDIR_META;
765 MetaElems = NewMeta();
767 ListSQItem listItems = s->GetSQItems();
771 for( ListSQItem::iterator i = listItems.begin();
772 i !=listItems.end(); ++i )
774 d = (*i)->GetDocEntryByNumber(0x0004, 0x1430); // Directory Record Type
775 if ( gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(d) )
777 v = ValEntry->GetValue();
781 dbg.Verbose(0, "gdcmDicomDir::CreateDicomDir: not a ValEntry.");
785 if( v == "PATIENT " )
787 AddDicomDirPatientToEnd( *i );
788 type = gdcmDicomDir::GDCM_DICOMDIR_PATIENT;
790 else if( v == "STUDY " )
792 AddDicomDirStudyToEnd( *i );
793 type = gdcmDicomDir::GDCM_DICOMDIR_STUDY;
795 else if( v == "SERIES" )
797 AddDicomDirSerieToEnd( *i );
798 type = gdcmDicomDir::GDCM_DICOMDIR_SERIE;
800 else if( v == "IMAGE " )
802 AddDicomDirImageToEnd( *i );
803 type = gdcmDicomDir::GDCM_DICOMDIR_IMAGE;
807 // It was not a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
808 // neither an 'IMAGE' SQItem. Skip to next item.
815 * \ingroup gdcmDicomDir
816 * \brief Well ... there is only one occurence
818 void gdcmDicomDir::AddDicomDirMeta()
824 MetaElems = new gdcmDicomDirMeta( &TagHT );
828 * \ingroup gdcmDicomDir
829 * \brief AddDicomDirPatientToEnd
830 * @param s SQ Item to enqueue to the DicomPatient chained List
832 void gdcmDicomDir::AddDicomDirPatientToEnd(gdcmSQItem *s)
834 Patients.push_back(new gdcmDicomDirPatient(s, &TagHT));
838 * \ingroup gdcmDicomDir
839 * \brief AddDicomDirStudyToEnd
840 * @param s SQ Item to enqueue to the DicomDirStudy chained List
842 void gdcmDicomDir::AddDicomDirStudyToEnd(gdcmSQItem *s)
844 if( Patients.size() > 0 )
846 ListDicomDirPatient::iterator itp = Patients.end();
848 (*itp)->AddDicomDirStudy(new gdcmDicomDirStudy(s, &TagHT));
853 * \ingroup gdcmDicomDir
854 * \brief AddDicomDirSerieToEnd
855 * @param s SQ Item to enqueue to the DicomDirSerie chained List
857 void gdcmDicomDir::AddDicomDirSerieToEnd(gdcmSQItem *s)
859 if( Patients.size() > 0 )
861 ListDicomDirPatient::iterator itp = Patients.end();
864 if( (*itp)->GetDicomDirStudies().size() > 0 )
866 ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
868 (*itst)->AddDicomDirSerie(new gdcmDicomDirSerie(s, &TagHT));
874 * \ingroup gdcmDicomDir
875 * \brief AddDicomDirImageToEnd
876 * @param s SQ Item to enqueue to the DicomDirImage chained List
878 void gdcmDicomDir::AddDicomDirImageToEnd(gdcmSQItem *s)
880 if( Patients.size() > 0 )
882 ListDicomDirPatient::iterator itp = Patients.end();
885 if( (*itp)->GetDicomDirStudies().size() > 0 )
887 ListDicomDirStudy::iterator itst = (*itp)->GetDicomDirStudies().end();
890 if( (*itst)->GetDicomDirSeries().size() > 0 )
892 ListDicomDirSerie::iterator its = (*itst)->GetDicomDirSeries().end();
894 (*its)->AddDicomDirImage(new gdcmDicomDirImage(s, &TagHT));
901 * \ingroup gdcmDicomDir
902 * \brief for each Header of the chained list, add/update the Patient/Study/Serie/Image info
903 * @param path path of the root directory
904 * @param list chained list of Headers
906 void gdcmDicomDir::SetElements(std::string &path, VectDocument &list)
908 std::string patPrevName = "", patPrevID = "";
909 std::string studPrevInstanceUID = "", studPrevID = "";
910 std::string serPrevInstanceUID = "", serPrevID = "";
912 std::string patCurName, patCurID;
913 std::string studCurInstanceUID, studCurID;
914 std::string serCurInstanceUID, serCurID;
916 for( VectDocument::iterator it = list.begin();
917 it != list.end(); ++it )
919 // get the current file characteristics
920 patCurName = (*it)->GetEntryByNumber(0x0010,0x0010);
921 patCurID = (*it)->GetEntryByNumber(0x0010,0x0011);
922 studCurInstanceUID = (*it)->GetEntryByNumber(0x0020,0x000d);
923 studCurID = (*it)->GetEntryByNumber(0x0020,0x0010);
924 serCurInstanceUID = (*it)->GetEntryByNumber(0x0020,0x000e);
925 serCurID = (*it)->GetEntryByNumber(0x0020,0x0011);
927 if( patCurName != patPrevName || patCurID != patPrevID)
929 SetElement(path, GDCM_DICOMDIR_PATIENT, *it);
932 // if new Study Deal with 'STUDY' Elements
933 if( studCurInstanceUID != studPrevInstanceUID || studCurID != studPrevID )
935 SetElement(path, GDCM_DICOMDIR_STUDY, *it);
938 // if new Serie Deal with 'SERIE' Elements
939 if( serCurInstanceUID != serPrevInstanceUID || serCurID != serPrevID )
941 SetElement(path, GDCM_DICOMDIR_SERIE, *it);
944 // Always Deal with 'IMAGE' Elements
945 SetElement(path, GDCM_DICOMDIR_IMAGE, *it);
947 patPrevName = patCurName;
948 patPrevID = patCurID;
949 studPrevInstanceUID = studCurInstanceUID;
950 studPrevID = studCurID;
951 serPrevInstanceUID = serCurInstanceUID;
952 serPrevID = serCurID;
957 * \ingroup gdcmDicomDir
958 * \brief compares two dgcmHeaders
960 bool gdcmDicomDir::HeaderLessThan(gdcmDocument *header1, gdcmDocument *header2)
962 return *header1 < *header2;
965 //-----------------------------------------------------------------------------