X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestCopyDicom.cxx;h=9220962c4098437541ccb0531f9a88793e72c36e;hb=ccd312d24ac6ea6536d7bbea5c9c96a57fe66385;hp=c64f88c8e2d8a3dadf39ae8ebef4f41611afe6d7;hpb=c094e185dd6404df031524ccae8e1b51e3b84871;p=gdcm.git diff --git a/Testing/TestCopyDicom.cxx b/Testing/TestCopyDicom.cxx index c64f88c8..9220962c 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/21 11:40:54 $ - Version: $Revision: 1.33 $ + Date: $Date: 2005/02/09 15:31:15 $ + 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 @@ -23,41 +23,12 @@ //Generated file: #include "gdcmDataImages.h" -#ifndef _WIN32 -#include //for access, unlink -#else -#include //for _access on Win32 -#endif - // return true if the file exists -bool FileExists(const char* filename) -{ -#ifdef _MSC_VER -# define access _access -#endif -#ifndef R_OK -# define R_OK 04 -#endif - if ( access(filename, R_OK) != 0 ) - { - return false; - } - else - { - return true; - } -} - -bool RemoveFile(const char* source) -{ -#ifdef _MSC_VER -#define _unlink unlink -#endif - return unlink(source) != 0 ? false : true; -} +bool FileExists(const char *filename); +bool RemoveFile(const char *source); -int CopyDicom(std::string const & filename, - std::string const & output ) +int CopyDicom(std::string const &filename, + std::string const &output ) { std::cout << " Testing: " << filename << std::endl; if( FileExists( output.c_str() ) ) @@ -74,32 +45,24 @@ int CopyDicom(std::string const & filename, 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..."; - gdcm::DocEntry* d=originalH->GetFirstEntry(); + gdcm::DocEntry *d=originalH->GetFirstEntry(); while(d) { - if ( gdcm::BinEntry* b = dynamic_cast(d) ) + 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) ) + 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 { @@ -113,10 +76,10 @@ int CopyDicom(std::string const & filename, gdcm::FileHelper *copy = new gdcm::FileHelper( copyH ); size_t dataSize = original->GetImageDataSize(); - uint8_t* imageData = original->GetImageData(); + 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: @@ -157,7 +120,7 @@ int CopyDicom(std::string const & filename, //////////////// Step 5: std::cout << "5..."; size_t dataSizeWritten = copy->GetImageDataSize(); - uint8_t* imageDataWritten = copy->GetImageData(); + uint8_t *imageDataWritten = copy->GetImageData(); if (dataSize != dataSizeWritten) { @@ -196,7 +159,7 @@ int CopyDicom(std::string const & filename, // Here we load a gdcmFile and then try to create from scratch a copy of it, // copying field by field the dicom image -int TestCopyDicom(int argc, char* argv[]) +int TestCopyDicom(int argc, char *argv[]) { if ( argc == 3 ) { @@ -228,7 +191,7 @@ int TestCopyDicom(int argc, char* argv[]) << "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;