X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestDicomDir.cxx;h=59158930c1f70909ce28d69d67c1869a8831a00b;hb=58255d78f79b6243b8bf0aee742801dc1dd655a9;hp=037227e2e25221d7c4e4f3dad14310ef740974d8;hpb=3ab013fad66fae47553b1b882edf0e0f00858f15;p=gdcm.git diff --git a/Testing/TestDicomDir.cxx b/Testing/TestDicomDir.cxx index 037227e2..59158930 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/01/29 11:56:53 $ - Version: $Revision: 1.34 $ + Date: $Date: 2005/07/08 13:39:57 $ + Version: $Revision: 1.39 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -39,9 +39,10 @@ int CompareSQItem(gdcm::SQItem *pa1, gdcm::SQItem *pa2 ) { // locate the corresponding element in 'source' file e1 = pa1->GetDocEntry( e2->GetGroup(),e2->GetElement() ); + + // an element doesn't exist in origin file if (!e1) { - // an element doesn't exist in source file std::cout << "DicomDir element " << std::hex << e2->GetGroup() << "," <GetElement() << std::endl; return 1; @@ -51,9 +52,21 @@ int CompareSQItem(gdcm::SQItem *pa1, gdcm::SQItem *pa2 ) !dynamic_cast(e2) ) continue; + // a value is read as GDCM_UNFOUND + if ( ((gdcm::ValEntry*)e1)->GetValue() == gdcm::GDCM_UNFOUND ) + { + std::cout << "for gdcm source DicomDir : element (" << std::hex + << e1->GetGroup() << "," <GetElement() + << ") has values [" << gdcm::GDCM_UNFOUND << "]" + << std::endl; + return 1; + } + + // values differ in source file and destination file if ( ((gdcm::ValEntry*)e1)->GetValue() != ((gdcm::ValEntry*)e2)->GetValue() ) { + // serious trouble : values differ in source and destination file std::cout << "for gdcm DicomDir element (" << std::hex << e2->GetGroup() << "," <GetElement() @@ -67,14 +80,14 @@ int CompareSQItem(gdcm::SQItem *pa1, gdcm::SQItem *pa2 ) return 0; } -int TestDicomDir(int argc, char* argv[]) +int TestDicomDir(int argc, char *argv[]) { gdcm::DicomDir *dicomdir; - gdcm::DicomDirPatient * pa1; - gdcm::DicomDirStudy *st1; - gdcm::DicomDirSerie *se1; - gdcm::DicomDirImage *im1; + gdcm::DicomDirPatient *pa1; + gdcm::DicomDirStudy *st1; + gdcm::DicomDirSerie *se1; + gdcm::DicomDirImage *im1; gdcm::TSKey v; @@ -87,7 +100,9 @@ int TestDicomDir(int argc, char* argv[]) file += "/DICOMDIR"; } - dicomdir = new gdcm::DicomDir(file); + dicomdir = new gdcm::DicomDir( ); + dicomdir->SetFileName(file); + dicomdir->Load( ); if (argc > 2) { int level = atoi(argv[2]); @@ -172,9 +187,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("NewDICOMDIR"); - - if (!d2) + gdcm::DicomDir *d2 = new gdcm::DicomDir( ); + d2->SetFileName("NewDICOMDIR"); + d2->Load( ); + if (!d2->IsReadable( )) { std::cout << std::endl << std::endl << "Read NewDicomDir from disc failed ========================" @@ -186,9 +202,9 @@ int TestDicomDir(int argc, char* argv[]) << std::endl<< std::endl; gdcm::DicomDirPatient *pa2; - gdcm::DicomDirStudy *st2; - gdcm::DicomDirSerie *se2; - gdcm::DicomDirImage *im2; + gdcm::DicomDirStudy *st2; + gdcm::DicomDirSerie *se2; + gdcm::DicomDirImage *im2; pa1 = dicomdir->GetFirstPatient(); pa2 = d2->GetFirstPatient(); @@ -196,16 +212,20 @@ int TestDicomDir(int argc, char* argv[]) if (!d2) { std::cout << "NewDICOMDIR contains no Patient ?!?" << std::endl; + delete dicomdir; + delete d2; return 1; } - gdcm::DocEntry *e1; - gdcm::DocEntry *e2; while ( pa1 && pa2 ) { // we process all the PATIENT of this DICOMDIR if ( CompareSQItem(pa2,pa1) == 1 ) - return 1; + { + delete dicomdir; + delete d2; + return 1; + } // just to allow human reader to be sure ... std::cout << pa2->GetEntryValue(0x0010, 0x0010) @@ -217,7 +237,11 @@ int TestDicomDir(int argc, char* argv[]) while ( st1 && st2 ) { if ( CompareSQItem(st2,st1) == 1 ) - return 1; + { + delete dicomdir; + delete d2; + return 1; + } // just to allow human reader to be sure ... std::cout << "--- "<< st2->GetEntryValue(0x0008, 0x1030); @@ -242,7 +266,11 @@ int TestDicomDir(int argc, char* argv[]) while ( im1 && im2 ) // we process all the IMAGE of this serie { if ( CompareSQItem(im2,im1) == 1 ) + { + delete dicomdir; + delete d2; return 1; + } im1 = se1->GetNextImage(); im2 = se2->GetNextImage(); @@ -259,6 +287,7 @@ int TestDicomDir(int argc, char* argv[]) std::cout << std::flush; delete dicomdir; + delete d2; return 0; }