Geant4  10.01.p03
DICOM.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: DICOM.cc 83429 2014-08-21 15:47:32Z gcosmo $
27 //
30 //
31 // The code was written by :
32 // *Louis Archambault louis.archambault@phy.ulaval.ca,
33 // *Luc Beaulieu beaulieu@phy.ulaval.ca
34 // +Vincent Hubert-Tremblay at tigre.2@sympatico.ca
35 //
36 //
37 // *Centre Hospitalier Universitaire de Quebec (CHUQ),
38 // Hotel-Dieu de Quebec, departement de Radio-oncologie
39 // 11 cote du palais. Quebec, QC, Canada, G1R 2J6
40 // tel (418) 525-4444 #6720
41 // fax (418) 691 5268
42 //
43 // + Université Laval, Québec (QC) Canada
44 //*******************************************************//
45 
46 
47 #ifdef G4MULTITHREADED
48 #include "G4MTRunManager.hh"
49 #else
50 #include "G4RunManager.hh"
51 #endif
52 
53 #include "globals.hh"
54 #include "G4UImanager.hh"
55 #include "Randomize.hh"
56 
57 #include "G4GenericPhysicsList.hh"
58 
62 
64 
65 #include "DicomHandler.hh"
66 #include "DicomIntersectVolume.hh"
67 #include "QGSP_BIC.hh"
68 #include "G4tgrMessenger.hh"
69 
70 #ifdef G4VIS_USE
71 #include "G4VisExecutive.hh"
72 #endif
73 
74 #ifdef G4UI_USE
75 #include "G4UIExecutive.hh"
76 #endif
77 
78 //=================================================================================
79 
80 int main(int argc,char** argv)
81 {
82 
83  new G4tgrMessenger;
84  char* part = getenv( "DICOM_PARTIAL_PARAM" );
85  G4bool bPartial = FALSE;
86  if( part && G4String(part) == "1" ) {
87  bPartial = TRUE;
88  }
89 
90  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
91  CLHEP::HepRandom::setTheSeed(24534575684783);
92  long seeds[2];
93  seeds[0] = 534524575674523;
94  seeds[1] = 526345623452457;
95  CLHEP::HepRandom::setTheSeeds(seeds);
96 
97  // Construct the default run manager
98 #ifdef G4MULTITHREADED
99  char* nthread_c = getenv("DICOM_NTHREADS");
100 
101  unsigned nthreads = 4;
102  unsigned env_threads = 0;
103 
104  if(nthread_c) { env_threads = G4UIcommand::ConvertToDouble(nthread_c); }
105  if(env_threads > 0) { nthreads = env_threads; }
106 
107  G4MTRunManager* runManager = new G4MTRunManager;
108  runManager->SetNumberOfThreads(nthreads);
109 
110  G4cout << "\n\n\tDICOM running in multithreaded mode with " << nthreads
111  << " threads\n\n" << G4endl;
112 
113 
114 #else
115  G4RunManager* runManager = new G4RunManager;
116  G4cout << "\n\n\tDICOM running in serial mode\n\n" << G4endl;
117 
118 #endif
119 
120  DicomDetectorConstruction* theGeometry = 0;
121  DicomHandler* dcmHandler = 0;
122 
123  if( !bPartial ){
124  // Treatment of DICOM images before creating the G4runManager
125  dcmHandler = new DicomHandler;
126  dcmHandler->CheckFileFormat();
127 
128  // Initialisation of physics, geometry, primary particles ...
129  char* nest = getenv( "DICOM_NESTED_PARAM" );
130  if( nest && G4String(nest) == "1" ) {
131  theGeometry = new DicomNestedParamDetectorConstruction();
132  } else {
133  theGeometry = new DicomRegularDetectorConstruction();
134  }
135  } else {
136  theGeometry = new DicomPartialDetectorConstruction();
137  }
138  runManager->SetUserInitialization(theGeometry);
139 
140  std::vector<G4String>* MyConstr = new std::vector<G4String>;
141  MyConstr->push_back("G4EmStandardPhysics");
142  G4VModularPhysicsList* phys = new G4GenericPhysicsList(MyConstr);
143  runManager->SetUserInitialization(phys);
144 
145  // Set user action classes
147 
148  runManager->Initialize();
149 
150  new DicomIntersectVolume();
151 
152 #ifdef G4VIS_USE
153  // visualisation manager
154  G4VisManager* visManager = new G4VisExecutive;
155  visManager->Initialize();
156 #endif
157 
158 
159  G4UImanager* UImanager = G4UImanager::GetUIpointer();
160 
161 
162  if (argc==1)
163  {
164 #ifdef G4UI_USE
165  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
166 #ifdef G4VIS_USE
167  UImanager->ApplyCommand("/control/execute vis.mac");
168 #endif
169  ui->SessionStart();
170  delete ui;
171 #endif
172  }
173  else
174  {
175  G4String command = "/control/execute ";
176  G4String fileName = argv[1];
177  UImanager->ApplyCommand(command+fileName);
178  }
179 
180  delete runManager;
181 
182 #ifdef G4VIS_USE
183  delete visManager;
184 #endif
185 
186  if( !bPartial ) { delete dcmHandler; }
187 
188  return 0;
189 }
190 
191 
192 
Definition of the DicomNestedParamDetectorConstruction class.
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
Definition of the DicomRegularDetectorConstruction class.
void SetNumberOfThreads(G4int n)
Construct the phantom using DicomPhantomParameterisationColour.
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
Manages intersections of DICOM files with volumes.
G4GLOB_DLL std::ostream G4cout
Definition of the DicomPartialDetectorConstruction class.
bool G4bool
Definition: G4Types.hh:79
#define FALSE
Definition: globals.hh:52
static G4double ConvertToDouble(const char *st)
Definition: G4UIcommand.cc:443
#define TRUE
Definition: globals.hh:55
void Initialize()
Definition of the DicomActionInitialization class.
TG4GenericPhysicsList< G4VModularPhysicsList > G4GenericPhysicsList
Definition of the DicomIntersectVolume class.
DicomRegularDetectorConstruction class.
Dicom detector construction.
Definition of the DicomHandler class.
virtual void Initialize()
#define G4endl
Definition: G4ios.hh:61
int main(int argc, char **argv)
Definition: DICOM.cc:80
void CheckFileFormat()
Construct a DICOM Geant4 geometry produced from the intersetion of a DICOM file and a volume...
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:432