X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestCopyDicom.cxx;h=8c3ad7491b056a390eadeabee24ef9b5eec5e11e;hb=6c6608b98c9260180a08309c6049b9450658acad;hp=1d26baeff58071e192b0efd342e9bae7eab78c3e;hpb=8a69df0f4018beae8c78a35bef30590e318128e5;p=gdcm.git diff --git a/Testing/TestCopyDicom.cxx b/Testing/TestCopyDicom.cxx index 1d26baef..8c3ad749 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/01/19 08:58:33 $ - Version: $Revision: 1.31 $ + Date: $Date: 2005/01/26 16:43:10 $ + Version: $Revision: 1.37 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -15,8 +15,8 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#include "gdcmHeader.h" #include "gdcmFile.h" +#include "gdcmFileHelper.h" #include "gdcmValEntry.h" #include "gdcmBinEntry.h" @@ -71,13 +71,10 @@ int CopyDicom(std::string const & filename, //////////////// Step 1: std::cout << " 1..."; - gdcm::Header *originalH = new gdcm::Header( filename ); - gdcm::Header *copyH = new gdcm::Header( ); + gdcm::File *originalH = new gdcm::File( filename ); + gdcm::File *copyH = new gdcm::File( ); - //First of all copy the header field by field - - // Warning :Accessor gdcmElementSet::GetEntry() should not exist - // It was commented out by Mathieu, that was a *good* idea + //First of all copy the file, field by field //////////////// Step 2: std::cout << "2..."; @@ -86,20 +83,15 @@ int CopyDicom(std::string const & filename, { if ( gdcm::BinEntry* b = dynamic_cast(d) ) { - copyH->ReplaceOrCreate( - b->GetBinArea(), - b->GetLength(), - b->GetGroup(), - b->GetElement(), - b->GetVR() ); + copyH->InsertBinEntry( b->GetBinArea(),b->GetLength(), + b->GetGroup(),b->GetElement(), + b->GetVR() ); } else if ( gdcm::ValEntry* v = dynamic_cast(d) ) { - copyH->ReplaceOrCreate( - v->GetValue(), - v->GetGroup(), - v->GetElement(), - v->GetVR() ); + copyH->InsertValEntry( v->GetValue(), + v->GetGroup(),v->GetElement(), + v->GetVR() ); } else { @@ -109,14 +101,14 @@ int CopyDicom(std::string const & filename, d=originalH->GetNextEntry(); } - gdcm::File *original = new gdcm::File( originalH ); - gdcm::File *copy = new gdcm::File( copyH ); + gdcm::FileHelper *original = new gdcm::FileHelper( originalH ); + gdcm::FileHelper *copy = new gdcm::FileHelper( copyH ); size_t dataSize = original->GetImageDataSize(); uint8_t* imageData = original->GetImageData(); - // Useless to set the image datas, because it's already made when - // copying the corresponding BinEntry that contains the pixel datas + // Useless to set the image data, because it's already made when + // copying the corresponding BinEntry that contains the pixel data copy->SetImageData(imageData, dataSize); //////////////// Step 3: @@ -140,10 +132,10 @@ int CopyDicom(std::string const & filename, //////////////// Step 4: std::cout << "4..."; - copy = new gdcm::File( output ); + copy = new gdcm::FileHelper( output ); //Is the file written still gdcm parsable ? - if ( !copy->GetHeader()->IsReadable() ) + if ( !copy->GetFile()->IsReadable() ) { std::cout << " Failed" << std::endl << " " << output << " not readable" << std::endl; @@ -223,12 +215,12 @@ int TestCopyDicom(int argc, char* argv[]) << std::endl; std::cout << " apply the following to each filename.xxx: " << std::endl; - std::cout << " step 1: parse the image (as gdcmHeader) and call" + std::cout << " step 1: parse the image (as gdcmFile) and call" << " IsReadable(). After that, call GetImageData() and " << "GetImageDataSize() " << std::endl; std::cout << " step 2: create a copy of the readed file and the new" - << " pixel datas are set to the copy" + << " pixel data are set to the copy" << std::endl; std::cout << " step 3: write the copy of the image" << std::endl;