X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=Example%2FTestChangeHeader.cxx;h=c6c19cd3d13c3a7cb1bde55058df93eb58ff52aa;hb=247c979db58d7bfd1d65029de05f4142a534c4c8;hp=c2d4b4d992cb772f39ddaf180c83e4f89f7ec2d5;hpb=c094e185dd6404df031524ccae8e1b51e3b84871;p=gdcm.git diff --git a/Example/TestChangeHeader.cxx b/Example/TestChangeHeader.cxx index c2d4b4d9..c6c19cd3 100644 --- a/Example/TestChangeHeader.cxx +++ b/Example/TestChangeHeader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestChangeHeader.cxx,v $ Language: C++ - Date: $Date: 2005/01/21 11:40:52 $ - Version: $Revision: 1.8 $ + Date: $Date: 2005/10/25 14:52:27 $ + Version: $Revision: 1.18 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -21,39 +21,50 @@ // This examples read two images (could be the same). Try to modify // Acquisition Matrix and then write the image again -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { - if (argc < 3) - { - std::cerr << "usage :" << std::endl << - argv[0] << " nomFichierPourEntete nomFichierPourDonnées" << - std::endl; - return 1; - } + if (argc < 3) + { + std::cerr << "usage :" << std::endl << + argv[0] << " fileNameForHeader fileNameForData" << + std::endl; + return 1; + } - gdcm::File *h1 = new gdcm::File( argv[1] ); - gdcm::FileHelper *f1 = new gdcm::FileHelper( h1 ); - gdcm::FileHelper *f2 = new gdcm::FileHelper( argv[2] ); + gdcm::File *h1 = gdcm::File::New( ); + h1->SetFileName ( argv[1] ); + h1->Load( ); + gdcm::FileHelper *f1 = gdcm::FileHelper::New( h1 ); + + gdcm::File *h2 = gdcm::File::New( ); + h2->SetFileName ( argv[2] ); + h2->Load( ); + gdcm::FileHelper *f2 = gdcm::FileHelper::New( h2 ); + - // 0018 1310 US ACQ Acquisition Matrix - gdcm::DictEntry *dictEntry = - f2->GetFile()->GetPubDict()->GetDictEntry( 0x0018, 1310 ); - std::cerr << std::hex << dictEntry->GetGroup() << "," << dictEntry->GetElement() << std::endl; + // 0018 1310 US ACQ Acquisition Matrix + gdcm::DictEntry *dictEntry = + f2->GetFile()->GetPubDict()->GetEntry( 0x0018, 1310 ); + std::cerr << std::hex << dictEntry->GetGroup() << "," + << dictEntry->GetElement() << std::endl; - std::string matrix = f2->GetFile()->GetEntry(0x0018, 0x1310); - if(matrix != "gdcm::Unfound") - { - std::cerr << "Aquisition Matrix:" << matrix << std::endl; - f1->GetFile()->ReplaceOrCreate( matrix, 0x0018, 0x1310); - } + std::string matrix = f2->GetFile()->GetEntryString(0x0018, 0x1310); + if(matrix != "gdcm::Unfound") + { + std::cerr << "Aquisition Matrix:" << matrix << std::endl; + f1->GetFile()->InsertEntryString( matrix, 0x0018, 0x1310); + } - f1->GetImageData(); - - h1->Print(); - - f1->WriteDcmExplVR("output-matrix.dcm"); + f1->GetImageData(); + + h1->Print(); + + f1->WriteDcmExplVR("output-matrix.dcm"); + + f1->Delete(); + f2->Delete(); + h1->Delete(); + h2->Delete(); - return 0; + return 0; } - -