X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FMakeDicomDir.cxx;h=6046ac506f4caf784c2deb1da2d8e290495cb4d6;hb=9fc41d585113e37d4d1d1d511e61d2e638096fb3;hp=86f7ec752127633f5b62972a5bdf55edd36e1b00;hpb=1d44a799e7860861ce969254d6403a0066ffd753;p=gdcm.git diff --git a/Example/MakeDicomDir.cxx b/Example/MakeDicomDir.cxx index 86f7ec75..6046ac50 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/11/28 17:09:22 $ - Version: $Revision: 1.17 $ + Date: $Date: 2007/09/28 14:09:20 $ + Version: $Revision: 1.25 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -22,6 +22,8 @@ #include "gdcmDebug.h" #include "gdcmArgMgr.h" +//#include // Linux Only + #include /** @@ -29,7 +31,7 @@ * orders the gdcm-readable found Files * according their Patient/Study/Serie/Image characteristics * makes the gdcmDicomDir - * and writes a file named NewDICOMDIR.. + * and writes a file named DICOMDIR. (user may choose an other name) */ int main(int argc, char *argv[]) @@ -37,19 +39,22 @@ int main(int argc, char *argv[]) START_USAGE(usage) " \n MakeDicomDir :\n ", " Explores recursively the given directory, makes the relevant DICOMDIR ", - " and writes it as 'NewDICOMDIR' ", + " and writes it as 'DICOMDIR' ", " ", " usage: MakeDicomDir dirname=rootDirectoryName ", - " [noshadowseq][noshadow][noseq] [debug] ", + " name=DICOMDIR file name ", + " [noshadowseq][noshadow][noseq] [debug] [check] ", " ", + " name : the default name for the generated dicomdir is 'DICOMDIR' ", " noshadowseq: user doesn't want to load Private Sequences ", " noshadow : user doesn't want to load Private groups (odd number) ", " noseq : user doesn't want to load Sequences ", - " debug : user wants to run the program in 'debug mode' ", + " debug : developper wants to run the program in 'debug mode' ", + " check : the dicomdir is checked as 'gdcm readable' ", FINISH_USAGE // ----- Initialize Arguments Manager ------ - gdcm::ArgMgr *am = new gdcm::ArgMgr(argc, argv); + GDCM_NAME_SPACE::ArgMgr *am = new GDCM_NAME_SPACE::ArgMgr(argc, argv); if (argc == 1 || am->ArgMgrDefined("usage")) { @@ -58,23 +63,28 @@ int main(int argc, char *argv[]) return 0; } - char *dirName; - dirName = am->ArgMgrGetString("dirName",(char *)"."); + const char *dirName; + dirName = am->ArgMgrGetString("dirName","."); - int loadMode = gdcm::LD_ALL; + const char *name; + name = am->ArgMgrGetString("name","DICOMDIR"); + + int loadMode = GDCM_NAME_SPACE::LD_ALL; if ( am->ArgMgrDefined("noshadowseq") ) - loadMode |= gdcm::LD_NOSHADOWSEQ; + loadMode |= GDCM_NAME_SPACE::LD_NOSHADOWSEQ; else { if ( am->ArgMgrDefined("noshadow") ) - loadMode |= gdcm::LD_NOSHADOW; + loadMode |= GDCM_NAME_SPACE::LD_NOSHADOW; if ( am->ArgMgrDefined("noseq") ) - loadMode |= gdcm::LD_NOSEQ; + loadMode |= GDCM_NAME_SPACE::LD_NOSEQ; } if (am->ArgMgrDefined("debug")) - gdcm::Debug::DebugOn(); - + GDCM_NAME_SPACE::Debug::DebugOn(); + + int check = am->ArgMgrDefined("check"); + // if unused Param we give up if ( am->ArgMgrPrintUnusedLabels() ) { @@ -82,22 +92,34 @@ int main(int argc, char *argv[]) delete am; return 0; } - + delete am; // we don't need Argument Manager any longer // ----- Begin Processing ----- - gdcm::DicomDir *dcmdir; - + GDCM_NAME_SPACE::DicomDir *dcmdir; + // we ask for Directory parsing - dcmdir = gdcm::DicomDir::New( ); + dcmdir = GDCM_NAME_SPACE::DicomDir::New( ); dcmdir->SetLoadMode(loadMode); dcmdir->SetDirectoryName(dirName); //dcmdir->SetParseDir(true); - dcmdir->Load(); - + + // struct tms tms1, tms2; // Time measurements + // times(&tms1); + + dcmdir->Load(); // Reads all the files and creates the GDCM_NAME_SPACE::DicomDir + + //times(&tms2); + //std::cout + // << (long) ((tms2.tms_utime) - (tms1.tms_utime)) + // << std::endl; + + if ( GDCM_NAME_SPACE::Debug::GetDebugFlag() ) + std::cout << "======================= End Parsing Directory" << std::endl; + // ----- Check the result if ( !dcmdir->GetFirstPatient() ) @@ -108,37 +130,46 @@ int main(int argc, char *argv[]) return 1; } - // ----- Create the corresponding DicomDir + // ----- Writes the corresponding DICOMDIR file (from the GDCM_NAME_SPACE::DicomDir) - dcmdir->Write("NewDICOMDIR"); + dcmdir->Write(name); dcmdir->Delete(); - - // Read from disc the just written DicomDir - gdcm::DicomDir *newDicomDir = gdcm::DicomDir::New(); - newDicomDir->SetFileName( "NewDICOMDIR" ); - newDicomDir->Load(); - if( !newDicomDir->IsReadable() ) + + if (check) { - std::cout<<" Written DicomDir 'NewDICOMDIR'" - <<" is not readable"<Delete(); - return 1; - } - - if( !newDicomDir->GetFirstPatient() ) - { - std::cout<<" Written DicomDir 'NewDICOMDIR'" - <<" has no patient"<Delete(); - return(1); + // Read from disc the just written DicomDir + + GDCM_NAME_SPACE::DicomDir *newDicomDir = GDCM_NAME_SPACE::DicomDir::New(); + newDicomDir->SetFileName( name ); + newDicomDir->Load(); + if ( GDCM_NAME_SPACE::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<Delete(); return 0; }