X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FTestCopyDicom.cxx;h=bc1313cf552297f83edb101e3800fc312da2ace9;hb=fefb49a4c17b2c2134cf23edf1ecf230c5e309d1;hp=bfc92b8a0279605f9e68a4332c56080e1f66e70b;hpb=9bc08a72beb8acf114c306262e06386e75f7b967;p=gdcm.git diff --git a/Example/TestCopyDicom.cxx b/Example/TestCopyDicom.cxx index bfc92b8a..bc1313cf 100644 --- a/Example/TestCopyDicom.cxx +++ b/Example/TestCopyDicom.cxx @@ -1,3 +1,20 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: TestCopyDicom.cxx,v $ + Language: C++ + Date: $Date: 2005/01/14 11:28:28 $ + 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" @@ -6,6 +23,8 @@ #ifndef _WIN32 #include //for access, unlink +#else +#include //for _access #endif // return true if the file exists @@ -61,17 +80,17 @@ int main(int argc, char* argv[]) return 1; } } - gdcmFile *original = new gdcmFile( filename ); + gdcm::File *original = new gdcm::File( filename ); std::cout << "--- Original ----------------------" << std::endl; //original->GetHeader()->Print(); - gdcmFile *copy = new gdcmFile( output ); - - TagDocEntryHT & Ht = original->GetHeader()->GetEntry(); + gdcm::File *copy = new gdcm::File( output ); size_t dataSize = original->GetImageDataSize(); - void *imageData = original->GetImageData(); + uint8_t* imageData = original->GetImageData(); + (void)imageData; + (void)dataSize; //First of all copy the header field by field @@ -80,24 +99,22 @@ int main(int argc, char* argv[]) // (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; - - for (TagDocEntryHT::iterator tag = Ht.begin(); tag != Ht.end(); ++tag) + original->GetHeader()->InitTraversal(); + gdcm::DocEntry* d=original->GetHeader()->GetNextEntry(); + while(d) { - d = tag->second; - d->Print(); std::cout << std::endl; - if ( gdcmBinEntry* b = dynamic_cast(d) ) + if ( gdcm::BinEntry* b = dynamic_cast(d) ) { - copy->GetHeader()->ReplaceOrCreateByNumber( - b->GetVoidArea(), + copy->GetHeader()->ReplaceOrCreate( + b->GetBinArea(), b->GetLength(), b->GetGroup(), b->GetElement(), b->GetVR() ); } - else if ( gdcmValEntry* v = dynamic_cast(d) ) + else if ( gdcm::ValEntry* v = dynamic_cast(d) ) { - copy->GetHeader()->ReplaceOrCreateByNumber( + copy->GetHeader()->ReplaceOrCreate( v->GetValue(), v->GetGroup(), v->GetElement(), @@ -111,14 +128,12 @@ int main(int argc, char* argv[]) // << d->GetGroup() << " " << d->GetElement() // << std::endl; } - } - - - + d=original->GetHeader()->GetNextEntry(); + } //copy->GetImageData(); - copy->SetImageData(imageData, dataSize); + //copy->SetImageData(imageData, dataSize); std::cout << "--- Copy ----------------------" << std::endl; std::cout <