]> Creatis software - gdcm.git/commitdiff
Deal with PRIVATE (at PrintDicomDir time, not MakeDicomDir time ...)
authorjpr <jpr>
Fri, 23 Mar 2007 15:30:15 +0000 (15:30 +0000)
committerjpr <jpr>
Fri, 23 Mar 2007 15:30:15 +0000 (15:30 +0000)
src/CMakeLists.txt
src/gdcmCommandManager.h
src/gdcmCommon.h
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h
src/gdcmDicomDirElement.cxx
src/gdcmDicomDirElement.h
src/gdcmDicomDirMeta.cxx
src/gdcmDicomDirSerie.cxx
src/gdcmDicomDirSerie.h

index 6325c3be8974511f3c302101cfa57375cc34a95a..9e7065a497aad21c277684d22ed4d50ebc38b032 100644 (file)
@@ -32,6 +32,7 @@ SET(GDCM_SOURCES
    gdcmDicomDir.cxx
    gdcmDicomDirElement.cxx
    gdcmDicomDirImage.cxx
+   gdcmDicomDirPrivate.cxx   
    gdcmDicomDirMeta.cxx
    gdcmDicomDirObject.cxx
    gdcmDicomDirPatient.cxx
index 9d964109238494dd23244c2c6059bbf54c85ac2e..ff21e0c14769b41c909719765488f71ca6cab075 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmCommandManager.h,v $
   Language:  C++
-  Date:      $Date: 2006/01/18 15:25:07 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2007/03/23 15:30:15 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -28,7 +28,7 @@ namespace gdcm
 {
 //-----------------------------------------------------------------------------
 class Command;
-typedef std::pair<const Base *,unsigned int> CommandKey;
+typedef std::pair<const Base *, unsigned int> CommandKey;
 typedef std::map<CommandKey,Command *> CommandHT;
 
 //-----------------------------------------------------------------------------
@@ -44,11 +44,11 @@ class GDCM_EXPORT CommandManager : public Base
 public:
    void Print(std::ostream &os = std::cout, std::string const &indent = "" );
 
-   static void SetCommand(const Base *object,unsigned int type,Command *command);
-   static Command *GetCommand(const Base *object,unsigned int type);
+   static void SetCommand(const Base *object, unsigned int type, Command *command);
+   static Command *GetCommand(const Base *object, unsigned int type);
 
-   static bool ExecuteCommand(Base *object,unsigned int type,std::string text = "");
-   static bool ExecuteCommandConst(const Base *object,unsigned int type,std::string text = "");
+   static bool ExecuteCommand(Base *object, unsigned int type, std::string text = "");
+   static bool ExecuteCommandConst(const Base *object, unsigned int type, std::string text = "");
 
    static const CommandManager *GetInstance();
 
@@ -58,11 +58,11 @@ protected:
    CommandManager();
 
    void InClearCommand(void);
-   void InSetCommand(const Base *object,unsigned int type,Command *command);
-   Command *InGetCommand(const Base *object,unsigned int type);
+   void InSetCommand(const Base *object, unsigned int type, Command *command);
+   Command *InGetCommand(const Base *object, unsigned int type);
 
-   bool InExecuteCommand(Base *object,unsigned int type,std::string text = "");
-   bool InExecuteCommandConst(const Base *object,unsigned int type,std::string text = "");
+   bool InExecuteCommand(Base *object, unsigned int type, std::string text = "");
+   bool InExecuteCommandConst(const Base *object, unsigned int type, std::string text = "");
 
 private:
    static CommandManager Instance;
index 91a978da34b8cb738a093d390c9246a201d9c5c0..64720371bcaedf6bc73f6e4012378ffd31165edd 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmCommon.h,v $
   Language:  C++
-  Date:      $Date: 2006/07/06 15:08:10 $
-  Version:   $Revision: 1.113 $
+  Date:      $Date: 2007/03/23 15:30:15 $
+  Version:   $Revision: 1.114 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -56,6 +56,7 @@ namespace gdcm
 #  define PUB_DICT_PATH   "../Dicts/"
 #endif
 #define PUB_DICT_NAME     "dicomV3Dict"
+
 // dicomV3.dic replaced by the generated gdcm.dic/
 // if gdcm.dic not found, method FillDefaultDataDict() is invoked
 //#define PUB_DICT_FILENAME "dicomV3.dic"
index 6c42fea238370cea60848fd12c63a526b885273d..96e35066c6c25ff24d43fae0d6adb2ecb3696d42 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/05/30 08:10:19 $
-  Version:   $Revision: 1.189 $
+  Date:      $Date: 2007/03/23 15:30:15 $
+  Version:   $Revision: 1.190 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -26,6 +26,7 @@
 #include "gdcmDicomDirSerie.h"
 #include "gdcmDicomDirVisit.h"
 #include "gdcmDicomDirImage.h"
+#include "gdcmDicomDirPrivate.h"
 #include "gdcmDicomDirPatient.h"
 #include "gdcmDicomDirMeta.h"
 #include "gdcmDicomDirElement.h"
@@ -701,11 +702,27 @@ void DicomDir::CreateDicomDir()
             gdcmErrorMacro( "Add PatientToEnd failed");
          }
       }
+      /// \to do : deal with PRIVATE (not so easy, since PRIVATE appears 
+      ///                           at defferent levels ?!? )
+      
+      else if ( v == "PRIVATE " ) // for SIEMENS 'CSA Non Image'      
+      {
+      
+         gdcmWarningMacro( " -------------------------------------------"
+              << "a PRIVATE SQItem was found : " << v);
+         si = DicomDirPrivate::New(true);
+         if ( !AddPrivateToEnd( static_cast<DicomDirPrivate *>(si)) )
+         {
+            si->Delete();
+            si = NULL;
+            gdcmErrorMacro( "Add PrivateToEnd failed");
+         }
+      }      
       else
       {
          // It was neither a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
          // nor an 'IMAGE' SQItem. Skip to next item.
-         gdcmDebugMacro( " -------------------------------------------"
+         gdcmWarningMacro( " -------------------------------------------"
          << "a non PATIENT/STUDY/SERIE/IMAGE SQItem was found : "
          << v);
 
@@ -813,6 +830,32 @@ bool DicomDir::AddImageToEnd(DicomDirImage *dd)
    return false;
 }
 
+/**
+ * \brief   AddPrivateToEnd
+ * @param   dd SQ Item to enqueue to the DicomDirPrivate chained List
+ *          (checked for SIEMENS 'CSA non image')
+ */
+bool DicomDir::AddPrivateToEnd(DicomDirPrivate *dd)
+{
+   if ( Patients.size() > 0 )
+   {
+      ListDicomDirPatient::iterator itp = Patients.end();
+      itp--;
+
+      DicomDirStudy *study = (*itp)->GetLastStudy();
+      if ( study )
+      {
+         DicomDirSerie *serie = study->GetLastSerie();
+         if ( serie )
+         {
+            serie->AddPrivate(dd);
+            return true;
+         }
+      }
+   }
+   return false;
+}
+
 /**
  * \brief  for each Header of the chained list, 
  *         add/update the Patient/Study/Serie/Image info 
index a402e279b3fd028ef932564b30927185ce4215a9..cb9145b28e1068a70986e79998ff249b2a1b5985 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.h,v $
   Language:  C++
-  Date:      $Date: 2006/05/30 08:10:19 $
-  Version:   $Revision: 1.77 $
+  Date:      $Date: 2007/03/23 15:30:15 $
+  Version:   $Revision: 1.78 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -35,6 +35,7 @@ class DicomDirStudy;
 class DicomDirSerie;
 class DicomDirVisit;
 class DicomDirImage;
+class DicomDirPrivate;
 class SQItem;
 
 typedef std::list<DicomDirPatient *> ListDicomDirPatient;
@@ -124,12 +125,13 @@ private:
    void Initialize();
    void CreateDicomDir();
    bool DoTheLoadingJob();
-   bool AddPatientToEnd(DicomDirPatient *dd);
+   bool AddPatientToEnd(DicomDirPatient *dd);   
    bool AddStudyToEnd  (DicomDirStudy *dd);
    bool AddSerieToEnd  (DicomDirSerie *dd);
    bool AddVisitToEnd  (DicomDirVisit *dd);
    bool AddImageToEnd  (DicomDirImage *dd);
-
+   bool AddPrivateToEnd(DicomDirPrivate *dd);
+   
    void SetElements(std::string const &path, VectDocument const &list);
    void SetElement (std::string const &path, DicomDirType type,
                     Document *header);
index 537d7df8f7fce5b68d158632113b65086926361d..c7ab9cf85c9ae778bb831441ae2a8ef77db66183 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirElement.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/04/11 16:03:26 $
-  Version:   $Revision: 1.43 $
+  Date:      $Date: 2007/03/23 15:30:15 $
+  Version:   $Revision: 1.44 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -87,7 +87,7 @@ DicomDirElement::DicomDirElement()
             from.getline(buff2, 1024, '"');
             elem.VR[0] = buff2[0];
             elem.VR[1] = buff2[1];
-    
+ // std::cout << "VR : [" <<  elem.VR[0] << elem.VR[1] << "]" << std::endl;  // JPR
             from >> std::ws;
             from.getline(buff, 1024, '"');
             from >> std::ws;
index 7ed69983be83857689f6fdb1e9b19333370d7d5c..b14be8549afd5ab15c7b10bcca24a698677b36a3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirElement.h,v $
   Language:  C++
-  Date:      $Date: 2006/04/11 16:03:26 $
-  Version:   $Revision: 1.38 $
+  Date:      $Date: 2007/03/23 15:30:15 $
+  Version:   $Revision: 1.39 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -36,6 +36,7 @@ typedef std::list<DicomElement> ListDicomDirStudyElem;
 typedef std::list<DicomElement> ListDicomDirVisitElem;
 typedef std::list<DicomElement> ListDicomDirSerieElem;
 typedef std::list<DicomElement> ListDicomDirImageElem;
+typedef std::list<DicomElement> ListDicomDirPrivateElem; // For "CSA Non Image"
 
 // For future use (Full DICOMDIR)
 
@@ -121,6 +122,14 @@ public:
    ListDicomDirImageElem const &GetDicomDirImageElements() const
       { return DicomDirImageList; }
 
+   /**
+    * \brief   returns a reference to the chained List 
+    *          related to the PRIVATE Elements of a DICOMDIR.
+    */      
+   ListDicomDirPrivateElem const &GetDicomDirPrivateElements() const
+      { return DicomDirPrivateList; }
+      
    // Public method to add an element
    bool AddEntry(DicomDirType type, DicomElement const &elem);
 
@@ -145,6 +154,8 @@ private:
    ListDicomDirSerieElem   DicomDirSerieList;
    /// Elements chained list, related to the ImageElements of DICOMDIR
    ListDicomDirImageElem   DicomDirImageList;
+   /// Elements chained list, related to the PrivateElements of DICOMDIR
+   ListDicomDirPrivateElem   DicomDirPrivateList;
 };
 } // end namespace gdcm
 //-----------------------------------------------------------------------------
index dae4d4e3dcc5ad22a973945a3e008bd3dc92ad8c..c19de1aae43e5f39b91d9488f401d9388785077c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirMeta.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/02/16 20:06:13 $
-  Version:   $Revision: 1.35 $
+  Date:      $Date: 2007/03/23 15:30:15 $
+  Version:   $Revision: 1.36 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -22,6 +22,7 @@
 #include "gdcmGlobal.h"
 #include "gdcmUtil.h"
 #include "gdcmDataEntry.h"
+
 namespace gdcm 
 {
 //-----------------------------------------------------------------------------
@@ -52,7 +53,7 @@ DicomDirMeta::~DicomDirMeta()
 /**
  * \brief   Writes the Meta Elements
  * @param fp ofstream to write to
- * @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
+ * @param filetype type of the file (ImplicitVR, ExplicitVR, ...)
  * @return
  */ 
 void DicomDirMeta::WriteContent(std::ofstream *fp, FileType filetype)
@@ -80,9 +81,9 @@ void DicomDirMeta::WriteContent(std::ofstream *fp, FileType filetype)
    e0000->SetString(sLen.str());
    
    for (ListDocEntry::iterator i = DocEntries.begin();  
-                              != DocEntries.end();
-                              ++i)
-   {
+                               i!= DocEntries.end();
+                             ++i)
+   {   
       (*i)->WriteContent(fp, filetype);
    }
 }
index 3737076e424ff7095a846e7e862ccfaca099a14f..1b5dbd12291e134f38eec4d752dc3d47d91b7a88 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirSerie.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/29 12:48:46 $
-  Version:   $Revision: 1.40 $
+  Date:      $Date: 2007/03/23 15:30:15 $
+  Version:   $Revision: 1.41 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,6 +19,7 @@
 #include "gdcmDicomDirSerie.h"
 #include "gdcmDicomDirElement.h"
 #include "gdcmDicomDirImage.h"
+#include "gdcmDicomDirPrivate.h"
 #include "gdcmGlobal.h"
 #include "gdcmDebug.h"
 
@@ -47,6 +48,7 @@ DicomDirSerie::DicomDirSerie(bool empty):
 DicomDirSerie::~DicomDirSerie() 
 {
    ClearImage();
+   ClearPrivate();  // For SIEMENS 'CSA non image'
 }
 
 //-----------------------------------------------------------------------------
@@ -65,7 +67,13 @@ void DicomDirSerie::WriteContent(std::ofstream *fp, FileType t)
                                  ++cc )
    {
       (*cc)->WriteContent( fp, t );
-   }
+   } 
+   for(ListDicomDirPrivate::iterator cc2 = Privates.begin();
+                                     cc2!= Privates.end();
+                                   ++cc2 )
+   {
+      (*cc2)->WriteContent( fp, t );
+   }   
 }
 
 /**
@@ -80,19 +88,33 @@ DicomDirImage *DicomDirSerie::NewImage()
 }
 
 /**
- * \brief  Remove all images in the serie 
+ * \brief  Remove all 'Images' in the serie 
+ */
+void DicomDirSerie::ClearPrivate()
+{
+   for(ListDicomDirPrivate::iterator cc = Privates.begin();
+                                     cc!= Privates.end();
+                                   ++cc)
+   {
+      (*cc)->Delete();
+   }
+   Privates.clear();
+}
+
+
+/**
+ * \brief  Remove all 'Privates' in the serie 
  */
 void DicomDirSerie::ClearImage()
 {
    for(ListDicomDirImage::iterator cc = Images.begin();
-                                   cc != Images.end();
-                                   ++cc)
+                                   cc!= Images.end();
+                                 ++cc)
    {
       (*cc)->Delete();
    }
    Images.clear();
 }
-
 /**
  * \brief   Get the first entry while visiting the DicomDirImage
  * \return  The first DicomDirImage if DicomDirserie not empty, otherwhise NULL
@@ -107,7 +129,7 @@ DicomDirImage *DicomDirSerie::GetFirstImage()
 
 /**
  * \brief   Get the next entry while visiting the DicomDirImages
- * \note : meaningfull only if GetFirstEntry already called
+ * \note : meaningfull only if GetFirstImage already called
  * \return  The next DicomDirImages if found, otherwhise NULL
  */
 DicomDirImage *DicomDirSerie::GetNextImage()
@@ -120,6 +142,33 @@ DicomDirImage *DicomDirSerie::GetNextImage()
    return NULL;
 }
 
+/**
+ * \brief   Get the first entry while visiting the DicomDirPrivate
+ * \return  The first DicomDirPrivate if DicomDirserie not empty, otherwhise NULL
+ */
+DicomDirPrivate *DicomDirSerie::GetFirstPrivate()
+{
+   ItPrivate = Privates.begin();
+   if (ItPrivate != Privates.end())
+      return *ItPrivate;
+   return NULL;
+}
+
+/**
+ * \brief   Get the next entry while visiting the DicomDirPrivates
+ * \note : meaningfull only if GetFirstPrivate already called
+ * \return  The next DicomDirPrivates if found, otherwhise NULL
+ */
+DicomDirPrivate *DicomDirSerie::GetNextPrivate()
+{
+   gdcmAssertMacro (ItPrivate != Privates.end());
+
+   ++ItPrivate;
+   if (ItPrivate != Privates.end())      
+      return *ItPrivate;
+   return NULL;
+}
+
 /**
  * \brief Copies all the attributes from an other DocEntrySet 
  * @param set entry to copy from
@@ -129,7 +178,8 @@ void DicomDirSerie::Copy(DocEntrySet *set)
 {
    // Remove all previous childs
    ClearImage();
-
+   ClearPrivate();
+   
    DicomDirObject::Copy(set);
 
    DicomDirSerie *ddEntry = dynamic_cast<DicomDirSerie *>(set);
@@ -138,7 +188,11 @@ void DicomDirSerie::Copy(DocEntrySet *set)
       Images = ddEntry->Images;
       for(ItImage = Images.begin();ItImage != Images.end();++ItImage)
          (*ItImage)->Register();
-   }
+
+      Privates = ddEntry->Privates;
+      for(ItPrivate = Privates.begin();ItPrivate != Privates.end();++ItPrivate)
+         (*ItPrivate)->Register();
+   }   
 }
 
 //-----------------------------------------------------------------------------
@@ -166,6 +220,15 @@ void DicomDirSerie::Print(std::ostream &os, std::string const &)
       (*cc)->SetPrintLevel(PrintLevel);
       (*cc)->Print(os);
    }
+
+   for(ListDicomDirPrivate::iterator cc2 = Privates.begin();
+                                     cc2 != Privates.end();
+                                   ++cc2)
+   {
+      (*cc2)->SetPrintLevel(PrintLevel);
+      (*cc2)->Print(os);
+   }   
+   
 }
 
 //-----------------------------------------------------------------------------
index 6a6fc7180da80575c378cafa79672872598d318f..ddbc51af4de9cd573b0b2615391d1c0550286552 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirSerie.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/29 12:48:46 $
-  Version:   $Revision: 1.32 $
+  Date:      $Date: 2007/03/23 15:30:15 $
+  Version:   $Revision: 1.33 $
                                                                                 
   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 DicomDirImage;
+class DicomDirPrivate;
+
 //-----------------------------------------------------------------------------
 typedef std::list<DicomDirImage *> ListDicomDirImage;
-
+typedef std::list<DicomDirPrivate *> ListDicomDirPrivate;
 //-----------------------------------------------------------------------------
 /**
  * \brief   describes a SERIE  within a within a STUDY
@@ -43,7 +45,7 @@ public:
    void Print( std::ostream &os = std::cout, std::string const &indent = "" );
    void WriteContent( std::ofstream *fp, FileType t );
 
-   // Image methods
+   // 'Image' methods
    DicomDirImage *NewImage();
    /// Add a new gdcm::DicomDirImage to the Serie
    void AddImage(DicomDirImage *obj) { Images.push_back(obj); }
@@ -52,6 +54,16 @@ public:
    DicomDirImage *GetFirstImage();
    DicomDirImage *GetNextImage();
 
+   // 'Private' methods (For SIEMENS 'CSA non image')
+   DicomDirPrivate *NewPrivate();
+   /// Add a new gdcm::DicomDirPrivate to the Serie
+   void AddPrivate(DicomDirPrivate *obj) { Privates.push_back(obj); }
+   void ClearPrivate();
+
+   DicomDirPrivate *GetFirstPrivate();
+   DicomDirPrivate *GetNextPrivate();   
+   
+   
    virtual void Copy(DocEntrySet *set);
 
 protected:
@@ -64,19 +76,18 @@ private:
    /// iterator on the DicomDirImages of the current DicomDirSerie
    ListDicomDirImage::iterator ItImage;
 
+   ///chained list of DicomDirPrivates (to be exploited recursively)
+   ListDicomDirPrivate Privates;
+   /// iterator on the DicomDirPrivates of the current DicomDirSerie
+   ListDicomDirPrivate::iterator ItPrivate;
 /*
-// for future use :
+// for future use  (Full DICOMDIR):
 
    /// chained list of DicomDirOverlays(single level)
    ListDicomDirOverlay Overlays;
    /// iterator on the DicomDirOverlays of the current DicomDirSerie
    ListDicomDirOverlay::iterator ItOverlay;
 
-   /// chained list of DicomDirModalityLuts(single level)
-   ListDicomDirModalityLut ModalityLuts;
-   /// iterator on the DicomDirModalityLuts of the current DicomDirSerie
-   ListDicomDirModalityLut::iterator ItModalityLut;
-
    /// chained list of DicomDirModalityLuts(single level)
    ListDicomDirModalityLut ModalityLuts;
    /// iterator on the DicomDirModalityLuts of the current DicomDirSerie