From: jpr Date: Fri, 8 Jul 2005 19:07:12 +0000 (+0000) Subject: Add the VISIT object within DicomDir X-Git-Tag: Version1.2.bp~341 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=6ae0c7b2171502cfc859786a4380efa7bcabcb2f;p=gdcm.git Add the VISIT object within DicomDir --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f13d7f09..6a271f79 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -39,6 +39,7 @@ SET(libgdcm_la_SOURCES gdcmDicomDirMeta.cxx gdcmDicomDirObject.cxx gdcmDicomDirPatient.cxx + gdcmDicomDirVisit.cxx gdcmDicomDirSerie.cxx gdcmDicomDirStudy.cxx gdcmDict.cxx diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 60d53366..606a6437 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -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(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 diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index 64b61a3a..3fc3c11f 100644 --- a/src/gdcmDicomDir.h +++ b/src/gdcmDicomDir.h @@ -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); diff --git a/src/gdcmDicomDirElement.h b/src/gdcmDicomDirElement.h index 4540ce16..0da4be80 100644 --- a/src/gdcmDicomDirElement.h +++ b/src/gdcmDicomDirElement.h @@ -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 ListDicomDirSerieElem; typedef std::list ListDicomDirImageElem; // For future use (Full DICOMDIR) + +typedef std::list ListDicomDirVisitElem; /* -typedef std::list ListDicomDirVisit; typedef std::list ListDicomDirResult; typedef std::list 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 diff --git a/src/gdcmDicomDirStudy.cxx b/src/gdcmDicomDirStudy.cxx index 4bb284ff..2151e441 100644 --- a/src/gdcmDicomDirStudy.cxx +++ b/src/gdcmDicomDirStudy.cxx @@ -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); + } + } //----------------------------------------------------------------------------- diff --git a/src/gdcmDicomDirStudy.h b/src/gdcmDicomDirStudy.h index 936a7f7c..bac65508 100644 --- a/src/gdcmDicomDirStudy.h +++ b/src/gdcmDicomDirStudy.h @@ -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 @@ -24,15 +24,16 @@ namespace gdcm { class DicomDirSerie; +class DicomDirVisit; //----------------------------------------------------------------------------- typedef std::list ListDicomDirSerie; -/* + // For future use (Full DICOMDIR) typedef std::list ListDicomDirVisit; +/* typedef std::list ListDicomDirResult; typedef std::list 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 index 00000000..b5c9eaba --- /dev/null +++ b/src/gdcmDicomDirVisit.cxx @@ -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(*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 index 00000000..18337fba --- /dev/null +++ b/src/gdcmDicomDirVisit.h @@ -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