Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
DICOM.cc
이 파일의 문서화 페이지로 가기
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 110379 2018-05-22 07:45:15Z 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, Qubec (QC) Canada
44 // *******************************************************
45 #include "G4Types.hh"
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 #ifdef G4_DCMTK
66 #include "DicomFileMgr.hh"
67 #else
68 #include "DicomHandler.hh"
69 #endif
70 
71 #include "DicomIntersectVolume.hh"
72 #include "QGSP_BIC.hh"
73 #include "G4tgrMessenger.hh"
74 
75 #include "G4VisExecutive.hh"
76 #include "G4UIExecutive.hh"
77 
78 #include "Shielding.hh"
79 
80 //=================================================================================
81 
82 int main(int argc,char** argv)
83 {
84  // Instantiate G4UIExecutive if interactive mode
85  G4UIExecutive* ui = nullptr;
86  if ( argc == 1 ) {
87  ui = new G4UIExecutive(argc, argv);
88  }
89 
90  new G4tgrMessenger;
91  char* part = getenv( "DICOM_PARTIAL_PARAM" );
92  G4bool bPartial = FALSE;
93  if( part && G4String(part) == "1" ) {
94  bPartial = TRUE;
95  }
96 
98  CLHEP::HepRandom::setTheSeed(24534575684783);
99  long seeds[2];
100  seeds[0] = 534524575674523;
101  seeds[1] = 526345623452457;
103 
104  // Construct the default run manager
105 #ifdef G4MULTITHREADED
106  char* nthread_c = getenv("DICOM_NTHREADS");
107 
108  unsigned nthreads = 4;
109  unsigned env_threads = 0;
110 
111  if(nthread_c) { env_threads = G4UIcommand::ConvertToDouble(nthread_c); }
112  if(env_threads > 0) { nthreads = env_threads; }
113 
114  G4MTRunManager* runManager = new G4MTRunManager;
115  runManager->SetNumberOfThreads(nthreads);
116 
117  G4cout << "\n\n\tDICOM running in multithreaded mode with " << nthreads
118  << " threads\n\n" << G4endl;
119 
120 
121 #else
122  G4RunManager* runManager = new G4RunManager;
123  G4cout << "\n\n\tDICOM running in serial mode\n\n" << G4endl;
124 
125 #endif
126 
127  DicomDetectorConstruction* theGeometry = 0;
128 
129 #ifdef G4_DCMTK
130  DicomFileMgr* theFileMgr = 0;
131 #else
132  DicomHandler* dcmHandler = 0;
133 #endif
134 
135  if( !bPartial ){
136 #ifdef G4_DCMTK
137 
138  theFileMgr = DicomFileMgr::GetInstance();
139  theFileMgr->Convert("Data.dat");
140 
141 #else
142  // Treatment of DICOM images before creating the G4runManager
143  dcmHandler = new DicomHandler;
144  dcmHandler->CheckFileFormat();
145 #endif
146 
147  // Initialisation of physics, geometry, primary particles ...
148  char* nest = getenv( "DICOM_NESTED_PARAM" );
149  if( nest && G4String(nest) == "1" ) {
150  theGeometry = new DicomNestedParamDetectorConstruction();
151  } else {
152  theGeometry = new DicomRegularDetectorConstruction();
153  }
154  } else {
155  theGeometry = new DicomPartialDetectorConstruction();
156  }
157  runManager->SetUserInitialization(theGeometry);
158 
159  // std::vector<G4String>* MyConstr = new std::vector<G4String>;
160  // MyConstr->push_back("G4EmStandardPhysics");
161  // G4VModularPhysicsList* phys = new G4GenericPhysicsList(MyConstr);
162  G4VModularPhysicsList* phys = new Shielding();
163  runManager->SetUserInitialization(phys);
164 
165  // Set user action classes
167 
168  runManager->Initialize();
169 
170  new DicomIntersectVolume();
171 
172  // visualisation manager
173  G4VisManager* visManager = new G4VisExecutive;
174  visManager->Initialize();
175 
176  G4UImanager* UImanager = G4UImanager::GetUIpointer();
177 
178  if (ui)
179  {
180  UImanager->ApplyCommand("/control/execute vis.mac");
181  ui->SessionStart();
182  delete ui;
183  }
184  else
185  {
186  G4String command = "/control/execute ";
187  G4String fileName = argv[1];
188  UImanager->ApplyCommand(command+fileName);
189  }
190 
191  delete visManager;
192  delete runManager;
193 
194  if( !bPartial ) {
195 #ifdef G4_DCMTK
196  delete theFileMgr;
197 #else
198  delete dcmHandler;
199 #endif
200  }
201 
202  return 0;
203 }
204 
void SetNumberOfThreads(G4int n)
Definition of the DicomHandler class.
static G4double ConvertToDouble(const char *st)
Definition: G4UIcommand.cc:457
static void setTheSeed(long seed, int lux=3)
Definition: Random.cc:231
static DicomFileMgr * GetInstance()
Definition: DicomFileMgr.cc:41
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
#define G4endl
Definition: G4ios.hh:61
Definition of the DicomActionInitialization class.
void Convert(G4String fFileName)
Definition: DicomFileMgr.cc:59
Definition of the DicomNestedParamDetectorConstruction class.
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
bool G4bool
Definition: G4Types.hh:79
TString part[npart]
Definition: Style.C:32
#define FALSE
Definition: globals.hh:52
static void setTheEngine(HepRandomEngine *theNewEngine)
Definition: Random.cc:270
Definition of the DicomRegularDetectorConstruction class.
#define TRUE
Definition: globals.hh:55
Definition of the DicomIntersectVolume class.
Definition of the DicomPartialDetectorConstruction class.
int main(int argc, char **argv)
Definition: genwindef.cc:359
void CheckFileFormat()
G4GLOB_DLL std::ostream G4cout
void Initialize()
static void setTheSeeds(const long *seeds, int aux=-1)
Definition: Random.cc:241
Manages intersections of DICOM files with volumes.
TShielding< G4VModularPhysicsList > Shielding
Definition: Shielding.hh:68
virtual void Initialize()