From: regrain Date: Tue, 30 Nov 2004 14:17:51 +0000 (+0000) Subject: * src/gdcmFile.[h|cxx] : bug fix for ACR-LIBIDO files when writting the file X-Git-Tag: Version1.0.bp~562 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=abac16617f1453f5db19618ccb45e821efa867b6;p=gdcm.git * src/gdcmFile.[h|cxx] : bug fix for ACR-LIBIDO files when writting the file * Test/TestAllReadCompareDicom.cxx, TestReadWriteReadCompare.cxx : add tests on the image size X, Y, Z -- BeNours --- diff --git a/ChangeLog b/ChangeLog index aff435cc..5b20d42a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-11-30 Benoit Regrain + * src/gdcmFile.[h|cxx] : bug fix for ACR-LIBIDO files when writting the file + * Test/TestAllReadCompareDicom.cxx, TestReadWriteReadCompare.cxx : add + tests on the image size X, Y, Z + 2004-11-26 Benoit Regrain * Remove some useless methods in gdcm::Document, gdcm::Header and gdcm::File * Rename gdcmHeaderHelper.[h|cxx] to gdcmSerieHeader.[h|cxx] to be coherent diff --git a/Testing/TestAllReadCompareDicom.cxx b/Testing/TestAllReadCompareDicom.cxx index 4a461f2c..e341b645 100644 --- a/Testing/TestAllReadCompareDicom.cxx +++ b/Testing/TestAllReadCompareDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestAllReadCompareDicom.cxx,v $ Language: C++ - Date: $Date: 2004/11/25 10:24:33 $ - Version: $Revision: 1.19 $ + Date: $Date: 2004/11/30 14:17:52 $ + Version: $Revision: 1.20 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -81,6 +81,25 @@ int InternalTest(std::string const & filename, int referenceDataSize = reference->GetImageDataSize(); uint8_t* referenceImageData = reference->GetImageData(); + // Test the image size + if (tested->GetHeader()->GetXSize() != reference->GetHeader()->GetXSize() || + tested->GetHeader()->GetYSize() != reference->GetHeader()->GetYSize() || + tested->GetHeader()->GetZSize() != reference->GetHeader()->GetZSize()) + { + std::cout << "Failed" << std::endl + << " Size differs: " + << "X: " << tested->GetHeader()->GetXSize() << " # " + << reference->GetHeader()->GetXSize() << " | " + << "Y: " << tested->GetHeader()->GetYSize() << " # " + << reference->GetHeader()->GetYSize() << " | " + << "Z: " << tested->GetHeader()->GetZSize() << " # " + << reference->GetHeader()->GetZSize() << std::endl; + delete reference; + delete tested; + return 1; + } + + // Test the data size if (testedDataSize != referenceDataSize) { std::cout << " Failed" << std::endl @@ -92,6 +111,7 @@ int InternalTest(std::string const & filename, return 1; } + // Test the data content if (int res = memcmp(testedImageData, referenceImageData, testedDataSize) != 0 ) { diff --git a/Testing/TestReadWriteReadCompare.cxx b/Testing/TestReadWriteReadCompare.cxx index b5359ba8..cc48edb7 100644 --- a/Testing/TestReadWriteReadCompare.cxx +++ b/Testing/TestReadWriteReadCompare.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestReadWriteReadCompare.cxx,v $ Language: C++ - Date: $Date: 2004/11/25 10:24:34 $ - Version: $Revision: 1.16 $ + Date: $Date: 2004/11/30 14:17:52 $ + 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 @@ -87,7 +87,26 @@ int CompareInternal(std::string const & filename, std::string const & output) uint8_t* imageDataWritten = reread->GetImageData(); //////////////// Step 4: + // Test the image size + if (header->GetXSize() != reread->GetHeader()->GetXSize() || + header->GetYSize() != reread->GetHeader()->GetYSize() || + header->GetZSize() != reread->GetHeader()->GetZSize()) + { + std::cout << "Failed" << std::endl + << " X Size differs: " + << "X: " << header->GetXSize() << " # " + << reread->GetHeader()->GetXSize() << " | " + << "Y: " << header->GetYSize() << " # " + << reread->GetHeader()->GetYSize() << " | " + << "Z: " << header->GetZSize() << " # " + << reread->GetHeader()->GetZSize() << std::endl; + delete header; + delete file; + delete reread; + return 1; + } + // Test the data size if (dataSize != dataSizeWritten) { std::cout << "Failed" << std::endl @@ -99,6 +118,7 @@ int CompareInternal(std::string const & filename, std::string const & output) return 1; } + // Test the data's content if (int res = memcmp(imageData, imageDataWritten, dataSize) !=0) { (void)res; diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index ca361e54..035e25c3 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2004/11/26 10:55:04 $ - Version: $Revision: 1.166 $ + Date: $Date: 2004/11/30 14:17:52 $ + Version: $Revision: 1.167 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -406,14 +406,21 @@ bool File::WriteBase (std::string const & fileName, FileType type) SetWriteFileTypeToExplicitVR(); break; case ACR: - SetWriteFileTypeToACR(); - break; case ACR_LIBIDO: - SetWriteFileTypeToACRLibido(); + SetWriteFileTypeToACR(); break; default: SetWriteFileTypeToExplicitVR(); } + + if( type == ACR_LIBIDO ) + { + SetWriteToLibido(); + } + else + { + SetWriteToNoLibido(); + } switch(WriteMode) { @@ -461,6 +468,7 @@ bool File::WriteBase (std::string const & fileName, FileType type) RestoreWrite(); RestoreWriteFileType(); + RestoreWriteOfLibido(); return check; } @@ -672,11 +680,6 @@ void File::SetWriteFileTypeToACR() Archive->Push(0x0002,0x0010); } -void File::SetWriteFileTypeToACRLibido() -{ - SetWriteFileTypeToACR(); -} - void File::SetWriteFileTypeToExplicitVR() { std::string ts = Util::DicomString( @@ -725,12 +728,33 @@ void File::SetWriteToLibido() Archive->Push(newRow); Archive->Push(newCol); } + + ValEntry *libidoCode = CopyValEntry(0x0008,0x0010); + libidoCode->SetValue("ACRNEMA_LIBIDO_1.1"); + libidoCode->SetLength(10); + Archive->Push(libidoCode); +} + +void File::SetWriteToNoLibido() +{ + ValEntry *recCode = dynamic_cast(HeaderInternal->GetDocEntryByNumber(0x0008,0x0010)); + if( recCode ) + { + if( recCode->GetValue() == "ACRNEMA_LIBIDO_1.1" ) + { + ValEntry *libidoCode = CopyValEntry(0x0008,0x0010); + libidoCode->SetValue(""); + libidoCode->SetLength(0); + Archive->Push(libidoCode); + } + } } -void File::RestoreWriteFromLibido() +void File::RestoreWriteOfLibido() { Archive->Restore(0x0028,0x0010); Archive->Restore(0x0028,0x0011); + Archive->Restore(0x0008,0x0010); } ValEntry* File::CopyValEntry(uint16_t group,uint16_t element) diff --git a/src/gdcmFile.h b/src/gdcmFile.h index 7637b7bd..53062b89 100644 --- a/src/gdcmFile.h +++ b/src/gdcmFile.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.h,v $ Language: C++ - Date: $Date: 2004/11/26 10:55:04 $ - Version: $Revision: 1.78 $ + Date: $Date: 2004/11/30 14:17:52 $ + 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 @@ -111,13 +111,13 @@ protected: void RestoreWrite(); void SetWriteFileTypeToACR(); - void SetWriteFileTypeToACRLibido(); void SetWriteFileTypeToExplicitVR(); void SetWriteFileTypeToImplicitVR(); void RestoreWriteFileType(); void SetWriteToLibido(); - void RestoreWriteFromLibido(); + void SetWriteToNoLibido(); + void RestoreWriteOfLibido(); ValEntry* CopyValEntry(uint16_t group,uint16_t element); BinEntry* CopyBinEntry(uint16_t group,uint16_t element);