1 /*=========================================================================
4 Module: $RCSfile: TestMakeDicomDir.cxx,v $
6 Date: $Date: 2005/10/25 14:52:31 $
7 Version: $Revision: 1.10 $
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"
25 void StartMethod(void *startMethod)
28 std::cout<<"Start parsing"<<std::endl;
31 void EndMethod(void *endMethod)
34 std::cout<<"End parsing"<<std::endl;
39 * \brief - Explores recursively the given directory
40 * (or GDCM_DATA_ROOT by default)
41 * - Orders the gdcm-readable found Files
42 * according their Patient/Study/Serie/Image characteristics
43 * - Makes the gdcm::DicomDir.
44 * - Writes a file named "NewDICOMDIR".
45 * - Reads "NewDICOMDIR" file.
48 int TestMakeDicomDir(int argc, char *argv[])
50 //gdcm::Debug::DebugOn();
59 dirName = GDCM_DATA_ROOT;
62 gdcm::DicomDir *dcmdir;
64 // new style (user is allowed no to load Sequences an/or Shadow Groups)
65 dcmdir = gdcm::DicomDir::New( );
67 // dcmdir->SetLoadMode(gdcm::LD_NOSEQ | gdcm::LD_NOSHADOW);
68 // some images have a wrong length for element 0x0000 of private groups
69 dcmdir->SetLoadMode(gdcm::LD_NOSEQ);
70 dcmdir->SetDirectoryName(dirName);
73 dcmdir->SetStartMethod(StartMethod);
74 dcmdir->SetEndMethod(EndMethod);
76 if ( !dcmdir->GetFirstPatient() )
78 std::cout << "makeDicomDir: no patient found. Exiting."
85 // Create the corresponding DicomDir
86 dcmdir->Write("NewDICOMDIR");
89 // Read from disc the just written DicomDir
90 gdcm::DicomDir *newDicomDir = gdcm::DicomDir::New();
91 newDicomDir->SetFileName("NewDICOMDIR");
94 if( !newDicomDir->IsReadable() )
96 std::cout<<" Written DicomDir 'NewDICOMDIR'"
97 <<" is not readable"<<std::endl
98 <<" ...Failed"<<std::endl;
100 newDicomDir->Delete();
104 if( !newDicomDir->GetFirstPatient() )
106 std::cout<<" Written DicomDir 'NewDICOMDIR'"
107 <<" has no patient"<<std::endl
108 <<" ...Failed"<<std::endl;
110 newDicomDir->Delete();
114 std::cout<<std::flush;
115 newDicomDir->Delete();