1 /*=========================================================================
4 Module: $RCSfile: MakeDicomDir.cxx,v $
6 Date: $Date: 2005/04/14 15:15:15 $
7 Version: $Revision: 1.2 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
18 #include "gdcmDocEntry.h"
19 #include "gdcmDicomDir.h"
20 #include "gdcmDicomDirPatient.h"
21 #include "gdcmDirList.h"
22 #include "gdcmDebug.h"
27 void StartMethod(void *toto) {
29 std::cout<<"Start parsing"<<std::endl;
32 void EndMethod(void *toto) {
34 std::cout<<"End parsing"<<std::endl;
40 * \brief Explores recursively the given directory (or GDCM_DATA_ROOT by default)
41 * orders the gdcm-readable found Files
42 * according their Patient/Study/Serie/Image characteristics
43 * makes the gdcmDicomDir
44 * and writes a file named NewDICOMDIR..
47 int main(int argc, char *argv[])
49 //gdcm::Debug::DebugOn();
58 dirName = GDCM_DATA_ROOT;
61 gdcm::DicomDir *dcmdir;
62 // we ask for Directory parsing
64 // Old style (still available) :
65 // dcmdir = new gdcm::DicomDir(dirName, true);
67 // new style (user is allowed no to load Sequences an/or Shadow Groups)
68 dcmdir = new gdcm::DicomDir( );
69 dcmdir->SetParseDir(true);
70 dcmdir->SetLoadMode(NO_SEQ | NO_SHADOW);
71 dcmdir->Load(dirName);
73 dcmdir->SetStartMethod(StartMethod, (void *) NULL);
74 dcmdir->SetEndMethod(EndMethod);
76 if ( !dcmdir->GetFirstPatient() )
78 std::cout << "makeDicomDir: no patient found. Exiting."
85 // Create the corresponding DicomDir
86 dcmdir->WriteDicomDir("NewDICOMDIR");
89 // Read from disc the just written DicomDir
90 gdcm::DicomDir *newDicomDir = new gdcm::DicomDir("NewDICOMDIR");
91 if( !newDicomDir->IsReadable() )
93 std::cout<<" Written DicomDir 'NewDICOMDIR'"
94 <<" is not readable"<<std::endl
95 <<" ...Failed"<<std::endl;
101 if( !newDicomDir->GetFirstPatient() )
103 std::cout<<" Written DicomDir 'NewDICOMDIR'"
104 <<" has no patient"<<std::endl
105 <<" ...Failed"<<std::endl;
111 std::cout<<std::flush;