]> Creatis software - gdcm.git/commitdiff
* ENH : now gdcmDicomDir::CreateDicomDir() returns also the meta elements
authorjpr <jpr>
Fri, 6 Feb 2004 14:56:55 +0000 (14:56 +0000)
committerjpr <jpr>
Fri, 6 Feb 2004 14:56:55 +0000 (14:56 +0000)
             GDCM_META added to gdcmDicomDirType
     class gdcmMeta created

ChangeLog
Testing/TestDicomDir.cxx
src/Makefile.am
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h
src/gdcmDicomDirElement.cxx
src/gdcmDirList.cxx
src/gdcmDirList.h
src/gdcmMeta.cxx [new file with mode: 0644]
src/gdcmMeta.h [new file with mode: 0644]
src/gdcmObject.h

index f642fb4945dd224c44be7562a5c189a06a95187e..e30d1a3ded8cfc28cbddb7f8d9a20021af90c78d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-02-06 Jean-Pierre Roux
+     * ENH : now gdcmDicomDir::CreateDicomDir() returns also the meta elements
+             GDCM_META added to gdcmDicomDirType
+            class gdcmMeta created
+
 2004-02-05 Benoit Regrain
      * ENH : add methods in gdcmObject to get the hash table or the list of
        header entries
index db226de843f79dd1322825962e3428c7c7ddf3e9..84d41113a6071469a46e4caace3c0cf641883d7a 100644 (file)
@@ -46,7 +46,94 @@ int main(int argc, char* argv[])
       return(1);
    }
 
+// Exemples exploitation de la structure
+
+// DON'T REMOVE neither the folowong code, nor the commented out lines
+
+
+  cout << std::endl << std::endl  
+            << " = Liste des PATIENT ==========================================" 
+            << std::endl<< std::endl;  
+
+
+   itPatient = e1->GetPatients().begin();      
+   while ( itPatient != e1->GetPatients().end() ) {  // on degouline la liste de PATIENT
+      std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name   
+      itPatient ++;    
+   }
+
+/*   
+     
+   cout << std::endl << std::endl  
+        << " = Liste des PATIENT/STUDY ==========================================" 
+        << std::endl<< std::endl;      
+
+   itPatient = e1->GetPatients().begin();      
+   while ( itPatient != e1->GetPatients().end() ) {  // on degouline la liste de PATIENT
+      std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name 
+      itStudy = ((*itPatient)->GetStudies()).begin();  
+      while (itStudy != (*itPatient)->GetStudies().end() ) { // on degouline les STUDY de ce patient   
+         std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Stdy Description
+         ++itStudy;            
+      }
+      itPatient ++;    
+   }
+   
+ */
+   cout << std::endl << std::endl  
+            << " = Liste des PATIENT/STUDY/SERIE ==========================================" 
+            << std::endl<< std::endl;  
+   itPatient = e1->GetPatients().begin();      
+   while ( itPatient != e1->GetPatients().end() ) {  // on degouline la liste de PATIENT
+      std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name 
+      itStudy = ((*itPatient)->GetStudies()).begin();  
+      while (itStudy != (*itPatient)->GetStudies().end() ) { // on degouline les STUDY de ce patient   
+         std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description 
+         itSerie = ((*itStudy)->GetSeries()).begin();
+         while (itSerie != (*itStudy)->GetSeries().end() ) { // on degouline les SERIES de cette study    
+            std::cout << "--- ---  "<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e) << std::endl; // Serie Description
+            ++itSerie;   
+         }
+         ++itStudy;            
+      }
+      itPatient ++;    
+   } 
+   
+    
+ /*
+   cout << std::endl << std::endl  
+            << " = Liste des PATIENT/STUDY/SERIE/IMAGE ===================================" 
+            << std::endl<< std::endl;
+   itPatient = e1->GetPatients().begin();      
+   while ( itPatient != e1->GetPatients().end() ) {  // on degouline la liste de PATIENT
+      std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
+      itStudy = ((*itPatient)->GetStudies()).begin();  
+      while (itStudy != (*itPatient)->GetStudies().end() ) { // on degouline les STUDY de ce patient   
+         std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
+         itSerie = ((*itStudy)->GetSeries()).begin();
+         while (itSerie != (*itStudy)->GetSeries().end() ) { // on degouline les SERIES de cette study    
+            std::cout << "--- --- "<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e) << std::endl; // Serie Description
+            itImage = ((*itSerie)->GetImages()).begin();
+            while (itImage != (*itSerie)->GetImages().end() ) { // on degouline les SERIES de cette study         
+               std::cout << "--- --- --- "<< (*itImage)->GetEntryByNumber(0x0004, 0x1500) << std::endl; // File name
+               ++itImage;   
+            }
+            ++itSerie;   
+         }
+         ++itStudy;            
+      }  
+      itPatient ++;    
+   }
+   
+ */  
+
 // DICOM DIR
+
+//What about the META informations?
+
    cout << std::endl << std::endl  
         << " = Contenu Complet du DICOMDIR ==========================================" 
         << std::endl<< std::endl;      
index ce709d5dae58cc6248369c6392bf36bd56282bc6..fc59601e4755b8fb984b7d61e77b1a9f58b4b5db 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = jpeg
+&SUBDIRS = jpeg
 
 LTVERSION = 0:1:0
 
@@ -25,6 +25,7 @@ libgdcm_la_SOURCES=                \
    gdcmHeaderEntry.cxx             \
    gdcmHeaderHelper.cxx            \
    gdcmImage.cxx                   \
+   gdcmMeta.cxx                    \
    gdcmJpeg12.cxx                  \
    gdcmJpeg2000.cxx                \
    gdcmJpeg.cxx                    \
@@ -37,14 +38,14 @@ libgdcm_la_SOURCES=                \
    gdcmStudy.cxx                   \
    gdcmTS.cxx                      \
    gdcmUtil.cxx                    \
-   gdcmVR.cxx 
+   gdcmVR.cxx
 
 
 libgdcmincludedir = $(includedir)
-libgdcminclude_HEADERS =           \
+libgdcminclude_HEADERS =                \
        gdcmCommon.h                    \
        gdcmDicomDir.h                  \
-   gdcmDicomDirElement.h           \
+        gdcmDicomDirElement.h           \
        gdcmDictEntry.h                 \
        gdcmDict.h                      \
        gdcmDictSet.h                   \
@@ -56,13 +57,14 @@ libgdcminclude_HEADERS =           \
        gdcmHeader.h                    \
        gdcmHeaderHelper.h              \
        gdcmImage.h                     \
+        gdcmMeta.h                      \
        gdcmObject.h                    \
        gdcmParser.h                    \
        gdcmPatient.h                   \
        gdcmSerie.h                     \
        gdcmStudy.h                     \
        gdcmVR.h                        \
-       gdcmTS.h                      
+       gdcmTS.h
 
 
 EXTRA_DIST =   \
index aedfc412f0a6d996d141206ae62d8f048e758855..cb54ee51b53093bfe6f1a4a077a36d4e38119e1e 100644 (file)
@@ -58,6 +58,8 @@ gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir,
  */
 gdcmDicomDir::~gdcmDicomDir() 
 {
+   delete metaelems;
+   
    for(ListPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
    {
       delete *cc;
@@ -72,6 +74,9 @@ gdcmDicomDir::~gdcmDicomDir()
  */
 void gdcmDicomDir::Print(std::ostream &os)
 {
+   (*metaelems).SetPrintLevel(printLevel);
+   (*metaelems).Print(os);   
+   
    for(ListPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
    {
      (*cc)->SetPrintLevel(printLevel);
@@ -127,7 +132,7 @@ void gdcmDicomDir::ParseDirectory(void)
 // Protected
 /*
  * \ingroup gdcmDicomDir
- * \brief   
+ * \brief create a gdcmDicomDir from a root Directory 
  * @param path entry point of the stree-like structure
  */
 void gdcmDicomDir::NewDicomDir(std::string path)
@@ -157,7 +162,7 @@ void gdcmDicomDir::NewDicomDir(std::string path)
 
 /*
  * \ingroup gdcmDicomDir
- * \brief   Get the dicom dir path
+ * \brief   Get the DicomDir path
  * @param   
  */
 std::string gdcmDicomDir::GetPath(void)
@@ -178,8 +183,7 @@ std::string gdcmDicomDir::GetPath(void)
 // Private
 /*
  * \ingroup gdcmDicomDir
- * \brief   
- * @param   
+ * \brief create a 'gdcmDicomDir' from a DICOMDIR gdcmHeader 
  */
 void gdcmDicomDir::CreateDicomDir()
 {
@@ -193,10 +197,22 @@ void gdcmDicomDir::CreateDicomDir()
    gdcmDicomDirType type=gdcmDicomDir::GDCM_NONE;
    ListTag::iterator begin;
    ListTag::iterator end;
+   ListTag::iterator k;
 
    begin=listEntries.begin();
    end=begin;
-   for(ListTag::iterator i=listEntries.begin();i !=listEntries.end();++i) 
+   
+   for(ListTag::iterator j=listEntries.begin();j !=listEntries.end();++j) 
+   {
+      if((*j)->GetValue()=="PATIENT ") {
+         k = j; 
+         break;
+      }
+      AddObjectToEnd(gdcmDicomDir::GDCM_META,begin,j);       
+   }   
+    
+//   for(ListTag::iterator i=listEntries.begin();i !=listEntries.end();++i) 
+   for(ListTag::iterator i=k;i !=listEntries.end();++i) 
    {
       std::string v=(*i)->GetValue();
       if(v=="PATIENT ") 
@@ -253,6 +269,9 @@ void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin,
 
    switch(type)
    {
+      case gdcmDicomDir::GDCM_META:
+         AddMetaToEnd(begin,end);
+         break;      
       case gdcmDicomDir::GDCM_PATIENT:
          AddPatientToEnd(begin,end);
          break;
@@ -268,6 +287,18 @@ void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin,
    }
 }
 
+
+/*
+ * \ingroup gdcmDicomDir
+ * \brief Well ... Not realy to end, there is only one occurence  
+ * @param   begin
+ * @param   end
+*/
+void gdcmDicomDir::AddMetaToEnd(ListTag::iterator begin,ListTag::iterator end)
+{
+   metaelems = new gdcmMeta(begin,end);
+}
+
 /*
  * \ingroup gdcmDicomDir
  * \brief   
@@ -382,9 +413,7 @@ void gdcmDicomDir::SetElements(std::string &path,ListHeader &list)
 
       // if new Serie Deal with 'SERIE' Elements   
       if(serCurInstanceUID!=serPrevInstanceUID || serCurID!=serPrevID) 
-      {
          SetElement(path,GDCM_SERIE,*it);
-      } 
       
       // Always Deal with 'IMAGE' Elements  
       SetElement(path,GDCM_IMAGE,*it);
index 3604104e0ea059aef8a8858eac64db13b3ce8f01..e06fcd1a429a796bef2775fc495fe19e354fa800 100644 (file)
@@ -6,13 +6,14 @@
 #include "gdcmHeader.h"
 #include "gdcmCommon.h"
 #include "gdcmPatient.h"
+#include "gdcmMeta.h"
 #include "gdcmDicomDirElement.h"
 
 #include <list>
 #include <vector>
 
 //-----------------------------------------------------------------------------
-typedef std::list<gdcmPatient *> ListPatient;
+typedef std::list<gdcmPatient *>   ListPatient;
 typedef std::vector<gdcmHeader *>  ListHeader;
 
 //-----------------------------------------------------------------------------
@@ -24,8 +25,9 @@ typedef std::vector<gdcmHeader *>  ListHeader;
 class GDCM_EXPORT gdcmDicomDir: public gdcmParser
 {
 public:
-//   gdcmDicomDir(ListTag *l,          bool exception_on_error = false);
-   gdcmDicomDir(const char *FileName, bool parseDir = false,
+//   gdcmDicomDir(ListTag *l,         bool exception_on_error = false);
+   gdcmDicomDir(const char *FileName, 
+                bool parseDir = false,
                 bool exception_on_error = false);
    
    ~gdcmDicomDir(void);
@@ -33,6 +35,7 @@ public:
    void SetPrintLevel(int level) { printLevel = level; };
    virtual void Print(std::ostream &os = std::cout);
 
+   inline gdcmMeta   *GetMeta()      {return metaelems;};
    inline ListPatient &GetPatients() {return patients;};
 
 // Write
@@ -43,6 +46,7 @@ public:
    typedef enum
    {
       GDCM_NONE,
+      GDCM_META,
       GDCM_PATIENT,
       GDCM_STUDY,
       GDCM_SERIE,
@@ -55,17 +59,20 @@ protected:
 
 private:
    void CreateDicomDir(void);
-   void AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin,ListTag::iterator end);
+   void AddObjectToEnd(gdcmDicomDirType type,
+                        ListTag::iterator begin,ListTag::iterator end);
+   void AddMetaToEnd   (ListTag::iterator begin,ListTag::iterator end);
    void AddPatientToEnd(ListTag::iterator begin,ListTag::iterator end);
-   void AddStudyToEnd(ListTag::iterator begin,ListTag::iterator end);
-   void AddSerieToEnd(ListTag::iterator begin,ListTag::iterator end);
-   void AddImageToEnd(ListTag::iterator begin,ListTag::iterator end);
+   void AddStudyToEnd  (ListTag::iterator begin,ListTag::iterator end);
+   void AddSerieToEnd  (ListTag::iterator begin,ListTag::iterator end);
+   void AddImageToEnd  (ListTag::iterator begin,ListTag::iterator end);
 
    void SetElements(std::string &path,ListHeader &list);
-   void SetElement(std::string &path,gdcmDicomDirType type,gdcmHeader *header);
+   void SetElement (std::string &path,gdcmDicomDirType type,gdcmHeader *header);
 
    static bool HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2);
 
+   gdcmMeta *metaelems;
    ListPatient patients;
 };
 
index f8aba446125120b54a680aae93cb0aa7bbf4ffb4..25afc82dcd1c4be3e4c53161654d51097272db32 100644 (file)
@@ -26,8 +26,7 @@
  * \ingroup gdcmDicomDirElement
  * \brief   constructor 
  */
- gdcmDicomDirElement::gdcmDicomDirElement(void) 
-{
+ gdcmDicomDirElement::gdcmDicomDirElement(void) {
    std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_ELEM);
    std::ifstream from(filename.c_str());
    dbg.Error(!from, "gdcmDicomDirElement::gdcmDicomDirElement: can't open dictionary",filename.c_str());
@@ -41,8 +40,8 @@
       from.getline(buff, 1024, ' ');
       type = buff;
 
-      if( (type=="metaElem") || (type=="patientElem") || 
-          (type=="studyElem") || (type=="serieElem") || 
+      if( (type=="metaElem")  || (type=="patientElem") || 
+          (type=="studyElem") || (type=="serieElem")   || 
           (type=="imageElem") )
       {
          from >> std::hex >> elem.group >> elem.elem;
@@ -74,8 +73,7 @@
  * \ingroup gdcmDicomDirElement
  * \brief   destructor 
  */
- gdcmDicomDirElement::~gdcmDicomDirElement() 
-{
+ gdcmDicomDirElement::~gdcmDicomDirElement() {
    MetaList.clear();
    PatientList.clear();
    StudyList.clear();
@@ -91,8 +89,7 @@
  * \todo add a 'Print Level' check 
  * @param   os The output stream to be written to.
  */
-void gdcmDicomDirElement::Print(std::ostream &os) 
-{
+void gdcmDicomDirElement::Print(std::ostream &os) {
    std::ostringstream s;
    std::list<gdcmElement>::iterator it;
    char greltag[10];  //group element tag
index 836041fbca94851635cd4a1271c637e1069390d1..f8a2d637963b1ea71e1edda1534ac91a9283a1f8 100644 (file)
@@ -43,7 +43,6 @@ gdcmDirList::gdcmDirList(std::string dirName,bool recursive)
 /*
  * \ingroup gdcmDirList
  * \brief  Destructor
- * @param   
  */
 gdcmDirList::~gdcmDirList(void)
 {
index 2dae2fcb84b9cab425bf3e0b9c4f16844b281c3d..e9cf3c5583bdf142a9a77aa9febb77fe0ffed0df 100644 (file)
@@ -1,4 +1,4 @@
-// gdcmDir.h
+// gdcmDirList.h
 //-----------------------------------------------------------------------------
 #ifndef GDCMDIRLIST_H
 #define GDCMDIRLIST_H
diff --git a/src/gdcmMeta.cxx b/src/gdcmMeta.cxx
new file mode 100644 (file)
index 0000000..52bb3ad
--- /dev/null
@@ -0,0 +1,50 @@
+// gdcmMeta.cxx
+//-----------------------------------------------------------------------------
+#include "gdcmMeta.h"
+
+//-----------------------------------------------------------------------------
+// Constructor / Destructor
+/**
+ * \ingroup gdcmMeta
+ * \brief   
+ * @param   begin iterator of begin for the object
+ * @param   end   iterator of end for the object
+ */
+gdcmMeta::gdcmMeta(ListTag::iterator begin,ListTag::iterator end):
+   gdcmObject(begin,end)
+{
+}
+
+/**
+ * \ingroup gdcmMeta
+ * \brief   Canonical destructor.
+ */
+gdcmMeta::~gdcmMeta() 
+{
+}
+
+//-----------------------------------------------------------------------------
+// Print
+/**
+ * \ingroup gdcmMeta
+ * \brief   Prints the Object
+ * @return
+ */ 
+void gdcmMeta::Print(std::ostream &os)
+{
+   os<<"META : ";
+   os<<std::endl;
+
+   gdcmObject::Print(os);
+}
+
+//-----------------------------------------------------------------------------
+// Public
+
+//-----------------------------------------------------------------------------
+// Protected
+
+//-----------------------------------------------------------------------------
+// Private
+
+//-----------------------------------------------------------------------------
diff --git a/src/gdcmMeta.h b/src/gdcmMeta.h
new file mode 100644 (file)
index 0000000..12e42eb
--- /dev/null
@@ -0,0 +1,19 @@
+// gdcmMeta.h
+//-----------------------------------------------------------------------------
+#ifndef GDCMMETA_H
+#define GDCMMETA_H
+
+#include "gdcmObject.h"
+
+//-----------------------------------------------------------------------------
+class GDCM_EXPORT gdcmMeta : public gdcmObject 
+{
+public:
+   gdcmMeta(ListTag::iterator begin,ListTag::iterator end);
+   ~gdcmMeta(void);
+
+   virtual void Print(std::ostream &os = std::cout);
+};
+
+//-----------------------------------------------------------------------------
+#endif
index b84575468b045d296d987121a13dde3157d071cd..0c745e0a5db64f89e9113249b7d500e63be6d740 100644 (file)
@@ -28,11 +28,13 @@ public:
 
    TagHeaderEntryHT GetEntry(void);
    ListTag GetListEntry(void);
-
+   ListTag::iterator debut(void) { return(beginObj);}
+   ListTag::iterator fin  (void) { return(endObj);  }
+   
 protected:
+   
    ListTag::iterator beginObj;
    ListTag::iterator endObj;
-
    int printLevel;
 
 private: