2 #include "gdcmFileHelper.h"
3 #include "gdcmDocument.h"
4 #include "gdcmDataEntry.h"
5 #include "gdcmArgMgr.h"
8 " \n toBrainVisa :\n ",
9 " Extracts user supplied tags (identified by group number-element number)",
10 " and writes their values in a text file. ",
11 " (file will be used as input by BrainVisa software ) ",
13 " toBrainVisa filein=inputFileName (a DICOM file) ",
14 " fileoutout=outputFileName ",
15 " tags= list of tags to process ",
16 " [verbose] [debug] ",
18 " e.g. : tags=0020-0052,0008-0021,0018-1030 (no space!) ",
19 " dirout : will be created (as a text file) if doesn't exist ",
20 " verbose : user wants to run the program in 'verbose mode' ",
21 " debug : *developer* wants to run the program in 'debug mode' ",
24 int main (int argc , char *argv[])
26 // ============== Initialize Arguments Manager =============================
28 GDCM_NAME_SPACE::ArgMgr *am = new GDCM_NAME_SPACE::ArgMgr(argc, argv);
30 if (argc == 1 || am->ArgMgrDefined("usage"))
32 am->ArgMgrUsage(usage); // Display 'usage'
38 filein = am->ArgMgrGetString("filein",".");
41 fileout = am->ArgMgrGetString("fileout",".");
43 int verbose = am->ArgMgrDefined("verbose");
46 uint16_t *tags = am->ArgMgrGetXInt16Enum("tags", &nbTags);
48 // if unused Param we give up
49 if ( am->ArgMgrPrintUnusedLabels() )
51 am->ArgMgrUsage(usage);
55 delete am; // we don't need Argument Manager any longer
57 // ==================== Begin Processing =====================================
60 fp=fopen(fileout, "w");
63 std::cout << "Failed to open [" << fileout << "] for writting" << std::endl;
66 GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
67 f->SetLoadMode( GDCM_NAME_SPACE::LD_ALL);
68 f->SetFileName( filein );
73 std::cout << "Sorry, [" << filein << "] not a gdcm-readable "
80 std::cout << "[" << filein << "] is readable " << std::endl;
82 for(int i=0; i<nbTags; i++)
84 std::string toto = f->GetEntryString(tags[2*i], tags[2*i+1]);
85 fprintf(fp, "%s\n", toto.c_str() );
87 std::cout << "[" << toto << "]" << std::endl;