3 #include "gdcmDocEntry.h"
4 #include "gdcmDicomDir.h"
5 #include "gdcmDicomDirPatient.h"
6 #include "gdcmDirList.h"
10 #ifdef GDCM_NO_ANSI_STRING_STREAM
12 # define ostringstream ostrstream
17 #define ostringstream ostrstream
19 #include <sys/types.h>
34 // ===============================================================
37 * \brief Builds up ex-nihilo a DICOMDIR file
38 * adding Patient, Study, Serie, Image descriptions
39 * to an empty gdcmDicomDir occurence
40 * and writes a file named NewDICOMDIR.
43 int main(int argc, char* argv[])
45 std::string dirName = "NewDICOMDIR";
49 std::cerr << "Usage: " << argv[0] << " [dicomdirname] ";
54 dcmdir=new gdcmDicomDir();
56 printf( "\n------- BuildUpDicomDir: Test Print Meta only -----\n");
57 ((gdcmDocument *)dcmdir)->Print();
59 gdcmDicomDirPatient *p1=dcmdir->NewPatient();
60 p1->SetEntryByNumber("patientONE",0x0010, 0x0010);
63 gdcmDicomDirPatient *p2=dcmdir->NewPatient();
64 p2->SetEntryByNumber("patientTWO",0x0010, 0x0010);
65 gdcmDicomDirStudy *s21=p2->NewStudy();
66 s21->SetEntryByNumber("StudyDescrTwo.One",0x0008, 0x1030);
67 gdcmDicomDirSerie *s211=s21->NewSerie();
68 gdcmDicomDirImage *s2111=s211->NewImage();
69 (void)s2111; //not used
71 gdcmDicomDirStudy *s11=p1->NewStudy();
72 s11->SetEntryByNumber("StudyDescrOne.One",0x0008, 0x1030);
73 // Name of the physician reading study
74 // Header Entry to be created
75 s11->SetEntryByNumber("Dr Mabuse",0x0008, 0x1060);
77 gdcmDicomDirPatient *p3 = dcmdir->NewPatient();
78 p3->SetEntryByNumber("patientTHREE",0x0010, 0x0010);
80 std::cout << "\n------- BuildUpDicomDir: Test Print of Patient ONE -----\n";
82 std::cout << "\n------- BuildUpDicomDir: Test Print of Patient THREE -----\n";
84 std::cout << "\n------- BuildUpDicomDir: Test Print of Patient TWO -------\n";
86 std::cout << "\n------- BuildUpDicomDir: Test Full Print-------------------\n";
87 dcmdir->SetPrintLevel(-1);
90 dcmdir->WriteDicomDir( dirName );
91 std::cout << std::endl;