X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestDicomDir.cxx;h=9d99963730695ba518b87656f2e5b80af9da201e;hb=ed8f0888f5c1f2bfb64d5759a5dc9590858b31f2;hp=6039f22a4b041cf6fbdb9b41c57b117a2637248e;hpb=96cc99e8e141ceaf026104699c3273ad5fc88a1f;p=gdcm.git diff --git a/Testing/TestDicomDir.cxx b/Testing/TestDicomDir.cxx index 6039f22a..9d999637 100644 --- a/Testing/TestDicomDir.cxx +++ b/Testing/TestDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/02/03 10:00:06 $ - Version: $Revision: 1.38 $ + Date: $Date: 2006/05/31 16:51:41 $ + Version: $Revision: 1.43 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -16,7 +16,7 @@ =========================================================================*/ #include "gdcmDocEntry.h" -#include "gdcmValEntry.h" +#include "gdcmDataEntry.h" #include "gdcmDicomDir.h" #include "gdcmDicomDirPatient.h" #include "gdcmDicomDirStudy.h" @@ -27,6 +27,8 @@ #include #include +#include + // check *all* the dicom elements (gdcm::DocEntry) // of this gdcm::DicomDirObject int CompareSQItem(gdcm::SQItem *pa1, gdcm::SQItem *pa2 ) @@ -48,12 +50,12 @@ int CompareSQItem(gdcm::SQItem *pa1, gdcm::SQItem *pa2 ) return 1; } // skip SeqEntries (I don't want to deal with 'recursion pbs' here) - if ( !dynamic_cast(e1) || - !dynamic_cast(e2) ) + if ( !dynamic_cast(e1) || + !dynamic_cast(e2) ) continue; // a value is read as GDCM_UNFOUND - if ( ((gdcm::ValEntry*)e1)->GetValue() == gdcm::GDCM_UNFOUND ) + if ( ((gdcm::DataEntry *)e1)->GetString() == gdcm::GDCM_UNFOUND ) { std::cout << "for gdcm source DicomDir : element (" << std::hex << e1->GetGroup() << "," <GetElement() @@ -63,16 +65,16 @@ int CompareSQItem(gdcm::SQItem *pa1, gdcm::SQItem *pa2 ) } // values differ in source file and destination file - if ( ((gdcm::ValEntry*)e1)->GetValue() != - ((gdcm::ValEntry*)e2)->GetValue() ) + if ( ((gdcm::DataEntry *)e1)->GetString() != + ((gdcm::DataEntry *)e2)->GetString() ) { // serious trouble : values differ in source and destination file std::cout << "for gdcm DicomDir element (" << std::hex << e2->GetGroup() << "," <GetElement() << ") values differ [" - << ((gdcm::ValEntry*)e1)->GetValue() << "] != [" - << ((gdcm::ValEntry*)e2)->GetValue() << "]" + << ((gdcm::DataEntry *)e1)->GetString() << "] != [" + << ((gdcm::DataEntry *)e2)->GetString() << "]" << std::endl; return 1; } @@ -100,7 +102,9 @@ int TestDicomDir(int argc, char *argv[]) file += "/DICOMDIR"; } - dicomdir = new gdcm::DicomDir(file); + dicomdir = gdcm::DicomDir::New(); + dicomdir->SetFileName(file); + dicomdir->Load(); if (argc > 2) { int level = atoi(argv[2]); @@ -114,7 +118,7 @@ int TestDicomDir(int argc, char *argv[]) <<"' is not readable"<Delete(); return 1; } else @@ -130,7 +134,7 @@ int TestDicomDir(int argc, char *argv[]) <<" has no patient"<Delete(); return 1; } @@ -142,26 +146,26 @@ int TestDicomDir(int argc, char *argv[]) pa1 = dicomdir->GetFirstPatient(); while ( pa1 ) { // we process all the PATIENT of this DICOMDIR - std::cout << pa1->GetEntryValue(0x0010, 0x0010) << std::endl; // Patient's Name + std::cout << pa1->GetEntryString(0x0010, 0x0010) << std::endl; // Patient's Name st1 = pa1->GetFirstStudy(); while ( st1 ) { // we process all the STUDY of this patient - std::cout << "--- "<< st1->GetEntryValue(0x0008, 0x1030) // Study Description + std::cout << "--- "<< st1->GetEntryString(0x0008, 0x1030) // Study Description << std::endl; - std::cout << " Stud.ID:[" << st1->GetEntryValue(0x0020, 0x0010) // Study ID + std::cout << " Stud.ID:[" << st1->GetEntryString(0x0020, 0x0010) // Study ID << "]"; se1 = st1->GetFirstSerie(); while ( se1 ) { // we process all the SERIES of this study - std::cout << "--- --- "<< se1->GetEntryValue(0x0008, 0x103e) << std::endl; // Serie Description - std::cout << " Ser.nb:[" << se1->GetEntryValue(0x0020, 0x0011); // Series number - std::cout << "] Mod.:[" << se1->GetEntryValue(0x0008, 0x0060) << "]"; // Modality + std::cout << "--- --- "<< se1->GetEntryString(0x0008, 0x103e) << std::endl; // Serie Description + std::cout << " Ser.nb:[" << se1->GetEntryString(0x0020, 0x0011); // Series number + std::cout << "] Mod.:[" << se1->GetEntryString(0x0008, 0x0060) << "]"; // Modality im1 = se1->GetFirstImage(); while ( im1 ) { // we process all the IMAGE of this serie - std::cout << "--- --- --- "<< im1->GetEntryValue(0x0004, 0x1500) << std::endl; // File name + std::cout << "--- --- --- "<< im1->GetEntryString(0x0004, 0x1500) << std::endl; // File name im1 = se1->GetNextImage(); } se1 = st1->GetNextSerie(); @@ -179,14 +183,16 @@ int TestDicomDir(int argc, char *argv[]) // ------------------------- second stage --------------------------- // Write on disc what we read - dicomdir->WriteDicomDir("NewDICOMDIR"); + dicomdir->Write("NewDICOMDIR"); std::cout << std::endl << std::endl << "NewDICOMDIR written on disc =================================" << std::endl<< std::endl; // Read what we wrote - gdcm::DicomDir *d2 = new gdcm::DicomDir("NewDICOMDIR"); - if (!d2) + gdcm::DicomDir *d2 = gdcm::DicomDir::New(); + d2->SetFileName("NewDICOMDIR"); + d2->Load(); + if (!d2->IsReadable()) { std::cout << std::endl << std::endl << "Read NewDicomDir from disc failed ========================" @@ -208,8 +214,8 @@ int TestDicomDir(int argc, char *argv[]) if (!d2) { std::cout << "NewDICOMDIR contains no Patient ?!?" << std::endl; - delete dicomdir; - delete d2; + dicomdir->Delete(); + d2->Delete(); return 1; } @@ -218,13 +224,13 @@ int TestDicomDir(int argc, char *argv[]) if ( CompareSQItem(pa2,pa1) == 1 ) { - delete dicomdir; - delete d2; + dicomdir->Delete(); + d2->Delete(); return 1; } // just to allow human reader to be sure ... - std::cout << pa2->GetEntryValue(0x0010, 0x0010) + std::cout << pa2->GetEntryString(0x0010, 0x0010) << std::endl; // Patient's Name st1 = pa1->GetFirstStudy(); @@ -234,16 +240,16 @@ int TestDicomDir(int argc, char *argv[]) { if ( CompareSQItem(st2,st1) == 1 ) { - delete dicomdir; - delete d2; + dicomdir->Delete(); + d2->Delete(); return 1; } // just to allow human reader to be sure ... - std::cout << "--- "<< st2->GetEntryValue(0x0008, 0x1030); + std::cout << "--- "<< st2->GetEntryString(0x0008, 0x1030); // << std::endl; // Study Description std::cout << " Stud.ID:[" - << st2->GetEntryValue(0x0020, 0x0010) + << st2->GetEntryString(0x0020, 0x0010) << "]" << std::endl; // Study ID se1 = st1->GetFirstSerie(); @@ -252,10 +258,11 @@ int TestDicomDir(int argc, char *argv[]) while ( se1 && se2 ) { // we process all the SERIE of this study if ( CompareSQItem(se2,se1) == 1 ) - return 1; - std::cout << "--- --- " << se2->GetEntryValue(0x0008, 0x103e); // Serie Description - std::cout << " Ser.nb:["<< se2->GetEntryValue(0x0020, 0x0011); // Series number - std::cout << "] Mod.:[" << se2->GetEntryValue(0x0008, 0x0060) << "]" << std::endl; // Modality + return 1; + + std::cout << "--- --- " << se2->GetEntryString(0x0008, 0x103e); // Serie Description + std::cout << " Ser.nb:["<< se2->GetEntryString(0x0020, 0x0011); // Series number + std::cout << "] Mod.:[" << se2->GetEntryString(0x0008, 0x0060) << "]" << std::endl; // Modality im1 = se1->GetFirstImage(); im2 = se2->GetFirstImage(); @@ -263,8 +270,8 @@ int TestDicomDir(int argc, char *argv[]) { if ( CompareSQItem(im2,im1) == 1 ) { - delete dicomdir; - delete d2; + dicomdir->Delete(); + d2->Delete(); return 1; } @@ -282,8 +289,8 @@ int TestDicomDir(int argc, char *argv[]) } std::cout << std::flush; - delete dicomdir; - delete d2; + dicomdir->Delete(); + d2->Delete(); return 0; }