From: jpr Date: Fri, 19 Mar 2004 15:16:13 +0000 (+0000) Subject: Now the tree-like structure describing a DICOMDIR comming from an already X-Git-Tag: Version0.5.bp~287 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9b3db5f141ec2b11eadefaa2ea2a3a20058b37f9;p=gdcm.git Now the tree-like structure describing a DICOMDIR comming from an already existing DICOMDIR file is consistent with the home-made tree-like structure build ex-nihilo or build from the files held (recursively) in a Directory (function gdcmDicomDir::CheckBoundaries() added) --- diff --git a/ChangeLog b/ChangeLog index 48bbcc81..62167983 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,9 @@ 2004-03-17 Jean-Pierre Roux * REM (Eric Boix bug) : removal of meaningless - gdcmDicomDirImage::NewImage function. + gdcmDicomDirImage::NewImage function. * FIX now file names and directory name are written properly in the DICOMDIR - now gdcmDicomDir constructor may be call without any trick + * FIX now gdcmDicomDir constructor may be call without any trick about the name 2004-03-16 Eric Boix diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index d61e5c11..2939043f 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -76,8 +76,11 @@ gdcmDicomDir::gdcmDicomDir(const char *Name, bool parseDir, ParseDirectory(); } } - else + else { CreateDicomDir(); + CheckBoundaries(); // JPR + } + } /* @@ -397,12 +400,50 @@ void gdcmDicomDir::CreateDicomDirChainedList(std::string path) std::sort(list.begin(),list.end(),gdcmDicomDir::HeaderLessThan); std::string tmp=fileList.GetDirName(); + //for each Header of the chained list, add/update the Patient/Study/Serie/Image info SetElements(tmp,list); - + CallEndMethod(); } + + +void gdcmDicomDir::CheckBoundaries() +{ + +cout <<"entree ds CheckBoundaries " <ResetBoundaries(0); + + itPatient = GetDicomDirPatients().begin(); + while ( itPatient != GetDicomDirPatients().end() ) { + (*itPatient)->ResetBoundaries(1); + itStudy = ((*itPatient)->GetDicomDirStudies()).begin(); + while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { + (*itStudy)->ResetBoundaries(1); + itSerie = ((*itStudy)->GetDicomDirSeries()).begin(); + while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { + (*itSerie)->ResetBoundaries(1); + itImage = ((*itSerie)->GetDicomDirImages()).begin(); + while (itImage != (*itSerie)->GetDicomDirImages().end() ) { + (*itImage)->ResetBoundaries(1); + ++itImage; + } + ++itSerie; + } + ++itStudy; + } + ++itPatient; + } +} + + /* * \ingroup gdcmDicomDir * \brief adds a new Patient to a partially created DICOMDIR diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index 30f86946..7b2e724f 100644 --- a/src/gdcmDicomDir.h +++ b/src/gdcmDicomDir.h @@ -66,7 +66,8 @@ public: // Parsing void ParseDirectory(void); - + void CheckBoundaries(void); + void SetStartMethod(gdcmMethod *,void * =NULL,gdcmMethod * =NULL); void SetStartMethodArgDelete(gdcmMethod *); void SetProgressMethod(gdcmMethod *,void * =NULL,gdcmMethod * =NULL); diff --git a/src/gdcmDirList.cxx b/src/gdcmDirList.cxx index 21c0c21b..5339ebeb 100644 --- a/src/gdcmDirList.cxx +++ b/src/gdcmDirList.cxx @@ -1,6 +1,7 @@ // gdcmDirList.cxx //----------------------------------------------------------------------------- #include "gdcmDirList.h" +#include "gdcmUtil.h" #include #include @@ -20,12 +21,6 @@ #include #endif -//----------------------------------------------------------------------------- -const char gdcmDirList::SEPARATOR_X = '/'; -const char gdcmDirList::SEPARATOR_WIN = '\\'; -const std::string gdcmDirList::SEPARATOR = "/"; - -//----------------------------------------------------------------------------- // Constructor / Destructor /* * \ingroup gdcmDirList @@ -69,19 +64,6 @@ std::string gdcmDirList::GetDirName(void) //----------------------------------------------------------------------------- // Private -/* - * \ingroup gdcmDirList - * \brief Add a SEPARATOR to the end of the directory name is necessary - * @param - */ -void gdcmDirList::NormalizePath(std::string &dirName) -{ - int size=dirName.size(); - if((dirName[size-1]!=SEPARATOR_X)&&(dirName[size-1]!=SEPARATOR_WIN)) - { - dirName+=SEPARATOR; - } -} /* * \ingroup gdcmDirList diff --git a/src/gdcmDirList.h b/src/gdcmDirList.h index e9cf3c55..5fa55a2b 100644 --- a/src/gdcmDirList.h +++ b/src/gdcmDirList.h @@ -22,7 +22,6 @@ public : static const std::string SEPARATOR; private : - void NormalizePath(std::string &dirName); void Explore(std::string dirName,bool recursive=false); std::string name; diff --git a/src/gdcmObject.cxx b/src/gdcmObject.cxx index eed5f4db..a067e72b 100644 --- a/src/gdcmObject.cxx +++ b/src/gdcmObject.cxx @@ -85,6 +85,34 @@ std::string gdcmObject::GetEntryByName(TagName name) { return GetEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement()); } +/** + * \ingroup gdcmObject + * \brief Set the 'boundaries' gdcmObject (gdcmDicomDirPatient, + * gdcmDicomDirStudy, gdcmDicomDirSerie, gdcmDicomDirImage) + * comming for the parsing of a DICOMDIR file + * \warning NOT en user intended function + * @param flag = 0 when META to be dealt with + */ +void gdcmObject::ResetBoundaries(int flag) { + + if (flag) { // it's NOT a META + // upwards to fffe,e000 + for( i=j=debut(); + ((*i)->GetGroup() != 0xfffe) && ((*i)->GetElement() != 0x0000); + --i,j--) { + } + beginObj=j; + } + + // downwards to fffe,e000 + for( i=j=fin(); + ((*i)->GetGroup() != 0xfffe) && ((*i)->GetElement() != 0x0000); + --i,j--) { + } + j--; + endObj=j; +} + /** * \ingroup gdcmParser * \brief Sets Entry (Dicom Element) value of an element, diff --git a/src/gdcmObject.h b/src/gdcmObject.h index f236d591..2d49cf3b 100644 --- a/src/gdcmObject.h +++ b/src/gdcmObject.h @@ -30,6 +30,8 @@ public: TagHeaderEntryHT GetEntry(void); ListTag GetListEntry(void); + + void ResetBoundaries(int flag); /** * \ingroup gdcmObject * \brief returns an iterator on the first Header Entry (i.e Dicom Element), @@ -48,6 +50,18 @@ public: */ ListTag::iterator fin (void) { return(endObj); } + +/** + * \ingroup gdcmObject + * \brief Sets the iterator on the 'new' last Header Entry (i.e Dicom Element), + * inside the DICOMDIR chained list, + * related to this 'Object' + * \warning : NOT end user intended function + * \todo find a trick to make this function useless. +* @return + */ + ListTag::iterator SetEndObj(ListTag::iterator newEnd) + { endObj=newEnd; } protected: diff --git a/src/gdcmUtil.cxx b/src/gdcmUtil.cxx index 42c176da..34998873 100644 --- a/src/gdcmUtil.cxx +++ b/src/gdcmUtil.cxx @@ -91,6 +91,12 @@ gdcmDicomDirElement *gdcmGlobal::GetDicomDirElements(void) { } //----------------------------------------------------------------------------- +// Here are some usefull functions, belonging to NO class, +// dealing with strings, file names, etc +// that can be called from anywhere +// by whomsoever they can help. +//----------------------------------------------------------------------------- + // Because is not yet available in g++2.96 std::istream& eatwhite(std::istream& is) { char c; @@ -133,7 +139,6 @@ char *_cleanString(char *v) { return v; } - /////////////////////////////////////////////////////////////////////////// // to prevent a flashing screen when non-printable character std::string _CreateCleanString(std::string s) {