X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FMakeDicomDir.cxx;h=2fc7051e17dea5693e1f34db09c39649bce0e4df;hb=81b83abc1f19db44870ea35907c5f6a102ba5c64;hp=5723db7de90643b7adcdf408533312f5e000a87b;hpb=4d992954520d43c6f2fb555b7cd721574978c23a;p=gdcm.git diff --git a/Example/MakeDicomDir.cxx b/Example/MakeDicomDir.cxx index 5723db7d..2fc7051e 100644 --- a/Example/MakeDicomDir.cxx +++ b/Example/MakeDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: MakeDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/07/07 17:31:53 $ - Version: $Revision: 1.8 $ + Date: $Date: 2006/01/26 15:52:42 $ + Version: $Revision: 1.20 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -20,42 +20,35 @@ #include "gdcmDicomDirPatient.h" #include "gdcmDirList.h" #include "gdcmDebug.h" - #include "gdcmArgMgr.h" #include -// --- -void StartMethod(void *toto) { - (void)toto; - std::cout<<"Start parsing"<ArgMgrGetString("dirName",(char *)"."); + const char *dirName; + dirName = am->ArgMgrGetString("dirName","."); - int loadMode = 0x00000000; + const char *name; + name = am->ArgMgrGetString("name","DICOMDIR"); + + int loadMode = gdcm::LD_ALL; if ( am->ArgMgrDefined("noshadowseq") ) - loadMode |= NO_SHADOWSEQ; + loadMode |= gdcm::LD_NOSHADOWSEQ; else { if ( am->ArgMgrDefined("noshadow") ) - loadMode |= NO_SHADOW; + loadMode |= gdcm::LD_NOSHADOW; if ( am->ArgMgrDefined("noseq") ) - loadMode |= NO_SEQ; + loadMode |= gdcm::LD_NOSEQ; } if (am->ArgMgrDefined("debug")) gdcm::Debug::DebugOn(); - + + int check = am->ArgMgrDefined("check"); + // if unused Param we give up if ( am->ArgMgrPrintUnusedLabels() ) { @@ -92,7 +90,7 @@ int main(int argc, char *argv[]) delete am; return 0; } - + delete am; // we don't need Argument Manager any longer // ----- Begin Processing ----- @@ -101,56 +99,66 @@ int main(int argc, char *argv[]) // we ask for Directory parsing - dcmdir = new gdcm::DicomDir( ); - dcmdir->SetParseDir(true); - - dcmdir->SetStartMethod(StartMethod, (void *) NULL); - dcmdir->SetEndMethod(EndMethod); + dcmdir = gdcm::DicomDir::New( ); dcmdir->SetLoadMode(loadMode); - dcmdir->SetFileName(dirName); - + dcmdir->SetDirectoryName(dirName); + //dcmdir->SetParseDir(true); dcmdir->Load(); + if ( gdcm::Debug::GetDebugFlag() ) + std::cout << "======================= End Parsing Directory" << std::endl; + // ----- Check the result if ( !dcmdir->GetFirstPatient() ) { std::cout << "makeDicomDir: no patient found. Exiting." << std::endl; - delete dcmdir; + dcmdir->Delete(); return 1; } // ----- Create the corresponding DicomDir - dcmdir->WriteDicomDir("NewDICOMDIR"); - delete dcmdir; - - // Read from disc the just written DicomDir - gdcm::DicomDir *newDicomDir = new gdcm::DicomDir("NewDICOMDIR"); - if( !newDicomDir->IsReadable() ) + dcmdir->Write(name); + dcmdir->Delete(); + + if (check) { - std::cout<<" Written DicomDir 'NewDICOMDIR'" - <<" is not readable"<GetFirstPatient() ) - { - std::cout<<" Written DicomDir 'NewDICOMDIR'" - <<" has no patient"<SetFileName( name ); + newDicomDir->Load(); + if ( gdcm::Debug::GetDebugFlag() ) + std::cout << "======================= End Parsing DICOMDIR" + << std::endl; + if( !newDicomDir->IsReadable() ) + { + std::cout<<" Written DicomDir [" << name << "] " + <<" is not readable"<Delete(); + return 1; + } + + if( !newDicomDir->GetFirstPatient() ) + { + std::cout <<" Written DicomDir [" << name << "] " + <<" has no patient"<Delete(); + return(1); + } + std::cout<Delete(); } - - std::cout<