]> Creatis software - gdcm.git/commitdiff
Now the tree-like structure describing a DICOMDIR comming from an already
authorjpr <jpr>
Fri, 19 Mar 2004 15:16:13 +0000 (15:16 +0000)
committerjpr <jpr>
Fri, 19 Mar 2004 15:16:13 +0000 (15:16 +0000)
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)

ChangeLog
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h
src/gdcmDirList.cxx
src/gdcmDirList.h
src/gdcmObject.cxx
src/gdcmObject.h
src/gdcmUtil.cxx

index 48bbcc81e974814469e89a2be52b39240d62b773..6216798366293a9900b07d8839e7eb274f547209 100644 (file)
--- 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 <Eric.Boix@creatis.insa-lyon.fr> 
index d61e5c11a58efe4f2f8dcbc90e7b7f96e08c3dc4..2939043f45a67a907ddbc86a7e552c40bedb4ccb 100644 (file)
@@ -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 " <<endl;
+   ListDicomDirPatient::iterator  itPatient;
+   ListDicomDirStudy::iterator    itStudy;
+   ListDicomDirSerie::iterator    itSerie;
+   ListDicomDirImage::iterator    itImage; 
+   ListTag::iterator i,j; 
+   
+   GetDicomDirMeta()->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
index 30f869468f2ea42c9a1688c58803abc54cbf3338..7b2e724f6f388e4d117aa305ea772f9c6347228e 100644 (file)
@@ -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);
index 21c0c21b6726e01809cb2024ec4c5603801aff5b..5339ebeb18730e88e5659e80cfdf154642ff2550 100644 (file)
@@ -1,6 +1,7 @@
 // gdcmDirList.cxx
 //-----------------------------------------------------------------------------
 #include "gdcmDirList.h"
+#include "gdcmUtil.h"
 
 #include <iostream>
 #include <algorithm>
    #include <unistd.h>
 #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
index e9cf3c5583bdf142a9a77aa9febb77fe0ffed0df..5fa55a2bdbe066bf4a84633bf7c8abfe447c6c21 100644 (file)
@@ -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;
index eed5f4db1da979be43ce2e4e16074b8376e67bc5..a067e72b764e3a14f1e3f88af6c6e29287e3e98c 100644 (file)
@@ -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,
index f236d5915ccabffb8924963a07f0774c03e53e18..2d49cf3b2be7928478c39e79d13f4813ec0298a8 100644 (file)
@@ -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:
 
index 42c176da5f9a6d8e47c12e07d967612d5e00c7fa..349988731553713eca6126d0726d41ddbbd5bda8 100644 (file)
@@ -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) {