X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FTestChangeHeader.cxx;h=bbc4d6fae8a5a54857d1457e30275cebe8e5b752;hb=225ed916326ada32c2944a3b7e937fe56859538a;hp=c0982e6d9095da93e149c005ef283f41a15b978a;hpb=eebb428694422967cab7559646df139d790afded;p=gdcm.git diff --git a/Example/TestChangeHeader.cxx b/Example/TestChangeHeader.cxx index c0982e6d..bbc4d6fa 100644 --- a/Example/TestChangeHeader.cxx +++ b/Example/TestChangeHeader.cxx @@ -1,38 +1,57 @@ -#include "gdcmHeader.h" +/*========================================================================= + + Program: gdcm + Module: $RCSfile: TestChangeHeader.cxx,v $ + Language: C++ + Date: $Date: 2005/07/08 12:02:02 $ + Version: $Revision: 1.15 $ + + 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 "gdcmFile.h" +#include "gdcmFileHelper.h" // 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; + argv[0] << " fileNameForHeader fileNameForData" << + std::endl; return 1; } - gdcmHeader *h1 = new gdcmHeader( argv[1] ); - gdcmFile *f1 = new gdcmFile( h1 ); - gdcmFile *f2 = new gdcmFile( argv[2] ); + gdcm::File *h1 = new gdcm::File( ); + h1->SetFileName ( argv[1] ); + h1->Load( ); + gdcm::FileHelper *f1 = new gdcm::FileHelper( h1 ); + + gdcm::File *h2 = new gdcm::File( ); + h2->SetFileName ( argv[2] ); + h2->Load( ); + gdcm::FileHelper *f2 = new gdcm::FileHelper( h2 ); + // 0018 1310 US ACQ Acquisition Matrix - gdcmDictEntry *dictEntry = - f2->GetHeader()->GetPubDict()->GetDictEntryByName( "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->GetHeader()->GetEntryByNumber(0x0018, 0x1310); - // Or, strictly equivalent (a little bit longer at run-time !): - std::string matrix = f2->GetHeader()->GetEntryByName("Acquisition Matrix"); + std::string matrix = f2->GetFile()->GetEntryValue(0x0018, 0x1310); if(matrix != "gdcm::Unfound") { std::cerr << "Aquisition Matrix:" << matrix << std::endl; - f1->GetHeader()->ReplaceOrCreateByNumber( matrix, 0x0018, 0x1310); - - //f1->GetHeader()->ReplaceOrCreateByNumber( matrix, dictEntry->GetGroup(), - // dictEntry->GetElement()); + f1->GetFile()->InsertValEntry( matrix, 0x0018, 0x1310); } f1->GetImageData(); @@ -40,8 +59,11 @@ std::endl; h1->Print(); f1->WriteDcmExplVR("output-matrix.dcm"); + + delete f1; + delete f2; + delete h1; + delete h2; return 0; } - -