X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=Testing%2FTestCopyDicom.cxx;h=698828b8cf20a010ca6abaf501af361d52f8e0a5;hb=1e66f7398c38a3d71b480e0297e29636ea6e1c1b;hp=9220962c4098437541ccb0531f9a88793e72c36e;hpb=efd3ea11eb9d6da5f3034f5e46649d250b90c75a;p=gdcm.git diff --git a/Testing/TestCopyDicom.cxx b/Testing/TestCopyDicom.cxx index 9220962c..698828b8 100644 --- a/Testing/TestCopyDicom.cxx +++ b/Testing/TestCopyDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestCopyDicom.cxx,v $ Language: C++ - Date: $Date: 2005/02/09 15:31:15 $ - Version: $Revision: 1.40 $ + Date: $Date: 2007/10/30 09:13:45 $ + Version: $Revision: 1.44 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -17,8 +17,7 @@ =========================================================================*/ #include "gdcmFile.h" #include "gdcmFileHelper.h" -#include "gdcmValEntry.h" -#include "gdcmBinEntry.h" +#include "gdcmDataEntry.h" //Generated file: #include "gdcmDataImages.h" @@ -42,27 +41,24 @@ int CopyDicom(std::string const &filename, //////////////// Step 1: std::cout << " 1..."; - gdcm::File *originalH = new gdcm::File( filename ); - gdcm::File *copyH = new gdcm::File( ); + GDCM_NAME_SPACE::File *originalH = GDCM_NAME_SPACE::File::New(); + GDCM_NAME_SPACE::File *copyH = GDCM_NAME_SPACE::File::New(); + + originalH->SetFileName( filename ); + originalH->Load( ); //First of all copy the file, field by field //////////////// Step 2: std::cout << "2..."; - gdcm::DocEntry *d=originalH->GetFirstEntry(); + GDCM_NAME_SPACE::DocEntry *d=originalH->GetFirstEntry(); while(d) { - if ( gdcm::BinEntry *b = dynamic_cast(d) ) - { - copyH->InsertBinEntry( b->GetBinArea(),b->GetLength(), - b->GetGroup(),b->GetElement(), - b->GetVR() ); - } - else if ( gdcm::ValEntry *v = dynamic_cast(d) ) - { - copyH->InsertValEntry( v->GetValue(), - v->GetGroup(),v->GetElement(), - v->GetVR() ); + if ( GDCM_NAME_SPACE::DataEntry *de = dynamic_cast(d) ) + { + copyH->InsertEntryBinArea( de->GetBinArea(),de->GetLength(), + de->GetGroup(),de->GetElement(), + de->GetVR() ); } else { @@ -71,15 +67,17 @@ int CopyDicom(std::string const &filename, d=originalH->GetNextEntry(); } - - gdcm::FileHelper *original = new gdcm::FileHelper( originalH ); - gdcm::FileHelper *copy = new gdcm::FileHelper( copyH ); + GDCM_NAME_SPACE::FileHelper *original = GDCM_NAME_SPACE::FileHelper::New(originalH); + GDCM_NAME_SPACE::FileHelper *copy = GDCM_NAME_SPACE::FileHelper::New(copyH); size_t dataSize = original->GetImageDataSize(); uint8_t *imageData = original->GetImageData(); // Useless to set the image data, because it's already made when - // copying the corresponding BinEntry that contains the pixel data + // copying the corresponding DataEntry that contains the pixel data + + // --> FIXME : Why do we let the following line? + // to avoid compile time warnings? copy->SetImageData(imageData, dataSize); //////////////// Step 3: @@ -90,29 +88,29 @@ int CopyDicom(std::string const &filename, std::cout << " Failed" << std::endl << " " << output << " not written" << std::endl; - delete original; - delete copy; - delete originalH; - delete copyH; + original->Delete(); + copy->Delete(); + originalH->Delete(); + copyH->Delete(); return 1; } - delete copy; - delete copyH; + copy->Delete(); + copyH->Delete(); //////////////// Step 4: std::cout << "4..."; - copy = new gdcm::FileHelper( output ); - +// copy = new GDCM_NAME_SPACE::FileHelper( output ); + copy = GDCM_NAME_SPACE::FileHelper::New(output); // ??? //Is the file written still gdcm parsable ? if ( !copy->GetFile()->IsReadable() ) { std::cout << " Failed" << std::endl << " " << output << " not readable" << std::endl; - delete original; - delete originalH; + original->Delete(); + originalH->Delete(); return 1; } @@ -128,9 +126,9 @@ int CopyDicom(std::string const &filename, << " Pixel areas lengths differ: " << dataSize << " # " << dataSizeWritten << std::endl; - delete original; - delete copy; - delete originalH; + original->Delete(); + copy->Delete(); + originalH->Delete(); return 1; } @@ -141,17 +139,17 @@ int CopyDicom(std::string const &filename, std::cout << " Failed" << std::endl << " Pixel differ (as expanded in memory)." << std::endl; - delete original; - delete copy; - delete originalH; + original->Delete(); + copy->Delete(); + originalH->Delete(); return 1; } std::cout << "OK." << std::endl ; - delete original; - delete copy; - delete originalH; + original->Delete(); + copy->Delete(); + originalH->Delete(); return 0; }