From ad8f0eb6ea1ad66c443b3640cded8a355efa7b42 Mon Sep 17 00:00:00 2001 From: regrain Date: Thu, 20 Jan 2005 16:16:41 +0000 Subject: [PATCH] * src/gdcmDicomDirObject.h : set the FillObject method in protected. Thus, DicomDirXXX are created with a flad that indicates if the created object is empty or not (when not empty, the DicomDirElement is used to fill the object) -- BeNours --- ChangeLog | 6 ++++++ src/gdcmDicomDir.cxx | 33 ++++++++++++++------------------- src/gdcmDicomDirImage.cxx | 16 ++++++++++++---- src/gdcmDicomDirImage.h | 6 +++--- src/gdcmDicomDirMeta.cxx | 14 ++++++++++---- src/gdcmDicomDirMeta.h | 6 +++--- src/gdcmDicomDirObject.cxx | 13 +++++++------ src/gdcmDicomDirObject.h | 7 ++++--- src/gdcmDicomDirPatient.cxx | 19 ++++++++++--------- src/gdcmDicomDirPatient.h | 6 +++--- src/gdcmDicomDirSerie.cxx | 18 ++++++++++-------- src/gdcmDicomDirSerie.h | 6 +++--- src/gdcmDicomDirStudy.cxx | 18 ++++++++++-------- src/gdcmDicomDirStudy.h | 6 +++--- 14 files changed, 98 insertions(+), 76 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f283717..6956bf1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-01-20 Benoit Regrain + * src/gdcmDicomDirObject.h : set the FillObject method in protected. + Thus, DicomDirXXX are created with a flad that indicates if the created + object is empty or not (when not empty, the DicomDirElement is used to + fill the object) + 2005-01-20 Benoit Regrain * src/gdcmDicomDir.cxx : simplify the NewPatient method, like made in gdcm::DicomDirPatient, gdcm::DicomDirStudy, gdcm::DicomDirSerie diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 7dd1f1f3..95b28004 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/01/20 11:33:44 $ - Version: $Revision: 1.110 $ + Date: $Date: 2005/01/20 16:16:41 $ + Version: $Revision: 1.111 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -471,10 +471,11 @@ DicomDirMeta * DicomDir::NewMeta() if( MetaElems ) delete MetaElems; - MetaElems = new DicomDirMeta(); if ( TagHT.begin() != TagHT.end() ) // after Document Parsing { + MetaElems = new DicomDirMeta(true); + TagDocEntryHT::iterator lastOneButSequence = TagHT.end(); lastOneButSequence --; // ALL the 'out of Sequence' Tags belong to Meta Elems @@ -488,9 +489,7 @@ DicomDirMeta * DicomDir::NewMeta() } else // after root directory parsing { - ListDicomDirMetaElem const &elemList = - Global::GetDicomDirElements()->GetDicomDirMetaElements(); - MetaElems->FillObject(elemList); + MetaElems = new DicomDirMeta(false); } MetaElems->SetSQItemNumber(0); // To avoid further missprinting return MetaElems; @@ -501,11 +500,7 @@ DicomDirMeta * DicomDir::NewMeta() */ DicomDirPatient *DicomDir::NewPatient() { - ListDicomDirPatientElem const & elemList = - Global::GetDicomDirElements()->GetDicomDirPatientElements(); DicomDirPatient *p = new DicomDirPatient(); - p->FillObject(elemList); - AddPatientToEnd( p ); return p; } @@ -533,7 +528,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, { case GDCM_DICOMDIR_IMAGE: elemList = Global::GetDicomDirElements()->GetDicomDirImageElements(); - si = new DicomDirImage(); + si = new DicomDirImage(true); if( !AddImageToEnd(static_cast(si)) ) { delete si; @@ -542,7 +537,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, break; case GDCM_DICOMDIR_SERIE: elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements(); - si = new DicomDirSerie(); + si = new DicomDirSerie(true); if( !AddSerieToEnd(static_cast(si)) ) { delete si; @@ -551,7 +546,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, break; case GDCM_DICOMDIR_STUDY: elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements(); - si = new DicomDirStudy(); + si = new DicomDirStudy(true); if( !AddStudyToEnd(static_cast(si)) ) { delete si; @@ -560,7 +555,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, break; case GDCM_DICOMDIR_PATIENT: elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements(); - si = new DicomDirPatient(); + si = new DicomDirPatient(true); if( !AddPatientToEnd(static_cast(si)) ) { delete si; @@ -569,7 +564,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, break; case GDCM_DICOMDIR_META: elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements(); - si = new DicomDirMeta(); + si = new DicomDirMeta(true); if( MetaElems ) { delete MetaElems; @@ -767,7 +762,7 @@ void DicomDir::CreateDicomDir() if( v == "PATIENT " ) { - si = new DicomDirPatient(); + si = new DicomDirPatient(true); if( !AddPatientToEnd( static_cast(si)) ) { delete si; @@ -777,7 +772,7 @@ void DicomDir::CreateDicomDir() } else if( v == "STUDY " ) { - si = new DicomDirStudy(); + si = new DicomDirStudy(true); if( !AddStudyToEnd( static_cast(si)) ) { delete si; @@ -787,7 +782,7 @@ void DicomDir::CreateDicomDir() } else if( v == "SERIES" ) { - si = new DicomDirSerie(); + si = new DicomDirSerie(true); if( !AddSerieToEnd( static_cast(si)) ) { delete si; @@ -797,7 +792,7 @@ void DicomDir::CreateDicomDir() } else if( v == "IMAGE " ) { - si = new DicomDirImage(); + si = new DicomDirImage(true); if( !AddImageToEnd( static_cast(si)) ) { delete si; diff --git a/src/gdcmDicomDirImage.cxx b/src/gdcmDicomDirImage.cxx index 0ddbfc46..6ad054f8 100644 --- a/src/gdcmDicomDirImage.cxx +++ b/src/gdcmDicomDirImage.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirImage.cxx,v $ Language: C++ - Date: $Date: 2005/01/18 14:28:32 $ - Version: $Revision: 1.18 $ + Date: $Date: 2005/01/20 16:16:42 $ + Version: $Revision: 1.19 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -18,6 +18,7 @@ #include "gdcmDicomDirImage.h" #include "gdcmValEntry.h" +#include "gdcmGlobal.h" namespace gdcm { @@ -26,10 +27,17 @@ namespace gdcm /** * \brief Constructor */ -DicomDirImage::DicomDirImage(): +DicomDirImage::DicomDirImage(bool empty): DicomDirObject() { + if( !empty ) + { + ListDicomDirImageElem const &elemList = + Global::GetDicomDirElements()->GetDicomDirImageElements(); + FillObject(elemList); + } } + /** * \brief Canonical destructor. */ @@ -54,7 +62,7 @@ void DicomDirImage::Print(std::ostream &os, std::string const & ) { if( (*i)->GetGroup() == 0x0004 && (*i)->GetElement() == 0x1500 ) { - os << ((ValEntry *)(*i))->GetValue(); //FIXME + os << (dynamic_cast(*i))->GetValue(); //FIXME } } os << std::endl; diff --git a/src/gdcmDicomDirImage.h b/src/gdcmDicomDirImage.h index cb5026df..a212aeb2 100644 --- a/src/gdcmDicomDirImage.h +++ b/src/gdcmDicomDirImage.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirImage.h,v $ Language: C++ - Date: $Date: 2005/01/16 04:50:41 $ - Version: $Revision: 1.14 $ + Date: $Date: 2005/01/20 16:16:42 $ + Version: $Revision: 1.15 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -32,7 +32,7 @@ namespace gdcm class GDCM_EXPORT DicomDirImage : public DicomDirObject { public: - DicomDirImage(); + DicomDirImage(bool empty=false); ~DicomDirImage(); void Print(std::ostream &os = std::cout, std::string const & indent = "" ); diff --git a/src/gdcmDicomDirMeta.cxx b/src/gdcmDicomDirMeta.cxx index 43f2c056..516150de 100644 --- a/src/gdcmDicomDirMeta.cxx +++ b/src/gdcmDicomDirMeta.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirMeta.cxx,v $ Language: C++ - Date: $Date: 2005/01/18 14:28:32 $ - Version: $Revision: 1.23 $ + Date: $Date: 2005/01/20 16:16:42 $ + Version: $Revision: 1.24 $ 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 "gdcmDicomDirMeta.h" #include "gdcmDocument.h" #include "gdcmDocEntry.h" +#include "gdcmGlobal.h" namespace gdcm { @@ -29,9 +30,15 @@ namespace gdcm /** * \brief Constructor */ -DicomDirMeta::DicomDirMeta(): +DicomDirMeta::DicomDirMeta(bool empty): DicomDirObject() { + if( !empty ) + { + ListDicomDirStudyElem const &elemList = + Global::GetDicomDirElements()->GetDicomDirMetaElements(); + FillObject(elemList); + } } /** @@ -90,5 +97,4 @@ void DicomDirMeta::WriteContent(std::ofstream *fp, FileType t) // Private //----------------------------------------------------------------------------- - } // end namespace gdcm diff --git a/src/gdcmDicomDirMeta.h b/src/gdcmDicomDirMeta.h index 9e530882..3274a9af 100644 --- a/src/gdcmDicomDirMeta.h +++ b/src/gdcmDicomDirMeta.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirMeta.h,v $ Language: C++ - Date: $Date: 2005/01/16 04:50:41 $ - Version: $Revision: 1.16 $ + Date: $Date: 2005/01/20 16:16:42 $ + Version: $Revision: 1.17 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -32,7 +32,7 @@ namespace gdcm class GDCM_EXPORT DicomDirMeta : public DicomDirObject { public: - DicomDirMeta(); + DicomDirMeta(bool empty=false); ~DicomDirMeta(); virtual void Print(std::ostream &os = std::cout, std::string const & indent = "" ); diff --git a/src/gdcmDicomDirObject.cxx b/src/gdcmDicomDirObject.cxx index c4501ffc..a06a2810 100644 --- a/src/gdcmDicomDirObject.cxx +++ b/src/gdcmDicomDirObject.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirObject.cxx,v $ Language: C++ - Date: $Date: 2005/01/20 11:09:23 $ - Version: $Revision: 1.16 $ + Date: $Date: 2005/01/20 16:16:42 $ + Version: $Revision: 1.17 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -37,7 +37,6 @@ DicomDirObject::DicomDirObject(int depth) { } - /** * \brief Canonical destructor. */ @@ -45,7 +44,6 @@ DicomDirObject::~DicomDirObject() { } - //----------------------------------------------------------------------------- // Public @@ -59,7 +57,6 @@ DicomDirObject::~DicomDirObject() void DicomDirObject::FillObject(ListDicomDirMetaElem const &elemList) { // FillObject fills up the SQItem that will be conneected to the right place - ListDicomDirMetaElem::const_iterator it; uint16_t tmpGr,tmpEl; DictEntry *dictEntry; @@ -78,5 +75,9 @@ void DicomDirObject::FillObject(ListDicomDirMetaElem const &elemList) AddEntry(entry); } } -} // end namespace gdcm +//----------------------------------------------------------------------------- +// Private + +//----------------------------------------------------------------------------- +} // end namespace gdcm diff --git a/src/gdcmDicomDirObject.h b/src/gdcmDicomDirObject.h index 2c70277b..361f4964 100644 --- a/src/gdcmDicomDirObject.h +++ b/src/gdcmDicomDirObject.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirObject.h,v $ Language: C++ - Date: $Date: 2005/01/20 11:09:23 $ - Version: $Revision: 1.13 $ + Date: $Date: 2005/01/20 16:16:42 $ + Version: $Revision: 1.14 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -41,7 +41,6 @@ typedef std::list ListContent; class GDCM_EXPORT DicomDirObject : public SQItem { public: - void FillObject(ListDicomDirMetaElem const &elemList); protected: // Constructor and destructor are protected to avoid end user to @@ -49,6 +48,8 @@ protected: // NO ! DicomDir needs to instanciate it! DicomDirObject(int depth = 1); ~DicomDirObject(); + + void FillObject(ListDicomDirMetaElem const &elemList); }; } // end namespace gdcm diff --git a/src/gdcmDicomDirPatient.cxx b/src/gdcmDicomDirPatient.cxx index 035f6492..cc2ba5b5 100644 --- a/src/gdcmDicomDirPatient.cxx +++ b/src/gdcmDicomDirPatient.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirPatient.cxx,v $ Language: C++ - Date: $Date: 2005/01/20 11:09:23 $ - Version: $Revision: 1.29 $ + Date: $Date: 2005/01/20 16:16:42 $ + Version: $Revision: 1.30 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -31,10 +31,17 @@ namespace gdcm /** * \brief Constructor */ -DicomDirPatient::DicomDirPatient(): +DicomDirPatient::DicomDirPatient(bool empty): DicomDirObject() { + if( !empty ) + { + ListDicomDirStudyElem const &elemList = + Global::GetDicomDirElements()->GetDicomDirPatientElements(); + FillObject(elemList); + } } + /** * \brief Canonical destructor. */ @@ -94,12 +101,7 @@ void DicomDirPatient::WriteContent(std::ofstream *fp, FileType t) */ DicomDirStudy* DicomDirPatient::NewStudy() { - ListDicomDirStudyElem const &elemList = - Global::GetDicomDirElements()->GetDicomDirStudyElements(); - DicomDirStudy *st = new DicomDirStudy(); - st->FillObject(elemList); - Studies.push_back(st); return st; } @@ -154,5 +156,4 @@ DicomDirStudy *DicomDirPatient::GetLastStudy() // Private //----------------------------------------------------------------------------- - } // end namespace gdcm diff --git a/src/gdcmDicomDirPatient.h b/src/gdcmDicomDirPatient.h index b3602e5a..d1f9ebfe 100644 --- a/src/gdcmDicomDirPatient.h +++ b/src/gdcmDicomDirPatient.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirPatient.h,v $ Language: C++ - Date: $Date: 2005/01/20 11:09:23 $ - Version: $Revision: 1.21 $ + Date: $Date: 2005/01/20 16:16:42 $ + Version: $Revision: 1.22 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -36,7 +36,7 @@ typedef std::list ListDicomDirStudy; class GDCM_EXPORT DicomDirPatient : public DicomDirObject { public: - DicomDirPatient(); + DicomDirPatient(bool empty=false); ~DicomDirPatient(); void Print(std::ostream &os = std::cout, std::string const & indent = "" ); diff --git a/src/gdcmDicomDirSerie.cxx b/src/gdcmDicomDirSerie.cxx index 0abf587e..5ae79875 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/01/20 11:09:23 $ - Version: $Revision: 1.31 $ + Date: $Date: 2005/01/20 16:16:42 $ + Version: $Revision: 1.32 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -30,10 +30,17 @@ namespace gdcm /** * \brief Constructor */ -DicomDirSerie::DicomDirSerie(): +DicomDirSerie::DicomDirSerie(bool empty): DicomDirObject() { + if( !empty ) + { + ListDicomDirSerieElem const &elemList = + Global::GetDicomDirElements()->GetDicomDirSerieElements(); + FillObject(elemList); + } } + /** * \brief Canonical destructor. */ @@ -92,12 +99,7 @@ void DicomDirSerie::WriteContent(std::ofstream *fp, FileType t) */ DicomDirImage *DicomDirSerie::NewImage() { - ListDicomDirImageElem const &elemList = - Global::GetDicomDirElements()->GetDicomDirImageElements(); - DicomDirImage *st = new DicomDirImage(); - st->FillObject(elemList); - Images.push_back(st); return st; } diff --git a/src/gdcmDicomDirSerie.h b/src/gdcmDicomDirSerie.h index 75140047..c87f0037 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/01/20 11:09:23 $ - Version: $Revision: 1.22 $ + Date: $Date: 2005/01/20 16:16:42 $ + Version: $Revision: 1.23 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -35,7 +35,7 @@ typedef std::list ListDicomDirImage; class GDCM_EXPORT DicomDirSerie : public DicomDirObject { public: - DicomDirSerie(); + DicomDirSerie(bool empty=false); ~DicomDirSerie(); void Print( std::ostream &os = std::cout, std::string const & indent = "" ); diff --git a/src/gdcmDicomDirStudy.cxx b/src/gdcmDicomDirStudy.cxx index 3a552627..6c43c6b0 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/01/20 11:09:23 $ - Version: $Revision: 1.28 $ + Date: $Date: 2005/01/20 16:16:42 $ + 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 @@ -29,10 +29,17 @@ namespace gdcm /** * \brief Constructor */ -DicomDirStudy::DicomDirStudy(): +DicomDirStudy::DicomDirStudy(bool empty): DicomDirObject() { + if( !empty ) + { + ListDicomDirStudyElem const &elemList = + Global::GetDicomDirElements()->GetDicomDirStudyElements(); + FillObject(elemList); + } } + /** * \brief Canonical destructor. */ @@ -94,12 +101,7 @@ void DicomDirStudy::WriteContent(std::ofstream *fp, FileType t) */ DicomDirSerie *DicomDirStudy::NewSerie() { - ListDicomDirSerieElem const &elemList = - Global::GetDicomDirElements()->GetDicomDirSerieElements(); - DicomDirSerie* st = new DicomDirSerie(); - st->FillObject(elemList); - Series.push_back(st); return st; } diff --git a/src/gdcmDicomDirStudy.h b/src/gdcmDicomDirStudy.h index 57d533af..ae743881 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/01/20 11:09:23 $ - Version: $Revision: 1.20 $ + Date: $Date: 2005/01/20 16:16:42 $ + Version: $Revision: 1.21 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -35,7 +35,7 @@ typedef std::list ListDicomDirSerie; class GDCM_EXPORT DicomDirStudy : public DicomDirObject { public: - DicomDirStudy(); + DicomDirStudy(bool empty=false); ~DicomDirStudy(); void Print(std::ostream &os = std::cout, std::string const & indent = "" ); -- 2.45.1