X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestCopyDicom.cxx;h=62e1a727e9a1a68e0c51a0520786bcdf13132076;hb=4dd42f8153a4d5ea8d2524b3c6670e80232f73b4;hp=e0478850e864cf7251975eb8829e4c6a696fff2c;hpb=41ff2e7dce0238097d516c0b10c78008202672d8;p=gdcm.git diff --git a/Testing/TestCopyDicom.cxx b/Testing/TestCopyDicom.cxx index e0478850..62e1a727 100644 --- a/Testing/TestCopyDicom.cxx +++ b/Testing/TestCopyDicom.cxx @@ -9,6 +9,8 @@ #ifndef _WIN32 #include //for access, unlink +#else +#include //for _access on Win32 #endif // return true if the file exists @@ -67,7 +69,10 @@ int TestCopyDicom(int , char* []) gdcmFile *original = new gdcmFile( filename ); gdcmFile *copy = new gdcmFile( output ); - TagDocEntryHT & Ht = original->GetHeader()->GetEntry(); + TagDocEntryHT & Ht = original->GetHeader()->GetEntry(); + + size_t dataSize = original->GetImageDataSize(); + uint8_t* imageData = original->GetImageData(); //First of all copy the header field by field @@ -75,57 +80,28 @@ int TestCopyDicom(int , char* []) // It was commented out by Mathieu, that was a *good* idea // (the user does NOT have to know the way we implemented the Header !) // Waiting for a 'clean' solution, I keep the method ...JPRx - - TagNameHT & nameHt = original->GetHeader()->GetPubDict()->GetEntriesByName(); - (void)nameHt; //not used ? - //gdcmValEntry* v; - //gdcmBinEntry* b; gdcmDocEntry* d; for (TagDocEntryHT::iterator tag = Ht.begin(); tag != Ht.end(); ++tag) { d = tag->second; - if ( gdcmBinEntry* b = dynamic_cast(d) ) - { - // for private elements, the gdcmDictEntry is unknown - // and it's VR is unpredictable ... - // ( In *this* case ReplaceOrCreateByNumber - // should have a knowledge of the virtual dictionary - // gdcmDictSet::VirtualEntry ) - // ReplaceOrCreateByNumber may now receive the VR of the source Entry - // as a extra parameter - // - //if ( d->GetGroup()%2 == 1) // Skip private Entries - // continue; - - // TODO :write ReplaceOrCreateByNumber with VR, - // for BinEntries as well! - + { copy->GetHeader()->ReplaceOrCreateByNumber( - b->GetVoidArea(), + b->GetBinArea(), b->GetLength(), b->GetGroup(), - b->GetElement() ); - } - else if ( gdcmValEntry* v = dynamic_cast(d) ) - { - if ( d->GetGroup()%2 != 1) - { - copy->GetHeader()->ReplaceOrCreateByNumber( - v->GetValue(), - v->GetGroup(), - v->GetElement() ); - } - else - { - copy->GetHeader()->ReplaceOrCreateByNumber( + b->GetElement(), + b->GetVR() ); + } + else if ( gdcmValEntry* v = dynamic_cast(d) ) + { + copy->GetHeader()->ReplaceOrCreateByNumber( v->GetValue(), v->GetGroup(), v->GetElement(), v->GetVR() ); - } } else { @@ -137,9 +113,6 @@ int TestCopyDicom(int , char* []) } } - size_t dataSize = original->GetImageDataSize(); - void *imageData = original->GetImageData(); - copy->SetImageData(imageData, dataSize); original->GetHeader()->SetImageDataSize(dataSize);