/*========================================================================= Program: gdcm Module: $RCSfile: MakeDicomDir.cxx,v $ Language: C++ Date: $Date: 2005/08/30 15:13:05 $ Version: $Revision: 1.14 $ 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 "gdcmDirList.h" #include "gdcmDebug.h" #include "gdcmArgMgr.h" #include // --- void StartMethod(void *toto) { (void)toto; std::cout<<"Start parsing"<ArgMgrDefined("usage")) { am->ArgMgrUsage(usage); // Display 'usage' delete am; return 0; } char *dirName; dirName = am->ArgMgrGetString("dirName",(char *)"."); int loadMode = gdcm::LD_ALL; if ( am->ArgMgrDefined("noshadowseq") ) loadMode |= gdcm::LD_NOSHADOWSEQ; else { if ( am->ArgMgrDefined("noshadow") ) loadMode |= gdcm::LD_NOSHADOW; if ( am->ArgMgrDefined("noseq") ) loadMode |= gdcm::LD_NOSEQ; } if (am->ArgMgrDefined("debug")) gdcm::Debug::DebugOn(); // if unused Param we give up if ( am->ArgMgrPrintUnusedLabels() ) { am->ArgMgrUsage(usage); delete am; return 0; } delete am; // we don't need Argument Manager any longer // ----- Begin Processing ----- gdcm::DicomDir *dcmdir; // we ask for Directory parsing dcmdir = new gdcm::DicomDir( ); dcmdir->SetStartMethod(StartMethod); dcmdir->SetEndMethod(EndMethod); dcmdir->SetLoadMode(loadMode); dcmdir->SetDirectoryName(dirName); //dcmdir->SetParseDir(true); dcmdir->Load(); // ----- Check the result if ( !dcmdir->GetFirstPatient() ) { std::cout << "makeDicomDir: no patient found. Exiting." << std::endl; delete dcmdir; 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->SetFileName( "NewDICOMDIR" ); newDicomDir->Load(); if( !newDicomDir->IsReadable() ) { std::cout<<" Written DicomDir 'NewDICOMDIR'" <<" is not readable"<GetFirstPatient() ) { std::cout<<" Written DicomDir 'NewDICOMDIR'" <<" has no patient"<