]> Creatis software - gdcm.git/commitdiff
Add the VISIT object within DicomDir
authorjpr <jpr>
Fri, 8 Jul 2005 19:07:12 +0000 (19:07 +0000)
committerjpr <jpr>
Fri, 8 Jul 2005 19:07:12 +0000 (19:07 +0000)
src/CMakeLists.txt
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h
src/gdcmDicomDirElement.h
src/gdcmDicomDirStudy.cxx
src/gdcmDicomDirStudy.h
src/gdcmDicomDirVisit.cxx [new file with mode: 0644]
src/gdcmDicomDirVisit.h [new file with mode: 0644]

index f13d7f09ac7968fb3ec1cb8b98489f38064d3ad4..6a271f7995796bb2bdceafaaca2a7447425026d9 100644 (file)
@@ -39,6 +39,7 @@ SET(libgdcm_la_SOURCES
    gdcmDicomDirMeta.cxx
    gdcmDicomDirObject.cxx
    gdcmDicomDirPatient.cxx
+   gdcmDicomDirVisit.cxx
    gdcmDicomDirSerie.cxx
    gdcmDicomDirStudy.cxx
    gdcmDict.cxx
index 60d533666df3716d0c55b59c9040a40afeed9da1..606a6437c252791d1f3187e9d511e94685b27ba5 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 10:13:38 $
-  Version:   $Revision: 1.145 $
+  Date:      $Date: 2005/07/08 19:07:12 $
+  Version:   $Revision: 1.146 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -23,6 +23,7 @@
 #include "gdcmDicomDir.h"
 #include "gdcmDicomDirStudy.h"
 #include "gdcmDicomDirSerie.h"
+#include "gdcmDicomDirVisit.h"
 #include "gdcmDicomDirImage.h"
 #include "gdcmDicomDirPatient.h"
 #include "gdcmDicomDirMeta.h"
@@ -772,6 +773,16 @@ void DicomDir::CreateDicomDir()
             gdcmErrorMacro( "Add AddSerieToEnd failed");
          }
       }
+      else if ( v == "VISIT " )
+      {
+         si = new DicomDirVisit(true);
+         if ( !AddVisitToEnd( static_cast<DicomDirVisit *>(si)) )
+         {
+            delete si;
+            si = NULL;
+            gdcmErrorMacro( "Add AddVisitToEnd failed");
+         }
+      }
       else if ( v == "STUDY " )
       {
          si = new DicomDirStudy(true);
@@ -859,6 +870,26 @@ bool DicomDir::AddSerieToEnd(DicomDirSerie *dd)
    return false;
 }
 
+/**
+ * \brief  AddVisitToEnd 
+ * @param   dd SQ Item to enqueue to the DicomDirVisit chained List
+ */
+bool DicomDir::AddVisitToEnd(DicomDirVisit *dd)
+{
+   if ( Patients.size() > 0 )
+   {
+      ListDicomDirPatient::iterator itp = Patients.end();
+      itp--;
+
+      DicomDirStudy *study = (*itp)->GetLastStudy();
+      if ( study )
+      {
+         study->AddVisit(dd);
+         return true;
+      }
+   }
+   return false;
+}
 /**
  * \brief   AddImageToEnd
  * @param   dd SQ Item to enqueue to the DicomDirImage chained List
index 64b61a3a51eb3098d6f6f8ee4174f162f1307d99..3fc3c11f5a3bacbd6457642db12bc98f235d5ae1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.h,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 10:13:38 $
-  Version:   $Revision: 1.62 $
+  Date:      $Date: 2005/07/08 19:07:12 $
+  Version:   $Revision: 1.63 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -32,6 +32,7 @@ class DicomDirMeta;
 class DicomDirElement;
 class DicomDirStudy;
 class DicomDirSerie;
+class DicomDirVisit;
 class DicomDirImage;
 class SQItem;
 
@@ -126,6 +127,7 @@ public:
       GDCM_DICOMDIR_PATIENT,
       GDCM_DICOMDIR_STUDY,
       GDCM_DICOMDIR_SERIE,
+      GDCM_DICOMDIR_VISIT,
       GDCM_DICOMDIR_IMAGE
    } DicomDirType;
    
@@ -142,6 +144,7 @@ private:
    bool AddPatientToEnd(DicomDirPatient *dd);
    bool AddStudyToEnd  (DicomDirStudy *dd);
    bool AddSerieToEnd  (DicomDirSerie *dd);
+   bool AddVisitToEnd  (DicomDirVisit *dd);
    bool AddImageToEnd  (DicomDirImage *dd);
 
    void SetElements(std::string const &path, VectDocument const &list);
index 4540ce16d26abec5aae39ac882d0231345a16f78..0da4be80e82338db6ea80cde28f190f89731a4eb 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirElement.h,v $
   Language:  C++
-  Date:      $Date: 2005/02/11 15:22:18 $
-  Version:   $Revision: 1.28 $
+  Date:      $Date: 2005/07/08 19:07:12 $
+  Version:   $Revision: 1.29 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -36,8 +36,9 @@ typedef std::list<Element> ListDicomDirSerieElem;
 typedef std::list<Element> ListDicomDirImageElem;
 
 // For future use (Full DICOMDIR)
+
+typedef std::list<Element> ListDicomDirVisitElem;
 /*
-typedef std::list<Element> ListDicomDirVisit;
 typedef std::list<Element> ListDicomDirResult;
 typedef std::list<Element> ListDicomDirStudyComponent;
 
@@ -96,6 +97,12 @@ public:
    ListDicomDirStudyElem const &GetDicomDirStudyElements() const
       { return DicomDirStudyList; };
 
+   /**
+    * \brief   returns a reference to the chained List 
+    *          related to the VISIT Elements of a DICOMDIR.
+    */      
+   ListDicomDirVisitElem const &GetDicomDirVisitElements() const
+      { return DicomDirVisitList; };
    /**
     * \brief   returns a reference to the chained List 
     *          related to the SERIE Elements of a DICOMDIR.
@@ -124,6 +131,8 @@ private:
    ListDicomDirPatientElem DicomDirPatientList;
    /// Elements chained list, related to the StudyElements of DICOMDIR
    ListDicomDirStudyElem   DicomDirStudyList;
+   /// Elements chained list, related to the VisitElements of DICOMDIR
+   ListDicomDirVisitElem   DicomDirVisitList;
    /// Elements chained list, related to the SerieElements of DICOMDIR
    ListDicomDirSerieElem   DicomDirSerieList;
    /// Elements chained list, related to the ImageElements of DICOMDIR
index 4bb284ff46533a7796a3f7155399f3f706c71385..2151e44139d3036987bbb9afa7db4dc48e328106 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirStudy.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/06/24 10:55:58 $
-  Version:   $Revision: 1.37 $
+  Date:      $Date: 2005/07/08 19:07:12 $
+  Version:   $Revision: 1.38 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -20,6 +20,7 @@
 #include "gdcmDicomDirElement.h"
 #include "gdcmGlobal.h"
 #include "gdcmDicomDirSerie.h"
+#include "gdcmDicomDirVisit.h"
 #include "gdcmDebug.h"
 
 namespace gdcm 
@@ -67,6 +68,13 @@ void DicomDirStudy::WriteContent(std::ofstream *fp, FileType t)
    {
       (*cc)->WriteContent( fp, t );
    }
+
+   for(ListDicomDirVisit::iterator cc = Visits.begin();
+                                   cc!= Visits.end();
+                                 ++cc )
+   {
+      (*cc)->WriteContent( fp, t );
+   }
 }
 
 /**
@@ -80,6 +88,17 @@ DicomDirSerie *DicomDirStudy::NewSerie()
    return st;
 } 
 
+/**
+ * \brief   adds a new Visit at the beginning of the VisitList
+ *          of a partially created DICOMDIR
+ */
+DicomDirVisit *DicomDirStudy::NewVisit()
+{
+   DicomDirVisit *st = new DicomDirVisit();
+   Visits.push_back(st);
+   return st;
+} 
+
 /**
  * \brief  Remove all series in the study 
  */
@@ -94,6 +113,20 @@ void DicomDirStudy::ClearSerie()
    Series.clear();
 }
 
+/**
+ * \brief  Remove all visits in the study 
+ */
+void DicomDirStudy::ClearVisit()
+{
+   for(ListDicomDirVisit::iterator cc =  Visits.begin();
+                                   cc != Visits.end();
+                                 ++cc )
+   {
+      delete *cc;
+   }
+   Visits.clear();
+}
+
 /**
  * \brief   Get the first entry while visiting the DicomDirSeries
  * \return  The first DicomDirSerie if found, otherwhise NULL
@@ -106,6 +139,18 @@ DicomDirSerie *DicomDirStudy::GetFirstSerie()
    return NULL;
 }
 
+/**
+ * \brief   Get the first entry while visiting the DicomDirVisit
+ * \return  The first DicomDirVisit if found, otherwhise NULL
+ */
+DicomDirVisit *DicomDirStudy::GetFirstVisit()
+{
+   ItVisit = Visits.begin();
+   if (ItVisit != Visits.end())
+      return *ItVisit;
+   return NULL;
+}
+
 /**
  * \brief   Get the next entry while visiting the DicomDirSeries
  * \note : meaningfull only if GetFirstEntry already called
@@ -121,9 +166,24 @@ DicomDirSerie *DicomDirStudy::GetNextSerie()
    return NULL;
 }  
 
+/**
+ * \brief   Get the next entry while visiting the DicomDirVisit
+ * \note : meaningfull only if GetFirstEntry already called
+ * \return  The next DicomDirVisit if found, otherwhise NULL
+ */
+DicomDirVisit *DicomDirStudy::GetNextVisit()
+{
+   gdcmAssertMacro (ItVisit != Visits.end());
+
+   ++ItVisit;
+   if (ItVisit != Visits.end())
+      return *ItVisit;
+   return NULL;
+}
+
 /**
  * \brief   Get the last entry while visiting the DicomDirSeries
- * \return  The first DicomDirSerie if found, otherwhise NULL
+ * \return  The last DicomDirSerie if found, otherwhise NULL
  */
 DicomDirSerie *DicomDirStudy::GetLastSerie()
 {
@@ -136,6 +196,21 @@ DicomDirSerie *DicomDirStudy::GetLastSerie()
    return NULL;
 }
 
+/**
+ * \brief   Get the last entry while visiting the DicomDirVisit
+ * \return  The last DicomDirVisit if found, otherwhise NULL
+ */
+DicomDirVisit *DicomDirStudy::GetLastVisit()
+{
+   ItVisit = Visits.end();
+   if (ItVisit != Visits.begin())
+   {
+     --ItVisit;
+      return *ItVisit;
+   }
+   return NULL;
+}
+
 //-----------------------------------------------------------------------------
 // Protected
 
@@ -162,6 +237,15 @@ void DicomDirStudy::Print(std::ostream &os, std::string const & )
       (*cc)->SetPrintLevel(PrintLevel);
       (*cc)->Print(os);
    }
+
+   for(ListDicomDirVisit::iterator cc2 =  Visits.begin();
+                                   cc2 != Visits.end();
+                                   ++cc2)
+   {
+      (*cc2)->SetPrintLevel(PrintLevel);
+      (*cc2)->Print(os);
+   }
+
 }
 
 //-----------------------------------------------------------------------------
index 936a7f7cc8bdbdd034d1ebd14762134b79df94ea..bac655086b9618544f25a8335dc8e2a0eecfb59e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirStudy.h,v $
   Language:  C++
-  Date:      $Date: 2005/02/07 14:48:34 $
-  Version:   $Revision: 1.26 $
+  Date:      $Date: 2005/07/08 19:07:12 $
+  Version:   $Revision: 1.27 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 namespace gdcm 
 {
 class DicomDirSerie;
+class DicomDirVisit;
 //-----------------------------------------------------------------------------
 typedef std::list<DicomDirSerie *> ListDicomDirSerie;
 
-/*
+
 // For future use (Full DICOMDIR)
 typedef std::list<DicomDirVisit *> ListDicomDirVisit;
+/*
 typedef std::list<DicomDirResult *> ListDicomDirResult;
 typedef std::list<DicomDirStudyComponent *> ListDicomDirStudyComponent;
-
 */
 //-----------------------------------------------------------------------------
 /**
@@ -58,20 +59,24 @@ public:
    DicomDirSerie *GetNextSerie();
    DicomDirSerie *GetLastSerie();
 
-/*
+
    // for future use (Full DICOMDIR)
 
+   DicomDirVisit *NewVisit();
+   void AddVisit(DicomDirVisit *obj) { Visits.push_back(obj); };
+   void ClearVisit();
    DicomDirVisit *GetFirstVisit();
    DicomDirVisit *GetNextVisit();
-
+   DicomDirVisit *GetLastVisit();
+/*
    DicomDirResult *GetFirstResult();
    DicomDirResult *GetNextResult();
+   DicomDirResult *GetLastResult();
 
    DicomDirStudyComponent *GetFirstStudyComponent();
    DicomDirStudyComponent *GetNextStudyComponent();
-
-*/
-    
+   DicomDirStudyComponent *GetLastStudyComponent();
+*/    
 private:
 
    /// chained list of DicomDirSeries (to be exploited hierarchicaly)
@@ -79,14 +84,14 @@ private:
    /// iterator on the DicomDirSeries of the current DicomDirStudy
    ListDicomDirSerie::iterator ItSerie;
 
-/*
+
    // for future use (Full DICOMDIR)
 
    /// chained list of DicomDirVisits(single level)
    ListDicomDirVisit Visits;
    /// iterator on the DicomDirVisits of the current DicomDirStudy
    ListDicomDirVisit::iterator ItVisit;
-
+/*
    /// chained list of DicomDirResults(single level)
    ListDicomDirResult Results;
    /// iterator on the DicomDirResults of the current DicomDirStudy
diff --git a/src/gdcmDicomDirVisit.cxx b/src/gdcmDicomDirVisit.cxx
new file mode 100644 (file)
index 0000000..b5c9eab
--- /dev/null
@@ -0,0 +1,85 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmDicomDirVisit.cxx,v $
+  Language:  C++
+  Date:      $Date: 2005/07/08 19:07:12 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+
+#include "gdcmDicomDirVisit.h"
+#include "gdcmValEntry.h"
+#include "gdcmGlobal.h"
+
+namespace gdcm 
+{
+//-----------------------------------------------------------------------------
+// Constructor / Destructor
+/**
+ * \brief  Constructor 
+ * \note End user must use : DicomDirStudy::NewVisit()
+ */
+DicomDirVisit::DicomDirVisit(bool empty):
+   DicomDirObject()
+{
+   if ( !empty )
+   {
+      ListDicomDirVisitElem const &elemList = 
+         Global::GetDicomDirElements()->GetDicomDirVisitElements();
+      FillObject(elemList);
+   }
+}
+
+/**
+ * \brief   Canonical destructor.
+ */
+DicomDirVisit::~DicomDirVisit() 
+{
+}
+
+//-----------------------------------------------------------------------------
+// Public
+
+//-----------------------------------------------------------------------------
+// Protected
+
+//-----------------------------------------------------------------------------
+// Private
+
+//-----------------------------------------------------------------------------
+// Print
+/**
+ * \brief   Prints the Object
+ * @param os ostream to write to
+ * @param indent Indentation string to be prepended during printing
+ * @return
+ */ 
+void DicomDirVisit::Print(std::ostream &os, std::string const & )
+{
+   os << "VISIT : ";
+   for(ListDocEntry::iterator i = DocEntries.begin();
+                              i!= DocEntries.end();
+                              ++i)
+   {
+      if ( (*i)->GetGroup() == 0x0004 && (*i)->GetElement() == 0x1500 )
+      {
+         os << (dynamic_cast<ValEntry *>(*i))->GetValue(); //FIXME // ????
+      }
+   }
+   os << std::endl;
+
+   DicomDirObject::Print(os);
+}
+
+//-----------------------------------------------------------------------------
+} // end namespace gdcm
+
diff --git a/src/gdcmDicomDirVisit.h b/src/gdcmDicomDirVisit.h
new file mode 100644 (file)
index 0000000..18337fb
--- /dev/null
@@ -0,0 +1,43 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmDicomDirVisit.h,v $
+  Language:  C++
+  Date:      $Date: 2005/07/08 19:07:12 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+
+#ifndef GDCMDICOMDIRVISIT_H
+#define GDCMDICOMDIRVISIT_H
+
+#include "gdcmDicomDirObject.h"
+
+namespace gdcm 
+{
+
+/**
+ * \brief   describes a VISIT  within a within a STUDY
+ * (DicomDirStudy) of a given DICOMDIR (DicomDir)
+ */
+class GDCM_EXPORT DicomDirVisit : public DicomDirObject 
+{
+public:
+   DicomDirVisit(bool empty=false); 
+   ~DicomDirVisit();
+
+   void Print( std::ostream &os = std::cout, std::string const &indent = "" );
+  // void WriteContent( std::ofstream *fp, FileType t );
+
+};
+} // end namespace gdcm
+//-----------------------------------------------------------------------------
+#endif