From 2410af81c71712957890eb38d9ecacc77adcd72e Mon Sep 17 00:00:00 2001 From: jpr Date: Fri, 23 Mar 2007 15:30:15 +0000 Subject: [PATCH] Deal with PRIVATE (at PrintDicomDir time, not MakeDicomDir time ...) --- src/CMakeLists.txt | 1 + src/gdcmCommandManager.h | 22 +++++----- src/gdcmCommon.h | 5 ++- src/gdcmDicomDir.cxx | 49 ++++++++++++++++++++-- src/gdcmDicomDir.h | 10 +++-- src/gdcmDicomDirElement.cxx | 6 +-- src/gdcmDicomDirElement.h | 15 ++++++- src/gdcmDicomDirMeta.cxx | 13 +++--- src/gdcmDicomDirSerie.cxx | 83 ++++++++++++++++++++++++++++++++----- src/gdcmDicomDirSerie.h | 31 +++++++++----- 10 files changed, 184 insertions(+), 51 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6325c3be..9e7065a4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,6 +32,7 @@ SET(GDCM_SOURCES gdcmDicomDir.cxx gdcmDicomDirElement.cxx gdcmDicomDirImage.cxx + gdcmDicomDirPrivate.cxx gdcmDicomDirMeta.cxx gdcmDicomDirObject.cxx gdcmDicomDirPatient.cxx diff --git a/src/gdcmCommandManager.h b/src/gdcmCommandManager.h index 9d964109..ff21e0c1 100644 --- a/src/gdcmCommandManager.h +++ b/src/gdcmCommandManager.h @@ -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 CommandKey; +typedef std::pair CommandKey; typedef std::map 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; diff --git a/src/gdcmCommon.h b/src/gdcmCommon.h index 91a978da..64720371 100644 --- a/src/gdcmCommon.h +++ b/src/gdcmCommon.h @@ -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" diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 6c42fea2..96e35066 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -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(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 diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index a402e279..cb9145b2 100644 --- a/src/gdcmDicomDir.h +++ b/src/gdcmDicomDir.h @@ -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 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); diff --git a/src/gdcmDicomDirElement.cxx b/src/gdcmDicomDirElement.cxx index 537d7df8..c7ab9cf8 100644 --- a/src/gdcmDicomDirElement.cxx +++ b/src/gdcmDicomDirElement.cxx @@ -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; diff --git a/src/gdcmDicomDirElement.h b/src/gdcmDicomDirElement.h index 7ed69983..b14be854 100644 --- a/src/gdcmDicomDirElement.h +++ b/src/gdcmDicomDirElement.h @@ -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 ListDicomDirStudyElem; typedef std::list ListDicomDirVisitElem; typedef std::list ListDicomDirSerieElem; typedef std::list ListDicomDirImageElem; +typedef std::list 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 //----------------------------------------------------------------------------- diff --git a/src/gdcmDicomDirMeta.cxx b/src/gdcmDicomDirMeta.cxx index dae4d4e3..c19de1aa 100644 --- a/src/gdcmDicomDirMeta.cxx +++ b/src/gdcmDicomDirMeta.cxx @@ -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(); - i != DocEntries.end(); - ++i) - { + i!= DocEntries.end(); + ++i) + { (*i)->WriteContent(fp, filetype); } } diff --git a/src/gdcmDicomDirSerie.cxx b/src/gdcmDicomDirSerie.cxx index 3737076e..1b5dbd12 100644 --- a/src/gdcmDicomDirSerie.cxx +++ b/src/gdcmDicomDirSerie.cxx @@ -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(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); + } + } //----------------------------------------------------------------------------- diff --git a/src/gdcmDicomDirSerie.h b/src/gdcmDicomDirSerie.h index 6a6fc718..ddbc51af 100644 --- a/src/gdcmDicomDirSerie.h +++ b/src/gdcmDicomDirSerie.h @@ -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 @@ -24,9 +24,11 @@ namespace gdcm { class DicomDirImage; +class DicomDirPrivate; + //----------------------------------------------------------------------------- typedef std::list ListDicomDirImage; - +typedef std::list 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 -- 2.48.1