1 /*=========================================================================
4 Module: $RCSfile: MakeDicomDir.cxx,v $
6 Date: $Date: 2005/06/03 15:40:53 $
7 Version: $Revision: 1.3 $
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 // some images have a wrong length for element 0x0000 of private groups
71 // dcmdir->SetLoadMode(NO_SEQ | NO_SHADOW);
73 dcmdir->SetLoadMode(NO_SEQ);
74 dcmdir->Load(dirName);
76 dcmdir->SetStartMethod(StartMethod, (void *) NULL);
77 dcmdir->SetEndMethod(EndMethod);
79 if ( !dcmdir->GetFirstPatient() )
81 std::cout << "makeDicomDir: no patient found. Exiting."
88 // Create the corresponding DicomDir
89 dcmdir->WriteDicomDir("NewDICOMDIR");
92 // Read from disc the just written DicomDir
93 gdcm::DicomDir *newDicomDir = new gdcm::DicomDir("NewDICOMDIR");
94 if( !newDicomDir->IsReadable() )
96 std::cout<<" Written DicomDir 'NewDICOMDIR'"
97 <<" is not readable"<<std::endl
98 <<" ...Failed"<<std::endl;
104 if( !newDicomDir->GetFirstPatient() )
106 std::cout<<" Written DicomDir 'NewDICOMDIR'"
107 <<" has no patient"<<std::endl
108 <<" ...Failed"<<std::endl;
114 std::cout<<std::flush;