From: regrain Date: Tue, 29 Nov 2005 12:48:45 +0000 (+0000) Subject: * Add the Copy method in all datas X-Git-Tag: Version1.3~15 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=5ac625c72835828d687ebdef878691d0913ae41b;p=gdcm.git * Add the Copy method in all datas * Remove the MoveItem in the SQItem... that was a stuff for the DicomDir -- BeNours --- diff --git a/src/gdcmDataEntry.cxx b/src/gdcmDataEntry.cxx index f80dd7d2..97afe0cb 100644 --- a/src/gdcmDataEntry.cxx +++ b/src/gdcmDataEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDataEntry.cxx,v $ Language: C++ - Date: $Date: 2005/11/21 12:15:06 $ - Version: $Revision: 1.23 $ + Date: $Date: 2005/11/29 12:48:45 $ + 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 @@ -452,9 +452,11 @@ std::string const &DataEntry::GetString() const } return StrArea; } + /** - * \brief Copies all the attributes from an other DocEntry + * \brief Copies all the attributes from an other DocEntry * @param doc entry to copy from + * @remarks The content BinArea is copied too */ void DataEntry::Copy(DocEntry *doc) { @@ -468,6 +470,7 @@ void DataEntry::Copy(DocEntry *doc) CopyBinArea(entry->BinArea,entry->GetLength()); } } + /** * \brief Writes the 'value' area of a DataEntry * @param fp already open ofstream pointer diff --git a/src/gdcmDataEntry.h b/src/gdcmDataEntry.h index b545ff0c..67413d8c 100644 --- a/src/gdcmDataEntry.h +++ b/src/gdcmDataEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDataEntry.h,v $ Language: C++ - Date: $Date: 2005/11/21 09:46:25 $ - Version: $Revision: 1.10 $ + Date: $Date: 2005/11/29 12:48:45 $ + Version: $Revision: 1.11 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -115,7 +115,7 @@ public: /// \brief true id Entry is a Pixel Data entry bool IsPixelData() { return (Flag &FLAG_PIXELDATA) != 0; } - void Copy(DocEntry *doc); + virtual void Copy(DocEntry *doc); /// \brief returns the size threshold above which an element value /// will NOT be *printed* in order no to polute the screen output diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index ef45a81e..1a470809 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/11/28 16:31:23 $ - Version: $Revision: 1.175 $ + Date: $Date: 2005/11/29 12:48:45 $ + Version: $Revision: 1.176 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -118,7 +118,6 @@ namespace gdcm * \brief Constructor : creates an empty DicomDir */ DicomDir::DicomDir() - :Document( ) { Initialize(); // sets all private fields to NULL ParseDir = false; @@ -436,6 +435,33 @@ bool DicomDir::Anonymize() return true; } +/** + * \brief Copies all the attributes from an other DocEntrySet + * @param set entry to copy from + * @remarks The contained DocEntries a not copied, only referenced + */ +void DicomDir::Copy(DocEntrySet *set) +{ + // Remove all previous childs + ClearPatient(); + + Document::Copy(set); + + DicomDir *dd = dynamic_cast(set); + if( dd ) + { + if(MetaElems) + MetaElems->Unregister(); + MetaElems = dd->MetaElems; + if(MetaElems) + MetaElems->Register(); + + Patients = dd->Patients; + for(ItPatient = Patients.begin();ItPatient != Patients.end();++ItPatient) + (*ItPatient)->Register(); + } +} + //----------------------------------------------------------------------------- // Protected /** @@ -653,7 +679,7 @@ void DicomDir::CreateDicomDir() continue; } if ( si ) - si->MoveObject(tmpSI); // New code : Copies the List + si->Copy(tmpSI); tmpSI=s->GetNextSQItem(); } diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index d9ec5b33..15162e8d 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/11/28 15:20:32 $ - Version: $Revision: 1.71 $ + Date: $Date: 2005/11/29 12:48:46 $ + Version: $Revision: 1.72 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -98,6 +98,8 @@ public: bool Anonymize(); + virtual void Copy(DocEntrySet *set); + /// Types of the DicomDirObject within the DicomDir typedef enum { diff --git a/src/gdcmDicomDirPatient.cxx b/src/gdcmDicomDirPatient.cxx index 73680f80..4fc33c58 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/10/25 14:52:33 $ - Version: $Revision: 1.39 $ + Date: $Date: 2005/11/29 12:48:46 $ + Version: $Revision: 1.40 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -136,6 +136,27 @@ DicomDirStudy *DicomDirPatient::GetLastStudy() return NULL; } +/** + * \brief Copies all the attributes from an other DocEntrySet + * @param set entry to copy from + * @remarks The contained DocEntries a not copied, only referenced + */ +void DicomDirPatient::Copy(DocEntrySet *set) +{ + // Remove all previous childs + ClearStudy(); + + DicomDirObject::Copy(set); + + DicomDirPatient *ddEntry = dynamic_cast(set); + if( ddEntry ) + { + Studies = ddEntry->Studies; + for(ItStudy = Studies.begin();ItStudy != Studies.end();++ItStudy) + (*ItStudy)->Register(); + } +} + //----------------------------------------------------------------------------- // Protected diff --git a/src/gdcmDicomDirPatient.h b/src/gdcmDicomDirPatient.h index 42a44903..c192970c 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/11/21 09:46:25 $ - Version: $Revision: 1.29 $ + Date: $Date: 2005/11/29 12:48:46 $ + 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 @@ -54,6 +54,8 @@ public: DicomDirStudy *GetNextStudy(); DicomDirStudy *GetLastStudy(); + virtual void Copy(DocEntrySet *set); + protected: DicomDirPatient(bool empty=false); ~DicomDirPatient(); diff --git a/src/gdcmDicomDirSerie.cxx b/src/gdcmDicomDirSerie.cxx index 090dac64..3737076e 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/10/25 14:52:33 $ - Version: $Revision: 1.39 $ + Date: $Date: 2005/11/29 12:48:46 $ + Version: $Revision: 1.40 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -120,6 +120,27 @@ DicomDirImage *DicomDirSerie::GetNextImage() return NULL; } +/** + * \brief Copies all the attributes from an other DocEntrySet + * @param set entry to copy from + * @remarks The contained DocEntries a not copied, only referenced + */ +void DicomDirSerie::Copy(DocEntrySet *set) +{ + // Remove all previous childs + ClearImage(); + + DicomDirObject::Copy(set); + + DicomDirSerie *ddEntry = dynamic_cast(set); + if( ddEntry ) + { + Images = ddEntry->Images; + for(ItImage = Images.begin();ItImage != Images.end();++ItImage) + (*ItImage)->Register(); + } +} + //----------------------------------------------------------------------------- // Protected diff --git a/src/gdcmDicomDirSerie.h b/src/gdcmDicomDirSerie.h index eecc374a..6a6fc718 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/21 09:46:25 $ - Version: $Revision: 1.31 $ + Date: $Date: 2005/11/29 12:48:46 $ + 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 @@ -52,6 +52,8 @@ public: DicomDirImage *GetFirstImage(); DicomDirImage *GetNextImage(); + virtual void Copy(DocEntrySet *set); + protected: DicomDirSerie(bool empty=false); ~DicomDirSerie(); diff --git a/src/gdcmDicomDirStudy.cxx b/src/gdcmDicomDirStudy.cxx index b907e698..66c29bcb 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/10/25 14:52:33 $ - Version: $Revision: 1.41 $ + Date: $Date: 2005/11/29 12:48:46 $ + Version: $Revision: 1.42 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -213,6 +213,32 @@ DicomDirVisit *DicomDirStudy::GetLastVisit() return NULL; } +/** + * \brief Copies all the attributes from an other DocEntrySet + * @param set entry to copy from + * @remarks The contained DocEntries a not copied, only referenced + */ +void DicomDirStudy::Copy(DocEntrySet *set) +{ + // Remove all previous childs + ClearSerie(); + ClearVisit(); + + DicomDirObject::Copy(set); + + DicomDirStudy *ddEntry = dynamic_cast(set); + if( ddEntry ) + { + Series = ddEntry->Series; + for(ItSerie = Series.begin();ItSerie != Series.end();++ItSerie) + (*ItSerie)->Register(); + + Visits = ddEntry->Visits; + for(ItVisit = Visits.begin();ItVisit != Visits.end();++ItVisit) + (*ItVisit)->Register(); + } +} + //----------------------------------------------------------------------------- // Protected diff --git a/src/gdcmDicomDirStudy.h b/src/gdcmDicomDirStudy.h index 6806dc2f..afe52f85 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/11/21 09:46:25 $ - Version: $Revision: 1.31 $ + Date: $Date: 2005/11/29 12:48:46 $ + 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 @@ -80,6 +80,8 @@ public: DicomDirStudyComponent *GetLastStudyComponent(); */ + virtual void Copy(DocEntrySet *set); + protected: DicomDirStudy(bool empty=false); ~DicomDirStudy(); diff --git a/src/gdcmDocEntry.cxx b/src/gdcmDocEntry.cxx index 706d023c..f343fb60 100644 --- a/src/gdcmDocEntry.cxx +++ b/src/gdcmDocEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.cxx,v $ Language: C++ - Date: $Date: 2005/11/21 12:15:06 $ - Version: $Revision: 1.78 $ + Date: $Date: 2005/11/29 12:48:46 $ + Version: $Revision: 1.79 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -219,7 +219,7 @@ bool DocEntry::IsSequenceDelimitor() } /** - * \brief Copies all the attributes from an other DocEntry + * \brief Copies all the attributes from an other DocEntry * @param doc entry to copy from */ void DocEntry::Copy(DocEntry *doc) diff --git a/src/gdcmDocEntry.h b/src/gdcmDocEntry.h index c0d40870..ee5c7eb6 100644 --- a/src/gdcmDocEntry.h +++ b/src/gdcmDocEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.h,v $ Language: C++ - Date: $Date: 2005/11/28 16:31:23 $ - Version: $Revision: 1.58 $ + Date: $Date: 2005/11/29 12:48:46 $ + Version: $Revision: 1.59 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -122,8 +122,8 @@ public: bool IsItemDelimitor(); bool IsItemStarter(); bool IsSequenceDelimitor(); - - virtual void Copy(DocEntry *e); + + virtual void Copy(DocEntry *doc); protected: DocEntry(DictEntry*); diff --git a/src/gdcmDocEntrySet.h b/src/gdcmDocEntrySet.h index 80f27e9e..319cf3b1 100644 --- a/src/gdcmDocEntrySet.h +++ b/src/gdcmDocEntrySet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.h,v $ Language: C++ - Date: $Date: 2005/11/28 16:31:23 $ - Version: $Revision: 1.65 $ + Date: $Date: 2005/11/29 12:48:47 $ + Version: $Revision: 1.66 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -111,6 +111,8 @@ public: VRKey const &vr = GDCM_VRUNKNOWN); SeqEntry *NewSeqEntry(uint16_t group, uint16_t elem); + virtual void Copy(DocEntrySet *set) {}; + protected: /// Canonical Constructor DocEntrySet(); diff --git a/src/gdcmElementSet.cxx b/src/gdcmElementSet.cxx index a59c4e19..4804928c 100644 --- a/src/gdcmElementSet.cxx +++ b/src/gdcmElementSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.cxx,v $ Language: C++ - Date: $Date: 2005/10/27 11:39:34 $ - Version: $Revision: 1.70 $ + Date: $Date: 2005/11/29 12:48:47 $ + Version: $Revision: 1.71 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -170,6 +170,29 @@ DocEntry *ElementSet::GetDocEntry(uint16_t group, uint16_t elem) return NULL; } +/** + * \brief Copies all the attributes from an other DocEntrySet + * @param set entry to copy from + * @remarks The contained DocEntries a not copied, only referenced + */ +void ElementSet::Copy(DocEntrySet *set) +{ + // Remove all previous entries + ClearEntry(); + + DocEntrySet::Copy(set); + + ElementSet *eltSet = dynamic_cast(set); + if( eltSet ) + { + TagHT = eltSet->TagHT; + for(ItTagHT = TagHT.begin();ItTagHT != TagHT.end();++ItTagHT) + { + (ItTagHT->second)->Register(); + } + } +} + //----------------------------------------------------------------------------- // Protected diff --git a/src/gdcmElementSet.h b/src/gdcmElementSet.h index 85021cbd..ab4b3a7b 100644 --- a/src/gdcmElementSet.h +++ b/src/gdcmElementSet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.h,v $ Language: C++ - Date: $Date: 2005/11/22 20:27:58 $ - Version: $Revision: 1.52 $ + Date: $Date: 2005/11/29 12:48:47 $ + Version: $Revision: 1.53 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -57,6 +57,8 @@ public: /// Tells us if the ElementSet contains no entry bool IsEmpty() { return TagHT.empty(); } + virtual void Copy(DocEntrySet *set); + protected: ElementSet(); ~ElementSet(); diff --git a/src/gdcmSQItem.cxx b/src/gdcmSQItem.cxx index d5f11db5..310be6b8 100644 --- a/src/gdcmSQItem.cxx +++ b/src/gdcmSQItem.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSQItem.cxx,v $ Language: C++ - Date: $Date: 2005/11/21 09:46:27 $ - Version: $Revision: 1.80 $ + Date: $Date: 2005/11/29 12:48:47 $ + Version: $Revision: 1.81 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -200,15 +200,6 @@ void SQItem::ClearEntry() DocEntries.clear(); } -/** - * \brief Move all the entries from a given Sequence Item - */ -void SQItem::MoveObject(SQItem *source) -{ - DocEntries = source->DocEntries; - source->DocEntries.clear(); -} - /** * \brief Get the first Dicom entry while visiting the SQItem * \return The first DocEntry if found, otherwhise 0 @@ -251,6 +242,30 @@ DocEntry *SQItem::GetDocEntry(uint16_t group, uint16_t elem) return NULL; } +/** + * \brief Copies all the attributes from an other DocEntrySet + * @param set entry to copy from + * @remarks The contained DocEntries a not copied, only referenced + */ +void SQItem::Copy(DocEntrySet *set) +{ + // Remove all previous entries + ClearEntry(); + + DocEntrySet::Copy(set); + + SQItem *sq = dynamic_cast(set); + if( sq ) + { + SQDepthLevel = sq->SQDepthLevel; + SQItemNumber = sq->SQItemNumber; + + DocEntries = sq->DocEntries; + for(ItDocEntries = DocEntries.begin();ItDocEntries != DocEntries.end();++ItDocEntries) + (*ItDocEntries)->Register(); + } +} + //----------------------------------------------------------------------------- // Protected diff --git a/src/gdcmSQItem.h b/src/gdcmSQItem.h index b76afb5a..28b18715 100644 --- a/src/gdcmSQItem.h +++ b/src/gdcmSQItem.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSQItem.h,v $ Language: C++ - Date: $Date: 2005/11/07 09:46:37 $ - Version: $Revision: 1.48 $ + Date: $Date: 2005/11/29 12:48:47 $ + Version: $Revision: 1.49 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -52,7 +52,6 @@ public: bool AddEntry(DocEntry *Entry); // add to the List bool RemoveEntry(DocEntry *EntryToRemove); void ClearEntry(); - void MoveObject(SQItem *source); DocEntry *GetFirstEntry(); DocEntry *GetNextEntry(); @@ -72,6 +71,8 @@ public: /// \brief Accessor on \ref SQDepthLevel. void SetDepthLevel(int depth) { SQDepthLevel = depth; } + virtual void Copy(DocEntrySet *set); + protected: SQItem(int depthLevel); ~SQItem(); @@ -81,8 +82,6 @@ protected: ListDocEntry DocEntries; /// Iterator, used to visit the entries ListDocEntry::iterator ItDocEntries; - /// Iterator, used to visit the Val Entries (for Python users) - ListDocEntry::iterator ItValEntries; private: /// \brief Sequences can be nested. This \ref SQDepthLevel represents diff --git a/src/gdcmSeqEntry.cxx b/src/gdcmSeqEntry.cxx index fb0dfdfc..dd5c582a 100644 --- a/src/gdcmSeqEntry.cxx +++ b/src/gdcmSeqEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSeqEntry.cxx,v $ Language: C++ - Date: $Date: 2005/11/07 09:46:36 $ - Version: $Revision: 1.62 $ + Date: $Date: 2005/11/29 12:48:47 $ + 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 @@ -230,10 +230,37 @@ void SeqEntry::SetDelimitationItem(DocEntry *e) } } +/** + * \brief Copies all the attributes from an other DocEntry + * @param doc entry to copy from + * @remarks The contained SQItems a not copied, only referenced + */ +void SeqEntry::Copy(DocEntry *doc) +{ + // Delete previous SQ items + ClearSQItem(); + + DocEntry::Copy(doc); + SeqEntry *entry = dynamic_cast(doc); + if ( entry ) + { + DelimitorMode = entry->DelimitorMode; + SQDepthLevel = entry->SQDepthLevel; + + SeqTerm = entry->SeqTerm; + if(SeqTerm) + SeqTerm->Register(); + Items = entry->Items; + for(ItSQItem = Items.begin();ItSQItem != Items.end(); ++ItSQItem) + { + (*ItSQItem)->Register(); + } + } +} + //----------------------------------------------------------------------------- // Protected - //----------------------------------------------------------------------------- // Private diff --git a/src/gdcmSeqEntry.h b/src/gdcmSeqEntry.h index 0d1aef53..e26eddd0 100644 --- a/src/gdcmSeqEntry.h +++ b/src/gdcmSeqEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSeqEntry.h,v $ Language: C++ - Date: $Date: 2005/11/21 09:46:27 $ - Version: $Revision: 1.38 $ + Date: $Date: 2005/11/29 12:48:47 $ + 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 @@ -60,18 +60,17 @@ public: /// Sets the delimitor mode void SetDelimitorMode(bool dm) { DelimitorMode = dm; } - - void SetDelimitationItem(DocEntry *e); - /// Gets the Sequence Delimitation Item - DocEntry *GetDelimitationItem() { return SeqTerm;} + DocEntry *GetDelimitationItem() { return SeqTerm;} /// Gets the depth level int GetDepthLevel() const { return SQDepthLevel; } /// Sets the depth level of a Sequence Entry embedded in a SeQuence void SetDepthLevel(int depth) { SQDepthLevel = depth; } + virtual void Copy(DocEntry *doc); + protected: private: