1 /*=========================================================================
4 Module: $RCSfile: exBuildUpDicomDir.cxx,v $
6 Date: $Date: 2005/02/03 15:44:50 $
7 Version: $Revision: 1.1 $
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"
23 #include "gdcmDicomDirStudy.h"
24 #include "gdcmDicomDirSerie.h"
25 #include "gdcmDicomDirImage.h"
27 // ===============================================================
30 * \brief Builds up ex-nihilo a DICOMDIR file
31 * adding Patient, Study, Serie, Image descriptions
32 * to an empty gdcmDicomDir occurence
33 * and writes a file named NewDICOMDIR.
36 int main(int argc, char *argv[])
38 std::string dirName = "NewDICOMDIR";
42 std::cerr << "Usage: " << argv[0] << " [dicomdirname] ";
46 gdcm::DicomDir *dcmdir;
47 dcmdir = new gdcm::DicomDir();
49 std::cout << "\n------- BuildUpDicomDir: Test Print Meta only -----" << std::endl;
50 ((gdcm::Document *)dcmdir)->Print();
52 gdcm::DicomDirPatient *p1=dcmdir->NewPatient();
53 p1->SetValEntry("patientONE",0x0010, 0x0010);
56 gdcm::DicomDirPatient *p2=dcmdir->NewPatient();
57 p2->SetValEntry("patientTWO",0x0010, 0x0010);
58 gdcm::DicomDirStudy *s21=p2->NewStudy();
59 s21->SetValEntry("StudyDescrTwo.One",0x0008, 0x1030);
60 gdcm::DicomDirSerie *s211=s21->NewSerie();
61 gdcm::DicomDirImage *s2111=s211->NewImage();
62 (void)s2111; //not used
64 gdcm::DicomDirStudy *s11=p1->NewStudy();
65 s11->SetValEntry("StudyDescrOne.One",0x0008, 0x1030);
66 // Name of the physician reading study
67 // Header Entry to be created
68 s11->SetValEntry("Dr Mabuse",0x0008, 0x1060);
70 gdcm::DicomDirPatient *p3 = dcmdir->NewPatient();
71 p3->SetValEntry("patientTHREE",0x0010, 0x0010);
73 std::cout << "\n------- BuildUpDicomDir: Test Print of Patient ONE -----\n";
75 std::cout << "\n------- BuildUpDicomDir: Test Print of Patient THREE -----\n";
77 std::cout << "\n------- BuildUpDicomDir: Test Print of Patient TWO -------\n";
79 std::cout << "\n------- BuildUpDicomDir: Test Full Print-------------------\n";
80 dcmdir->SetPrintLevel(-1);
83 dcmdir->WriteDicomDir( dirName );
84 std::cout << std::endl;