From 8f68ff1b50850c4b4890d15af2218e3ef12da4e2 Mon Sep 17 00:00:00 2001 From: jpr Date: Wed, 28 Apr 2004 16:24:58 +0000 Subject: [PATCH] * ENH add self defined param 'new' to PrintHeader to 'show' the SeQuence tree-like structure of a Dicom Header * FIX Test code cleaning --- Testing/TestBug.cxx | 23 ++++++------- Testing/TestChangeHeader.cxx | 66 ++++++++++++++++++------------------ Testing/TestDicomDir.cxx | 10 +++--- Testing/TestHash.cxx | 36 ++++++++++---------- 4 files changed, 66 insertions(+), 69 deletions(-) diff --git a/Testing/TestBug.cxx b/Testing/TestBug.cxx index b71e660e..4d3f22e1 100644 --- a/Testing/TestBug.cxx +++ b/Testing/TestBug.cxx @@ -3,20 +3,17 @@ int bug1(int argc, char* argv[]) { - gdcmHeader* e1; + gdcmHeader* e1; - if (argc > 1) - e1 = new gdcmHeader(argv[1]); - else - { - std::string filename = GDCM_DATA_ROOT; - filename += "/test.acr"; - e1 = new gdcmHeader( filename.c_str() ); - } - e1->PrintPubDict(); + if (argc > 1) + e1 = new gdcmHeader(argv[1]); + else + { + std::string filename = GDCM_DATA_ROOT; + filename += "/test.acr"; + e1 = new gdcmHeader( filename.c_str() ); + } + e1->PrintPubDict(); return 0; } - - - diff --git a/Testing/TestChangeHeader.cxx b/Testing/TestChangeHeader.cxx index a84d3b96..7ffbd7e1 100644 --- a/Testing/TestChangeHeader.cxx +++ b/Testing/TestChangeHeader.cxx @@ -10,38 +10,38 @@ int testChangeEntete(int argc, char* argv[]) { - std::string premier, deuxieme; - char resultat[200]; + std::string premier, deuxieme; + char resultat[200]; - gdcmFile *f1, *f2; + gdcmFile *f1, *f2; //gdcmHeader *e1, *e2; - void* imageData; - int dataSize; + void* imageData; + int dataSize; - if (argc < 3) { - std::cerr << "usage :" << std::endl << + if (argc < 3) { + std::cerr << "usage :" << std::endl << argv[0] << " nomFichierPourEntete nomFichierPourDonnées" << std::endl; - return 0; - } + return 0; + } - premier = argv[1]; - f1 = new gdcmFile(premier); + premier = argv[1]; + f1 = new gdcmFile(premier); - deuxieme = argv[2]; - f2 = new gdcmFile(deuxieme); + deuxieme = argv[2]; + f2 = new gdcmFile(deuxieme); //f1->PrintPubElVal(); // On suppose que les champs DICOM du 2ieme fichier existent *effectivement* - std::string nbFrames = f2->GetHeader()->GetEntryByNumber(0x0028, 0x0008); - if(nbFrames != "gdcm::Unfound") { - f1->GetHeader()->ReplaceOrCreateByNumber( nbFrames, 0x0028, 0x0008); - } + std::string nbFrames = f2->GetHeader()->GetEntryByNumber(0x0028, 0x0008); + if(nbFrames != "gdcm::Unfound") { + f1->GetHeader()->ReplaceOrCreateByNumber( nbFrames, 0x0028, 0x0008); + } - f1->GetHeader()->ReplaceOrCreateByNumber(f2->GetHeader()->GetEntryByNumber(0x0028, 0x0010), + f1->GetHeader()->ReplaceOrCreateByNumber(f2->GetHeader()->GetEntryByNumber(0x0028, 0x0010), 0x0028, 0x0010);// nbLig - f1->GetHeader()->ReplaceOrCreateByNumber( f2->GetHeader()->GetEntryByNumber(0x0028, 0x0011), + f1->GetHeader()->ReplaceOrCreateByNumber( f2->GetHeader()->GetEntryByNumber(0x0028, 0x0011), 0x0028, 0x0011);// nbCol @@ -52,28 +52,28 @@ int testChangeEntete(int argc, char* argv[]) { // et qui fasse le boulot. - dataSize = f2->GetImageDataSize(); - printf ("dataSize %d\n",dataSize); - imageData= f2->GetImageData(); + dataSize = f2->GetImageDataSize(); + printf ("dataSize %d\n",dataSize); + imageData= f2->GetImageData(); // TODO : ne devrait-on pas fusionner ces 2 fonctions ? - f1->SetImageData(imageData,dataSize); - f1->GetHeader()->SetImageDataSize(dataSize); + f1->SetImageData(imageData,dataSize); + f1->GetHeader()->SetImageDataSize(dataSize); - f1->GetHeader()->PrintEntry(); + f1->GetHeader()->PrintEntry(); - std::string s0 =f2->GetHeader()->GetEntryByNumber(0x7fe0, 0x0000); - std::string s10=f2->GetHeader()->GetEntryByNumber(0x7fe0, 0x0010); - printf("lgr 7fe0, 0000 %s\n",s0.c_str()); - printf("lgr 7fe0, 0010 %s\n",s10.c_str()); + std::string s0 =f2->GetHeader()->GetEntryByNumber(0x7fe0, 0x0000); + std::string s10=f2->GetHeader()->GetEntryByNumber(0x7fe0, 0x0010); + printf("lgr 7fe0, 0000 %s\n",s0.c_str()); + printf("lgr 7fe0, 0010 %s\n",s10.c_str()); - sprintf(resultat, "%s.vol", deuxieme.c_str()); - printf ("WriteDCM\n"); + sprintf(resultat, "%s.vol", deuxieme.c_str()); + printf ("WriteDCM\n"); //f1->WriteDcmExplVR("itk-gdcm-ex.dcm"); //f1->WriteDcmImplVR(resultat); - f1->WriteAcr(resultat); + f1->WriteAcr(resultat); - return 0; + return 0; } diff --git a/Testing/TestDicomDir.cxx b/Testing/TestDicomDir.cxx index 1cccb798..11f8aa6d 100644 --- a/Testing/TestDicomDir.cxx +++ b/Testing/TestDicomDir.cxx @@ -37,10 +37,10 @@ int testDicomDir(int argc, char* argv[]) } e1 = new gdcmDicomDir(file.c_str()); - if (argc > 2) { - int level = atoi(argv[2]); - e1->SetPrintLevel(level); - } + if (argc > 2) { + int level = atoi(argv[2]); + e1->SetPrintLevel(level); + } if(e1->GetDicomDirPatients().begin() == e1->GetDicomDirPatients().end() ) { @@ -48,7 +48,7 @@ int testDicomDir(int argc, char* argv[]) return(1); } -// Exemples exploitation de la structure +// Simple examples of structure exploitation // DON'T REMOVE neither the folowing code, nor the commented out lines /* diff --git a/Testing/TestHash.cxx b/Testing/TestHash.cxx index 230550ee..313df602 100644 --- a/Testing/TestHash.cxx +++ b/Testing/TestHash.cxx @@ -7,27 +7,27 @@ int hashtest( int, char * [] ) { typedef std::map dict; - dict tb1; - dict::iterator im = tb1.find("00380010"); - tb1["00100010"] = "Patient Name"; - tb1["7fe00010"] = "Pixel Data"; - tb1["50000010"] = "Number of points"; - tb1["00380010"] = "Admission ID"; + dict tb1; + dict::iterator im = tb1.find("00380010"); + tb1["00100010"] = "Patient Name"; + tb1["7fe00010"] = "Pixel Data"; + tb1["50000010"] = "Number of points"; + tb1["00380010"] = "Admission ID"; - std::cout << "Traversal of dictionary (note the proper ordering on key)." << std::endl; - for ( im = tb1.begin(); im != tb1.end(); ++im ) - std::cout << " \"" << im->first << "\" = " << im->second << std::endl; - std::cout << "End of dictionary." << std::endl; + std::cout << "Traversal of dictionary (note the proper ordering on key)." << std::endl; + for ( im = tb1.begin(); im != tb1.end(); ++im ) + std::cout << " \"" << im->first << "\" = " << im->second << std::endl; + std::cout << "End of dictionary." << std::endl; - std::cout << "Find request on key 00380010" << std::endl; - im = tb1.find("00380010"); - std::cout << " \"" << im->first << "\" = " << im->second << std::endl; + std::cout << "Find request on key 00380010" << std::endl; + im = tb1.find("00380010"); + std::cout << " \"" << im->first << "\" = " << im->second << std::endl; - int i = 0x0010; - std::cout.setf(std::ios::hex); - std::cout << i << std::endl; - std::cout.setf(std::ios::dec); - std::cout << i << std::endl; + int i = 0x0010; + std::cout.setf(std::ios::hex); + std::cout << i << std::endl; + std::cout.setf(std::ios::dec); + std::cout << i << std::endl; // Voir : //http://www.developer.com/net/cplus/article.php/10919_2119781_3 -- 2.45.1