1 /*=========================================================================
4 Module: $RCSfile: BuildUpDicomDir.cxx,v $
6 Date: $Date: 2004/11/30 18:10:23 $
7 Version: $Revision: 1.9 $
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 =========================================================================*/
19 #include "gdcmDocEntry.h"
20 #include "gdcmDicomDir.h"
21 #include "gdcmDicomDirPatient.h"
22 #include "gdcmDirList.h"
23 #include "gdcmDebug.h"
28 #ifdef GDCM_NO_ANSI_STRING_STREAM
30 # define ostringstream ostrstream
35 #define ostringstream ostrstream
37 #include <sys/types.h>
41 #if defined(_MSC_VER) || defined(__BORLANDC__)
53 // ===============================================================
56 * \brief Builds up ex-nihilo a DICOMDIR file
57 * adding Patient, Study, Serie, Image descriptions
58 * to an empty gdcmDicomDir occurence
59 * and writes a file named NewDICOMDIR.
62 int main(int argc, char* argv[])
64 std::string dirName = "NewDICOMDIR";
68 std::cerr << "Usage: " << argv[0] << " [dicomdirname] ";
72 gdcm::DicomDir *dcmdir;
73 dcmdir = new gdcm::DicomDir();
75 printf( "\n------- BuildUpDicomDir: Test Print Meta only -----\n");
76 ((gdcm::Document *)dcmdir)->Print();
78 gdcm::DicomDirPatient *p1=dcmdir->NewPatient();
79 p1->SetEntryByNumber("patientONE",0x0010, 0x0010);
82 gdcm::DicomDirPatient *p2=dcmdir->NewPatient();
83 p2->SetEntryByNumber("patientTWO",0x0010, 0x0010);
84 gdcm::DicomDirStudy *s21=p2->NewStudy();
85 s21->SetEntryByNumber("StudyDescrTwo.One",0x0008, 0x1030);
86 gdcm::DicomDirSerie *s211=s21->NewSerie();
87 gdcm::DicomDirImage *s2111=s211->NewImage();
88 (void)s2111; //not used
90 gdcm::DicomDirStudy *s11=p1->NewStudy();
91 s11->SetEntryByNumber("StudyDescrOne.One",0x0008, 0x1030);
92 // Name of the physician reading study
93 // Header Entry to be created
94 s11->SetEntryByNumber("Dr Mabuse",0x0008, 0x1060);
96 gdcm::DicomDirPatient *p3 = dcmdir->NewPatient();
97 p3->SetEntryByNumber("patientTHREE",0x0010, 0x0010);
99 std::cout << "\n------- BuildUpDicomDir: Test Print of Patient ONE -----\n";
101 std::cout << "\n------- BuildUpDicomDir: Test Print of Patient THREE -----\n";
103 std::cout << "\n------- BuildUpDicomDir: Test Print of Patient TWO -------\n";
105 std::cout << "\n------- BuildUpDicomDir: Test Full Print-------------------\n";
106 dcmdir->SetPrintLevel(-1);
109 dcmdir->WriteDicomDir( dirName );
110 std::cout << std::endl;