X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestDicomDir.cxx;h=b2dad187df6046de3137692e082cf2f47bef288d;hb=4552d4ee18f3234af4e037e77abf0622c2702004;hp=af76b111b4e2f01c161b31e52a636e46fdddaf48;hpb=4289ddedc713b40cb0af61e19e788bc63f0e5af0;p=gdcm.git diff --git a/Testing/TestDicomDir.cxx b/Testing/TestDicomDir.cxx index af76b111..b2dad187 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/08/31 09:29:11 $ - Version: $Revision: 1.40 $ + Date: $Date: 2008/09/15 15:49:21 $ + Version: $Revision: 1.47 $ 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,12 +27,14 @@ #include #include -// check *all* the dicom elements (gdcm::DocEntry) -// of this gdcm::DicomDirObject -int CompareSQItem(gdcm::SQItem *pa1, gdcm::SQItem *pa2 ) +#include + +// check *all* the dicom elements (GDCM_NAME_SPACE::DocEntry) +// of this GDCM_NAME_SPACE::DicomDirObject +int CompareSQItem(GDCM_NAME_SPACE::SQItem *pa1, GDCM_NAME_SPACE::SQItem *pa2 ) { - gdcm::DocEntry *e1; - gdcm::DocEntry *e2; + GDCM_NAME_SPACE::DocEntry *e1; + GDCM_NAME_SPACE::DocEntry *e2; e2 = pa2->GetFirstEntry(); while (!e2) @@ -48,31 +50,34 @@ 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_NAME_SPACE::DataEntry *)e1)->GetString() == GDCM_NAME_SPACE::GDCM_UNFOUND ) { std::cout << "for gdcm source DicomDir : element (" << std::hex << e1->GetGroup() << "," <GetElement() - << ") has values [" << gdcm::GDCM_UNFOUND << "]" + << ") has values [" << GDCM_NAME_SPACE::GDCM_UNFOUND << "]" << std::endl; return 1; } // values differ in source file and destination file - if ( ((gdcm::ValEntry*)e1)->GetValue() != - ((gdcm::ValEntry*)e2)->GetValue() ) + if ( ((GDCM_NAME_SPACE::DataEntry *)e1)->GetString() != + ((GDCM_NAME_SPACE::DataEntry *)e2)->GetString() ) { + /// \todo : check the value *written on disc*, not the value converted as a std::string + /// (this comparison doesn't make the difference between Ox(ff) and "255" ...) + // 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_NAME_SPACE::DataEntry *)e1)->GetString() << "] != [" + << ((GDCM_NAME_SPACE::DataEntry *)e2)->GetString() << "]" << std::endl; return 1; } @@ -82,14 +87,14 @@ int CompareSQItem(gdcm::SQItem *pa1, gdcm::SQItem *pa2 ) int TestDicomDir(int argc, char *argv[]) { - gdcm::DicomDir *dicomdir; + GDCM_NAME_SPACE::DicomDir *dicomdir; - gdcm::DicomDirPatient *pa1; - gdcm::DicomDirStudy *st1; - gdcm::DicomDirSerie *se1; - gdcm::DicomDirImage *im1; + GDCM_NAME_SPACE::DicomDirPatient *pa1; + GDCM_NAME_SPACE::DicomDirStudy *st1; + GDCM_NAME_SPACE::DicomDirSerie *se1; + GDCM_NAME_SPACE::DicomDirImage *im1; - gdcm::TSKey v; + GDCM_NAME_SPACE::TSKey v; std::string file; if (argc > 1) @@ -100,23 +105,26 @@ int TestDicomDir(int argc, char *argv[]) file += "/DICOMDIR"; } - dicomdir = new gdcm::DicomDir( ); + std::cout << "DicomDir we're going to deal with : ["<< file << "]" + << std::endl; + + dicomdir = GDCM_NAME_SPACE::DicomDir::New(); dicomdir->SetFileName(file); - dicomdir->Load( ); + dicomdir->Load(); if (argc > 2) { int level = atoi(argv[2]); dicomdir->SetPrintLevel(level); } - // Test if the DicomDir is readable + // Test if the DICOMDIR file is readable if( !dicomdir->IsReadable() ) { std::cout<<" DicomDir '"<Delete(); return 1; } else @@ -125,14 +133,14 @@ int TestDicomDir(int argc, char *argv[]) <<"' is readable"<GetFirstPatient() ) { std::cout<<" DicomDir '"<Delete(); return 1; } @@ -143,27 +151,27 @@ 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 + { // we process all the PATIENT of this GDCM_NAME_SPACE::DicomDir + 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(); @@ -173,12 +181,22 @@ int TestDicomDir(int argc, char *argv[]) pa1 = dicomdir->GetNextPatient(); } +/* +// this one is *really* too much verbose! + std::cout << std::endl << std::endl << " = DICOMDIR full content ====================================" << std::endl<< std::endl; - // dicomdir->Print(); - + dicomdir->Print(); + std::cout << std::endl << std::endl + << " = end of DICOMDIR full content ====================================" + << std::endl<< std::endl; +*/ // ------------------------- second stage --------------------------- + + + GDCM_NAME_SPACE::Debug::DebugOn(); + // Write on disc what we read dicomdir->Write("NewDICOMDIR"); @@ -187,10 +205,10 @@ int TestDicomDir(int argc, char *argv[]) << "NewDICOMDIR written on disc =================================" << std::endl<< std::endl; // Read what we wrote - gdcm::DicomDir *d2 = new gdcm::DicomDir( ); + GDCM_NAME_SPACE::DicomDir *d2 = GDCM_NAME_SPACE::DicomDir::New(); d2->SetFileName("NewDICOMDIR"); - d2->Load( ); - if (!d2->IsReadable( )) + d2->Load(); + if (!d2->IsReadable()) { std::cout << std::endl << std::endl << "Read NewDicomDir from disc failed ========================" @@ -201,10 +219,10 @@ int TestDicomDir(int argc, char *argv[]) << "NewDICOMDIR successfully read from disc =================================" << std::endl<< std::endl; - gdcm::DicomDirPatient *pa2; - gdcm::DicomDirStudy *st2; - gdcm::DicomDirSerie *se2; - gdcm::DicomDirImage *im2; + GDCM_NAME_SPACE::DicomDirPatient *pa2; + GDCM_NAME_SPACE::DicomDirStudy *st2; + GDCM_NAME_SPACE::DicomDirSerie *se2; + GDCM_NAME_SPACE::DicomDirImage *im2; pa1 = dicomdir->GetFirstPatient(); pa2 = d2->GetFirstPatient(); @@ -212,8 +230,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; } @@ -222,13 +240,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(); @@ -238,16 +256,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(); @@ -256,10 +274,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(); @@ -267,8 +286,8 @@ int TestDicomDir(int argc, char *argv[]) { if ( CompareSQItem(im2,im1) == 1 ) { - delete dicomdir; - delete d2; + dicomdir->Delete(); + d2->Delete(); return 1; } @@ -286,8 +305,8 @@ int TestDicomDir(int argc, char *argv[]) } std::cout << std::flush; - delete dicomdir; - delete d2; + dicomdir->Delete(); + d2->Delete(); return 0; }