X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FTestCopyDicom.cxx;h=f7139f88615de71ca356d631ef773183736a5f2a;hb=a8569ff195c346229a951d7c6925d93fb5b7dea5;hp=f1b4978f92ce9128c458da4fb0f9e8dde0623dff;hpb=5b4ab2e7e473455c7b5c4b2c21164df15451e19f;p=gdcm.git diff --git a/Example/TestCopyDicom.cxx b/Example/TestCopyDicom.cxx index f1b4978f..f7139f88 100644 --- a/Example/TestCopyDicom.cxx +++ b/Example/TestCopyDicom.cxx @@ -3,6 +3,10 @@ #include "gdcmDocument.h" #include "gdcmValEntry.h" +#ifndef _WIN32 +#include +#endif + // return true if the file exists bool FileExists(const char* filename) { @@ -54,7 +58,7 @@ int main(int argc, char* argv[]) gdcmFile *original = new gdcmFile( argv[1] ); std::cout << "--- Original ----------------------" << std::endl; - original->GetHeader()->Print(); + //original->GetHeader()->Print(); gdcmFile *copy = new gdcmFile( argv[2] ); @@ -68,14 +72,28 @@ int main(int argc, char* argv[]) for (TagDocEntryHT::iterator tag = Ht.begin(); tag != Ht.end(); ++tag) { - //std::cerr << "Reading: " << tag->second->GetVR() << std::endl; - tag->second->Print(); std::cout << std::endl; - if (tag->second->GetVR() == "SQ") //to skip pb of SQ recursive exploration continue; + + std::string value = ((gdcmValEntry*)(tag->second))->GetValue(); + //According to JPR I should also skip those: +// if (tag->second->GetVR() == "unkn") //to skip pb of SQ recursive exploration +// continue; + +// if( value.find( "gdcm::NotLoaded" ) == 0 ) +// continue; + + if( value.find( "gdcm::Loaded" ) == 0 ) + continue; + + //std::cerr << "Reading: " << tag->second->GetVR() << std::endl; + //tag->second->Print(); std::cout << std::endl; + + std::cerr << "Reading: " << value << std::endl; + // Well ... Should have dynamic cast here copy->GetHeader()->ReplaceOrCreateByNumber( - ((gdcmValEntry*)(tag->second))->GetValue(), + value, tag->second->GetGroup(), tag->second->GetElement() ); @@ -85,11 +103,12 @@ int main(int argc, char* argv[]) size_t dataSize = original->GetImageDataSize(); void *imageData = original->GetImageData(); + //copy->GetImageData(); copy->SetImageData(imageData, dataSize); std::cout << "--- Copy ----------------------" << std::endl; std::cout <GetHeader()->Print(); + //copy->GetHeader()->Print(); std::cout << "--- ---- ----------------------" << std::endl; copy->WriteDcmExplVR( argv[2] );