]> Creatis software - gdcm.git/commitdiff
* FIX : sort the images in the dicom dir
authorregrain <regrain>
Wed, 4 Feb 2004 13:27:55 +0000 (13:27 +0000)
committerregrain <regrain>
Wed, 4 Feb 2004 13:27:55 +0000 (13:27 +0000)
     -- BeNours

ChangeLog
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h

index 973aeda3600ab81679bb5711c566fa5fdc0765f0..1ba6d046eb1bd9345f70b9135e589de65425a4ff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-02-04 Benoit Regrain
+     * FIX : sort the images in the dicom dir
+     * FIX : Bug fix for python use of dicom dir
+     * Add a python demo
+
 2004-02-04 Jean-Pierre Roux
      * FIX : Final solution (?) for icone embedded images
      * FIX : dicomVR.dic Overlay group is not *only* 6000, but 60xxx
 2004-02-04 Jean-Pierre Roux
      * FIX : Final solution (?) for icone embedded images
      * FIX : dicomVR.dic Overlay group is not *only* 6000, but 60xxx
index cc37127647324718cc4c51cb92a37ee15b989dcd..92cdc6f8702234cf7474e1132bf527ec82ede3d0 100644 (file)
@@ -8,6 +8,7 @@
 #include "gdcmUtil.h"
 
 #include <string>
 #include "gdcmUtil.h"
 
 #include <string>
+#include <algorithm>
 
 #include <sys/types.h>
 #include <errno.h>
 
 #include <sys/types.h>
 #include <errno.h>
@@ -133,7 +134,6 @@ void gdcmDicomDir::NewDicomDir(std::string path)
    for(gdcmDirList::iterator it=fileList.begin(); 
        it!=fileList.end(); ++it) 
    {
    for(gdcmDirList::iterator it=fileList.begin(); 
        it!=fileList.end(); ++it) 
    {
-//      std::cout<<*it<<std::endl;
       header=new gdcmHeader(it->c_str());
       if(header->IsReadable())
          list.push_back(header);
       header=new gdcmHeader(it->c_str());
       if(header->IsReadable())
          list.push_back(header);
@@ -141,6 +141,8 @@ void gdcmDicomDir::NewDicomDir(std::string path)
          delete header;
    }
 
          delete header;
    }
 
+   std::sort(list.begin(),list.end(),gdcmDicomDir::HeaderLessThan);
+
    SetElements(path,list);
 }
 
    SetElements(path,list);
 }
 
@@ -187,13 +189,9 @@ void gdcmDicomDir::CreateDicomDir()
    end=begin;
    for(ListTag::iterator i=listEntries.begin();i !=listEntries.end();++i) 
    {
    end=begin;
    for(ListTag::iterator i=listEntries.begin();i !=listEntries.end();++i) 
    {
-      // std::cout << std::hex <<(*i)->GetGroup() << 
-      //                  " " <<(*i)->GetElement() << endl;
-
       std::string v=(*i)->GetValue();
       if(v=="PATIENT ") 
       {
       std::string v=(*i)->GetValue();
       if(v=="PATIENT ") 
       {
-       //  std::cout<<"PATIENT"<<std::endl;
          end=i;
          AddObjectToEnd(type,begin,end);
 
          end=i;
          AddObjectToEnd(type,begin,end);
 
@@ -203,7 +201,6 @@ void gdcmDicomDir::CreateDicomDir()
 
       if(v=="STUDY ")
       {
 
       if(v=="STUDY ")
       {
-       //  std::cout<<"STUDY"<<std::endl;
          end=i;
          AddObjectToEnd(type,begin,end);
 
          end=i;
          AddObjectToEnd(type,begin,end);
 
@@ -213,7 +210,6 @@ void gdcmDicomDir::CreateDicomDir()
 
       if(v=="SERIES") 
       {
 
       if(v=="SERIES") 
       {
-       //  std::cout<<"SERIES"<<std::endl;
          end=i;
          AddObjectToEnd(type,begin,end);
 
          end=i;
          AddObjectToEnd(type,begin,end);
 
@@ -223,7 +219,6 @@ void gdcmDicomDir::CreateDicomDir()
 
       if(v=="IMAGE ") 
       {
 
       if(v=="IMAGE ") 
       {
-       //  std::cout<<"IMAGE"<<std::endl;
          end=i;
          AddObjectToEnd(type,begin,end);
 
          end=i;
          AddObjectToEnd(type,begin,end);
 
@@ -354,7 +349,7 @@ void gdcmDicomDir::SetElements(std::string &path,ListHeader &list)
    ListTag::iterator debPat=listEntries.begin();
    for(ListHeader::iterator it=list.begin();it!=list.end();++it) 
    {
    ListTag::iterator debPat=listEntries.begin();
    for(ListHeader::iterator it=list.begin();it!=list.end();++it) 
    {
-     // get the current file characteristics
+      // get the current file characteristics
       patCurName=(*it)->GetEntryByNumber(0x0010,0x0010); 
       patCurID=(*it)->GetEntryByNumber(0x0010,0x0011); 
       studCurInstanceUID=(*it)->GetEntryByNumber(0x0020,0x000d);            
       patCurName=(*it)->GetEntryByNumber(0x0010,0x0010); 
       patCurID=(*it)->GetEntryByNumber(0x0010,0x0011); 
       studCurInstanceUID=(*it)->GetEntryByNumber(0x0020,0x000d);            
@@ -484,4 +479,9 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,gdcmHeader
    }     
 }
 
    }     
 }
 
+bool gdcmDicomDir::HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2)
+{
+   return(*header1<*header2);
+}
+
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
index b0bc7453254c1756998f572c4b1f353277849d29..3604104e0ea059aef8a8858eac64db13b3ce8f01 100644 (file)
@@ -8,9 +8,12 @@
 #include "gdcmPatient.h"
 #include "gdcmDicomDirElement.h"
 
 #include "gdcmPatient.h"
 #include "gdcmDicomDirElement.h"
 
+#include <list>
+#include <vector>
+
 //-----------------------------------------------------------------------------
 typedef std::list<gdcmPatient *> ListPatient;
 //-----------------------------------------------------------------------------
 typedef std::list<gdcmPatient *> ListPatient;
-typedef std::list<gdcmHeader *>  ListHeader;
+typedef std::vector<gdcmHeader *>  ListHeader;
 
 //-----------------------------------------------------------------------------
 /*
 
 //-----------------------------------------------------------------------------
 /*
@@ -61,6 +64,8 @@ private:
    void SetElements(std::string &path,ListHeader &list);
    void SetElement(std::string &path,gdcmDicomDirType type,gdcmHeader *header);
 
    void SetElements(std::string &path,ListHeader &list);
    void SetElement(std::string &path,gdcmDicomDirType type,gdcmHeader *header);
 
+   static bool HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2);
+
    ListPatient patients;
 };
 
    ListPatient patients;
 };