X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestCopyDicom.cxx;h=70284c3a36aaa2be2a27d049c7b94184cd0591a5;hb=bac2910466f502dec4c1842527aa81a8f83f04b8;hp=74075fe7a2e6a11c52fd640e4fd3b31e2dc9668b;hpb=d7637fa58050f4cc346b5356a960e03e58e99dd3;p=gdcm.git diff --git a/Testing/TestCopyDicom.cxx b/Testing/TestCopyDicom.cxx index 74075fe7..70284c3a 100644 --- a/Testing/TestCopyDicom.cxx +++ b/Testing/TestCopyDicom.cxx @@ -1,3 +1,20 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: TestCopyDicom.cxx,v $ + Language: C++ + Date: $Date: 2004/11/16 04:28:20 $ + Version: $Revision: 1.16 $ + + 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 "gdcmHeader.h" #include "gdcmFile.h" #include "gdcmDocument.h" @@ -9,6 +26,8 @@ #ifndef _WIN32 #include //for access, unlink +#else +#include //for _access on Win32 #endif // return true if the file exists @@ -64,10 +83,13 @@ int TestCopyDicom(int , char* []) } } - gdcmFile *original = new gdcmFile( filename ); - gdcmFile *copy = new gdcmFile( output ); + gdcm::File *original = new gdcm::File( filename ); + gdcm::File *copy = new gdcm::File( output ); - TagDocEntryHT & Ht = original->GetHeader()->GetEntry(); + const gdcm::TagDocEntryHT & Ht = original->GetHeader()->GetTagHT(); + + size_t dataSize = original->GetImageDataSize(); + uint8_t* imageData = original->GetImageData(); //First of all copy the header field by field @@ -76,41 +98,38 @@ int TestCopyDicom(int , char* []) // (the user does NOT have to know the way we implemented the Header !) // Waiting for a 'clean' solution, I keep the method ...JPRx - gdcmDocEntry* d; + gdcm::DocEntry* d; - for (TagDocEntryHT::iterator tag = Ht.begin(); tag != Ht.end(); ++tag) + for (gdcm::TagDocEntryHT::const_iterator tag = Ht.begin(); tag != Ht.end(); ++tag) { d = tag->second; - if ( gdcmBinEntry* b = dynamic_cast(d) ) + if ( gdcm::BinEntry* b = dynamic_cast(d) ) { copy->GetHeader()->ReplaceOrCreateByNumber( - b->GetVoidArea(), + b->GetBinArea(), b->GetLength(), b->GetGroup(), b->GetElement(), b->GetVR() ); - } - else if ( gdcmValEntry* v = dynamic_cast(d) ) - { - copy->GetHeader()->ReplaceOrCreateByNumber( + } + else if ( gdcm::ValEntry* v = dynamic_cast(d) ) + { + copy->GetHeader()->ReplaceOrCreateByNumber( v->GetValue(), v->GetGroup(), v->GetElement(), v->GetVR() ); - } - else - { + } + else + { // We skip pb of SQ recursive exploration //std::cout << "Skipped Sequence " // << "------------- " << d->GetVR() << " "<< std::hex // << d->GetGroup() << " " << d->GetElement() // << std::endl; - } + } } - size_t dataSize = original->GetImageDataSize(); - void *imageData = original->GetImageData(); - copy->SetImageData(imageData, dataSize); original->GetHeader()->SetImageDataSize(dataSize); @@ -119,7 +138,7 @@ int TestCopyDicom(int , char* []) delete original; delete copy; - copy = new gdcmFile( output ); + copy = new gdcm::File( output ); //Is the file written still gdcm parsable ? if ( !copy->GetHeader()->IsReadable() )