From b8ca604b2c1c17790f19ac61b63dfb5b550ac6c0 Mon Sep 17 00:00:00 2001 From: regrain Date: Wed, 17 Nov 2004 10:20:05 +0000 Subject: [PATCH] * src/gdcmDocument.cxx : now, when using the ReplaceOrCreateByNumber to set a BinEntry, the binArea is copied (like to set a ValEntry, the string is copied). * Test/TestCopyDicom.cxx, Example/TestCopyDicom.cxx : the image data isn't set because already copied when copying the BinEntry's of the header * Test/TestAllReadCompareDicom.cxx : remove warnings -- BeNours --- ChangeLog | 8 ++++++++ Example/TestCopyDicom.cxx | 6 +++--- Testing/TestAllReadCompareDicom.cxx | 6 ++++-- Testing/TestCopyDicom.cxx | 10 ++++++---- src/gdcmDocument.cxx | 23 ++++++++++++++++++++--- 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 85e4a7e9..3aab041b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-11-15 Benoit Regrain + * src/gdcmDocument.cxx : now, when using the ReplaceOrCreateByNumber to + set a BinEntry, the binArea is copied (like to set a ValEntry, the string + is copied). + * Test/TestCopyDicom.cxx, Example/TestCopyDicom.cxx : the image data isn't + set because already copied when copying the BinEntry's of the header + * Test/TestAllReadCompareDicom.cxx : remove warnings + 2004-11-15 Benoit Regrain * FIX : now, the DocEntries are all deleted in the gdcmElementSet. Two problems appear when doing it : diff --git a/Example/TestCopyDicom.cxx b/Example/TestCopyDicom.cxx index eda53d67..24400816 100644 --- a/Example/TestCopyDicom.cxx +++ b/Example/TestCopyDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestCopyDicom.cxx,v $ Language: C++ - Date: $Date: 2004/11/16 04:26:18 $ - Version: $Revision: 1.12 $ + Date: $Date: 2004/11/17 10:20:06 $ + Version: $Revision: 1.13 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -137,7 +137,7 @@ int main(int argc, char* argv[]) //copy->GetImageData(); - copy->SetImageData(imageData, dataSize); + //copy->SetImageData(imageData, dataSize); std::cout << "--- Copy ----------------------" << std::endl; std::cout <GetImageData(); // Kludge + (void)testedImageData; + tested->WriteDcmExplVR( referenceFileName ); std::cerr << " Creating reference baseline file :" << std::endl << " " << referenceFileName diff --git a/Testing/TestCopyDicom.cxx b/Testing/TestCopyDicom.cxx index 70284c3a..9706397c 100644 --- a/Testing/TestCopyDicom.cxx +++ b/Testing/TestCopyDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestCopyDicom.cxx,v $ Language: C++ - Date: $Date: 2004/11/16 04:28:20 $ - Version: $Revision: 1.16 $ + Date: $Date: 2004/11/17 10:20:06 $ + 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 @@ -104,7 +104,7 @@ int TestCopyDicom(int , char* []) { d = tag->second; if ( gdcm::BinEntry* b = dynamic_cast(d) ) - { + { copy->GetHeader()->ReplaceOrCreateByNumber( b->GetBinArea(), b->GetLength(), @@ -130,7 +130,9 @@ int TestCopyDicom(int , char* []) } } - copy->SetImageData(imageData, dataSize); + // Useless to set the image datas, because it's already made when + // copying the corresponding BinEntry that contains the pixel datas + //copy->SetImageData(imageData, dataSize); original->GetHeader()->SetImageDataSize(dataSize); copy->WriteDcmExplVR( output ); diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index a569ccac..854e6db2 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2004/11/17 03:20:05 $ - Version: $Revision: 1.132 $ + Date: $Date: 2004/11/17 10:20:07 $ + Version: $Revision: 1.133 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -619,6 +619,7 @@ ValEntry* Document::ReplaceOrCreateByNumber( /* * \brief Modifies the value of a given Header Entry (Dicom Element) * when it exists. Create it with the given value when unexistant. + * A copy of the binArea is made to be kept in the Document. * @param binArea (binary) value to be set * @param Group Group number of the Entry * @param Elem Element number of the Entry @@ -690,7 +691,23 @@ BinEntry* Document::ReplaceOrCreateByNumber( } } - SetEntryByNumber(binArea, lgth, group, elem); + uint8_t *tmpArea; + if (lgth>0 && binArea) + { + tmpArea = new uint8_t[lgth]; + memcpy(tmpArea,binArea,lgth); + } + else + { + tmpArea = 0; + } + if (!SetEntryByNumber(tmpArea, lgth, group, elem)) + { + if (tmpArea) + { + delete[] tmpArea; + } + } return binEntry; } -- 2.45.1