From: jpr Date: Wed, 26 Oct 2005 07:18:37 +0000 (+0000) Subject: Remove useless Example/TestCopyDicom X-Git-Tag: OpenJPEG.Version1.2~157 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=852f9b2a0a83c7c9f5d051536ac6803e37c24a0b;p=gdcm.git Remove useless Example/TestCopyDicom --- diff --git a/Example/TestCopyDicom.cxx b/Example/TestCopyDicom.cxx deleted file mode 100644 index 77be5b59..00000000 --- a/Example/TestCopyDicom.cxx +++ /dev/null @@ -1,139 +0,0 @@ -/*========================================================================= - - Program: gdcm - Module: $RCSfile: TestCopyDicom.cxx,v $ - Language: C++ - Date: $Date: 2005/10/25 14:52:27 $ - Version: $Revision: 1.32 $ - - Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de - l'Image). All rights reserved. See Doc/License.txt or - http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ -#include "gdcmFile.h" -#include "gdcmFileHelper.h" -#include "gdcmDocument.h" -#include "gdcmDataEntry.h" - -#ifndef _WIN32 -#include //for access, unlink -#else -#include //for _access -#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; -} - -// Here we load a gdcmFile and then try to create from scratch a copy of it, -// copying field by field the dicom image - -int main(int argc, char *argv[]) -{ - if (argc < 3) - { - std::cerr << "Usage :" << std::endl << - argv[0] << " input_dicom output_dicom" << std::endl; - return 1; - } - -// don't modify identation in order to let this source xdiffable with ../Test - std::string filename = argv[1]; - std::string output = argv[2]; - - if( FileExists( output.c_str() ) ) - { - std::cerr << "Don't try to cheat, I am removing the file anyway" - << std::endl; - if( !RemoveFile( output.c_str() ) ) - { - std::cerr << "Ouch, the file exist, but I cannot remove it" - << std::endl; - return 1; - } - } - gdcm::File *fileOr = gdcm::File::New(); - fileOr->SetFileName( filename ); - fileOr->Load(); - gdcm::FileHelper *original = gdcm::FileHelper::New( fileOr ); - - std::cout << "--- Original ----------------------" << std::endl; - - gdcm::FileHelper *copy = gdcm::FileHelper::New( ); - copy->SetFileName( output ); - copy->Load(); - - uint8_t *imageData; - - imageData = original->GetImageData(); // VERY important : - // brings pixels into memory ! - - std::cout << imageData << std::endl; // to avoid warning ? - - //First of all copy the header field by field - - gdcm::DocEntry *d = original->GetFile()->GetFirstEntry(); - while(d) - { - if ( gdcm::DataEntry *de = dynamic_cast(d) ) - { - copy->GetFile()->InsertEntryBinArea( de->GetBinArea(),de->GetLength(), - de->GetGroup(),de->GetElement(), - de->GetVR() ); - } - else - { - // We skip pb of SQ recursive exploration - std::cout << "Skipped Sequence " - << "------------- " << d->GetVR() << " "<< std::hex - << d->GetGroup() << "," << d->GetElement() - << std::endl; - } - - d=original->GetFile()->GetNextEntry(); - } - - std::cout << "--- Copy ----------------------" << std::endl; - std::cout <GetFile()->Print(); - std::cout << "--- ---- ----------------------" << std::endl; - - copy->WriteDcmExplVR( output ); - - fileOr->Delete(); // File - original->Delete(); // FileHelper - copy->Delete(); // FileHelper - return 0; -} - - -