1 /*=========================================================================
4 Module: $RCSfile: BuildUpDicomDir.cxx,v $
6 Date: $Date: 2004/11/16 04:26:17 $
7 Version: $Revision: 1.8 $
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 =========================================================================*/
20 #include "gdcmDocEntry.h"
21 #include "gdcmDicomDir.h"
22 #include "gdcmDicomDirPatient.h"
23 #include "gdcmDirList.h"
24 #include "gdcmDebug.h"
27 #ifdef GDCM_NO_ANSI_STRING_STREAM
29 # define ostringstream ostrstream
34 #define ostringstream ostrstream
36 #include <sys/types.h>
40 #if defined(_MSC_VER) || defined(__BORLANDC__)
52 // ===============================================================
55 * \brief Builds up ex-nihilo a DICOMDIR file
56 * adding Patient, Study, Serie, Image descriptions
57 * to an empty gdcmDicomDir occurence
58 * and writes a file named NewDICOMDIR.
61 int main(int argc, char* argv[])
63 std::string dirName = "NewDICOMDIR";
67 std::cerr << "Usage: " << argv[0] << " [dicomdirname] ";
71 gdcm::DicomDir *dcmdir;
72 dcmdir = new gdcm::DicomDir();
74 printf( "\n------- BuildUpDicomDir: Test Print Meta only -----\n");
75 ((gdcm::Document *)dcmdir)->Print();
77 gdcm::DicomDirPatient *p1=dcmdir->NewPatient();
78 p1->SetEntryByNumber("patientONE",0x0010, 0x0010);
81 gdcm::DicomDirPatient *p2=dcmdir->NewPatient();
82 p2->SetEntryByNumber("patientTWO",0x0010, 0x0010);
83 gdcm::DicomDirStudy *s21=p2->NewStudy();
84 s21->SetEntryByNumber("StudyDescrTwo.One",0x0008, 0x1030);
85 gdcm::DicomDirSerie *s211=s21->NewSerie();
86 gdcm::DicomDirImage *s2111=s211->NewImage();
87 (void)s2111; //not used
89 gdcm::DicomDirStudy *s11=p1->NewStudy();
90 s11->SetEntryByNumber("StudyDescrOne.One",0x0008, 0x1030);
91 // Name of the physician reading study
92 // Header Entry to be created
93 s11->SetEntryByNumber("Dr Mabuse",0x0008, 0x1060);
95 gdcm::DicomDirPatient *p3 = dcmdir->NewPatient();
96 p3->SetEntryByNumber("patientTHREE",0x0010, 0x0010);
98 std::cout << "\n------- BuildUpDicomDir: Test Print of Patient ONE -----\n";
100 std::cout << "\n------- BuildUpDicomDir: Test Print of Patient THREE -----\n";
102 std::cout << "\n------- BuildUpDicomDir: Test Print of Patient TWO -------\n";
104 std::cout << "\n------- BuildUpDicomDir: Test Full Print-------------------\n";
105 dcmdir->SetPrintLevel(-1);
108 dcmdir->WriteDicomDir( dirName );
109 std::cout << std::endl;