X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestDicomDir.cxx;h=c778078eb4872378c0a22d7a1a4e52e8ca1dbb8f;hb=323dba69fa639a71f1559c8aee8209afc8731bb4;hp=db226de843f79dd1322825962e3428c7c7ddf3e9;hpb=4a07b1470f68d316f570fef1f07b9f9c77e90ee1;p=gdcm.git diff --git a/Testing/TestDicomDir.cxx b/Testing/TestDicomDir.cxx index db226de8..c778078e 100644 --- a/Testing/TestDicomDir.cxx +++ b/Testing/TestDicomDir.cxx @@ -1,59 +1,122 @@ -#include -#include "gdcm.h" -#include "gdcmHeaderEntry.h" +/*========================================================================= + + Program: gdcm + Module: $RCSfile: TestDicomDir.cxx,v $ + Language: C++ + Date: $Date: 2005/01/17 11:01:26 $ + Version: $Revision: 1.27 $ + + 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 "gdcmDocEntry.h" #include "gdcmDicomDir.h" +#include "gdcmDicomDirPatient.h" +#include "gdcmDicomDirStudy.h" +#include "gdcmDicomDirSerie.h" +#include "gdcmDicomDirImage.h" +#include "gdcmTS.h" -#include -#ifdef GDCM_NO_ANSI_STRING_STREAM -# include -# define ostringstream ostrstream -# else -# include -#endif -#include #include +#include -#define ostringstream ostrstream -//extern "C" - -using namespace std; - -int main(int argc, char* argv[]) +int TestDicomDir(int argc, char* argv[]) { - gdcmDicomDir *e1; - ListTag::iterator deb , fin; - ListPatient::iterator itPatient; - ListStudy::iterator itStudy; - ListSerie::iterator itSerie; - ListImage::iterator itImage; - TSKey v; + gdcm::DicomDir *e1; + + gdcm::DicomDirPatient *pa; + gdcm::DicomDirStudy *st; + gdcm::DicomDirSerie *se; + gdcm::DicomDirImage *im; + + gdcm::TSKey v; std::string file; if (argc > 1) file = argv[1]; - else - file = "../gdcmData/DICOMDIR"; - - e1 = new gdcmDicomDir(file.c_str()); - if (argc > 2) { - int level = atoi(argv[2]); - e1->SetPrintLevel(level); - } + else + { + file += GDCM_DATA_ROOT; + file += "/DICOMDIR"; + } - if(e1->GetPatients().begin() == e1->GetPatients().end() ) + e1 = new gdcm::DicomDir(file); + if (argc > 2) { - std::cout<<"Empty list"<SetPrintLevel(level); } -// DICOM DIR - cout << std::endl << std::endl - << " = Contenu Complet du DICOMDIR ==========================================" - << std::endl<< std::endl; + // Test if the DicomDir is readable + if( !e1->IsReadable() ) + { + std::cout<<" DicomDir '"<GetNextEntry() ) + { + std::cout<<" DicomDir '"<InitTraversal(); + pa = e1->GetNextEntry(); + while ( pa ) { // on degouline la liste de PATIENT + std::cout << pa->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name + pa->InitTraversal(); + st = pa->GetNextEntry(); + while ( st ) { // on degouline les STUDY de ce patient + std::cout << "--- "<< st->GetEntry(0x0008, 0x1030) << std::endl; // Study Description + std::cout << " Stud.ID:[" << st->GetEntry(0x0020, 0x0010); // Study ID + st->InitTraversal(); + se = st->GetNextEntry(); + while ( se ) { // on degouline les SERIES de cette study + std::cout << "--- --- "<< se->GetEntry(0x0008, 0x103e) << std::endl; // Serie Description + std::cout << " Ser.nb:[" << se->GetEntry(0x0020, 0x0011); // Series number + std::cout << "] Mod.:[" << se->GetEntry(0x0008, 0x0060) << "]"; // Modality + se->InitTraversal(); + im = se->GetNextEntry(); + while ( im ) { // on degouline les Images de cette serie + std::cout << "--- --- --- "<< im->GetEntry(0x0004, 0x1500) << std::endl; // File name + im = se->GetNextEntry(); + } + se = st->GetNextEntry(); + } + st = pa->GetNextEntry(); + } + pa = e1->GetNextEntry(); + } + + + std::cout << std::endl << std::endl + << " = DICOMDIR full content ====================================" + << std::endl<< std::endl; e1->Print(); std::cout<