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 | // |
---|
27 | // $Id: G3toG4MakeSolid.cc,v 1.10 2006/06/29 18:13:29 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-03 $ |
---|
29 | // |
---|
30 | // modified by I.Hrivnacova, V.Berejnoi 27 Sep 99 |
---|
31 | |
---|
32 | #include "globals.hh" |
---|
33 | #include "G4Box.hh" |
---|
34 | #include "G4Tubs.hh" |
---|
35 | #include "G4Trd.hh" |
---|
36 | #include "G4Trap.hh" |
---|
37 | #include "G4Cons.hh" |
---|
38 | #include "G4Sphere.hh" |
---|
39 | #include "G3toG4.hh" |
---|
40 | #include "G4Polycone.hh" |
---|
41 | #include "G4Polyhedra.hh" |
---|
42 | #include "G4Para.hh" |
---|
43 | #include "G4Hype.hh" |
---|
44 | #include "G4EllipticalTube.hh" |
---|
45 | #include "G3toG4MakeSolid.hh" |
---|
46 | |
---|
47 | G4VSolid* G3toG4MakeSolid(const G4String& vname, const G4String& shape, |
---|
48 | const G4double* Rpar, const G4int npar, |
---|
49 | G4bool& NegVolPars, G4bool& Deferred, |
---|
50 | G4bool* OKAxis){ |
---|
51 | |
---|
52 | // Create the solid if no negative length parameters |
---|
53 | G4VSolid *solid = 0; |
---|
54 | |
---|
55 | NegVolPars = false; |
---|
56 | |
---|
57 | // if npar = 0 assume LV deferral |
---|
58 | Deferred = (npar == 0); |
---|
59 | // modified |
---|
60 | if (Deferred) return solid; |
---|
61 | |
---|
62 | for (G4int i=0;i<3;i++){ |
---|
63 | OKAxis[i]=false; |
---|
64 | }; |
---|
65 | |
---|
66 | if ( shape == "BOX" ) { |
---|
67 | G4double pX = Rpar[0]*cm; |
---|
68 | G4double pY = Rpar[1]*cm; |
---|
69 | G4double pZ = Rpar[2]*cm; |
---|
70 | |
---|
71 | OKAxis[0]=OKAxis[1]=OKAxis[2]=true; |
---|
72 | |
---|
73 | NegVolPars = pX<0 || pY<0 || pZ<0; |
---|
74 | |
---|
75 | if (!(NegVolPars || Deferred)) { |
---|
76 | solid = new G4Box(vname, pX, pY, pZ); |
---|
77 | } |
---|
78 | |
---|
79 | } else if ( shape == "TRD1" ) { |
---|
80 | G4double pdx1 = Rpar[0]*cm; |
---|
81 | G4double pdx2 = Rpar[1]*cm; |
---|
82 | G4double pdy1 = Rpar[2]*cm; |
---|
83 | G4double pdy2 = pdy1; |
---|
84 | G4double pdz = Rpar[3]*cm; |
---|
85 | |
---|
86 | OKAxis[1]=OKAxis[2]=true; |
---|
87 | |
---|
88 | NegVolPars = pdx1<0 || pdx2<0 || pdy1<0 || pdz<0; |
---|
89 | |
---|
90 | if (!(NegVolPars || Deferred)) { |
---|
91 | solid = new G4Trd(vname, pdx1, pdx2, pdy1, pdy2, pdz); |
---|
92 | } |
---|
93 | |
---|
94 | } else if ( shape == "TRD2" ) { |
---|
95 | G4double pdx1 = Rpar[0]*cm; |
---|
96 | G4double pdx2 = Rpar[1]*cm; |
---|
97 | G4double pdy1 = Rpar[2]*cm; |
---|
98 | G4double pdy2 = Rpar[3]*cm; |
---|
99 | G4double pdz = Rpar[4]*cm; |
---|
100 | |
---|
101 | OKAxis[2]=true; |
---|
102 | |
---|
103 | NegVolPars = pdx1<0 || pdx2<0 || pdy1<0 || pdy2<0 || pdz<0; |
---|
104 | |
---|
105 | if (!(NegVolPars || Deferred)) { |
---|
106 | solid = new G4Trd(vname, pdx1, pdx2, pdy1, pdy2, pdz); |
---|
107 | } |
---|
108 | |
---|
109 | } else if ( shape == "TRAP" ) { |
---|
110 | G4double pDz = Rpar[0]*cm; |
---|
111 | G4double pTheta = Rpar[1]*deg; |
---|
112 | G4double pPhi = Rpar[2]*deg; |
---|
113 | G4double pDy1 = Rpar[3]*cm; |
---|
114 | G4double pDx1 = Rpar[4]*cm; |
---|
115 | G4double pDx2 = Rpar[5]*cm; |
---|
116 | G4double pAlp1 = Rpar[6]*deg; |
---|
117 | G4double pDy2 = Rpar[7]*cm; |
---|
118 | G4double pDx3 = Rpar[8]*cm; |
---|
119 | G4double pDx4 = Rpar[9]*cm; |
---|
120 | G4double pAlp2 = Rpar[10]*deg; |
---|
121 | |
---|
122 | OKAxis[2]=true; |
---|
123 | |
---|
124 | NegVolPars= pDz<0 || pDy1<0 || pDx1<0 || pDx2<0 || pDy2<0 || pDx3<0 || pDx4<0; |
---|
125 | |
---|
126 | if (!(NegVolPars || Deferred)) { |
---|
127 | // added for test only |
---|
128 | if (!(pDz>0)) pDz += 0.001*cm; |
---|
129 | if (!(pDy1>0)) pDy1 += 0.001*cm; |
---|
130 | if (!(pDx1>0)) pDx1 += 0.001*cm; |
---|
131 | if (!(pDx2>0)) pDx2 += 0.001*cm; |
---|
132 | if (!(pDy2>0)) pDy2 += 0.001*cm; |
---|
133 | if (!(pDx3>0)) pDx3 += 0.001*cm; |
---|
134 | if (!(pDx4>0)) pDx4 += 0.001*cm; |
---|
135 | |
---|
136 | solid = new |
---|
137 | G4Trap(vname, pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, |
---|
138 | pDx4, pAlp2); |
---|
139 | } |
---|
140 | |
---|
141 | } else if ( shape == "TUBE" ) { |
---|
142 | G4double pRMin = Rpar[0]*cm; |
---|
143 | G4double pRMax = Rpar[1]*cm; |
---|
144 | G4double pDz = Rpar[2]*cm; |
---|
145 | G4double pSPhi = 0.*deg; |
---|
146 | G4double pDPhi = 360.*deg; |
---|
147 | |
---|
148 | OKAxis[0]=OKAxis[1]=OKAxis[2]=true; |
---|
149 | |
---|
150 | NegVolPars = pRMin<0 || pRMax<0 || pDz<0; |
---|
151 | |
---|
152 | if (!(NegVolPars || Deferred)) { |
---|
153 | solid = new G4Tubs(vname, pRMin, pRMax, pDz, pSPhi, pDPhi); |
---|
154 | } |
---|
155 | |
---|
156 | } else if ( shape == "TUBS" ) { |
---|
157 | G4double pRMin = Rpar[0]*cm; |
---|
158 | G4double pRMax = Rpar[1]*cm; |
---|
159 | G4double pDz = Rpar[2]*cm; |
---|
160 | G4double pSPhi = Rpar[3]*deg; |
---|
161 | G4double pDPhi = Rpar[4]*deg - pSPhi; |
---|
162 | if ( Rpar[4]*deg <= pSPhi ) pDPhi = pDPhi + 360.*deg; |
---|
163 | |
---|
164 | OKAxis[0]=OKAxis[1]=OKAxis[2]=true; |
---|
165 | |
---|
166 | NegVolPars = pRMin<0 || pRMax<0 || pDz<0; |
---|
167 | |
---|
168 | if (!(NegVolPars || Deferred)){ |
---|
169 | solid = new G4Tubs(vname, pRMin, pRMax, pDz, pSPhi, pDPhi); |
---|
170 | } |
---|
171 | |
---|
172 | } else if ( shape == "CONE" ) { |
---|
173 | G4double pDz = Rpar[0]*cm; |
---|
174 | G4double pRmin1 = Rpar[1]*cm; |
---|
175 | G4double pRmax1 = Rpar[2]*cm; |
---|
176 | G4double pRmin2 = Rpar[3]*cm; |
---|
177 | G4double pRmax2 = Rpar[4]*cm; |
---|
178 | G4double pSPhi = 0.*deg; |
---|
179 | G4double pDPhi = 360.*deg; |
---|
180 | |
---|
181 | OKAxis[0]=OKAxis[1]=OKAxis[2]=true; |
---|
182 | |
---|
183 | NegVolPars = pDz<0 || pRmin1<0 || pRmax1<0 || pRmin2<0 || pRmax2<0; |
---|
184 | |
---|
185 | if (!(NegVolPars || Deferred)){ |
---|
186 | solid = new |
---|
187 | G4Cons(vname, pRmin1, pRmax1, pRmin2, pRmax2, pDz, pSPhi, pDPhi); |
---|
188 | } |
---|
189 | |
---|
190 | } else if ( shape == "CONS" ) { |
---|
191 | G4double pDz = Rpar[0]*cm; |
---|
192 | G4double pRmin1 = Rpar[1]*cm; |
---|
193 | G4double pRmax1 = Rpar[2]*cm; |
---|
194 | G4double pRmin2 = Rpar[3]*cm; |
---|
195 | G4double pRmax2 = Rpar[4]*cm; |
---|
196 | G4double pSPhi = Rpar[5]*deg; |
---|
197 | G4double pDPhi = Rpar[6]*deg - pSPhi; |
---|
198 | if ( Rpar[6]*deg <= pSPhi ) pDPhi = pDPhi + 360.*deg; |
---|
199 | |
---|
200 | OKAxis[0]=OKAxis[1]=OKAxis[2]=true; |
---|
201 | |
---|
202 | NegVolPars = pDz<0 || pRmin1<0 || pRmax1<0 || pRmin2<0 || pRmax2<0; |
---|
203 | |
---|
204 | if (!(NegVolPars || Deferred)){ |
---|
205 | solid = new |
---|
206 | G4Cons(vname, pRmin1, pRmax1, pRmin2, pRmax2, pDz, pSPhi, pDPhi); |
---|
207 | } |
---|
208 | |
---|
209 | } else if ( shape == "SPHE" ) { |
---|
210 | G4double pRmin = Rpar[0]*cm; |
---|
211 | G4double pRmax = Rpar[1]*cm; |
---|
212 | G4double pThe1 = Rpar[2]*deg; |
---|
213 | G4double pThe2 = Rpar[3]*deg; |
---|
214 | G4double pDThe = pThe2 - pThe1; |
---|
215 | G4double pPhi1 = Rpar[4]*deg; |
---|
216 | G4double pPhi2 = Rpar[5]*deg; |
---|
217 | G4double pDPhi = pPhi2 - pPhi1; |
---|
218 | |
---|
219 | NegVolPars = pRmin<0 || pRmax<0; |
---|
220 | |
---|
221 | if (!(NegVolPars || Deferred)) { |
---|
222 | solid = new G4Sphere(vname, pRmin, pRmax, pPhi1, pDPhi, pThe1, pDThe); |
---|
223 | } |
---|
224 | |
---|
225 | } else if ( shape == "PARA" ) { |
---|
226 | G4double pDx = Rpar[0]*cm; |
---|
227 | G4double pDy = Rpar[1]*cm; |
---|
228 | G4double pDz = Rpar[2]*cm; |
---|
229 | G4double pAlph = Rpar[3]*deg; |
---|
230 | G4double pThet = Rpar[4]*deg; |
---|
231 | G4double pPhi = Rpar[5]*deg; |
---|
232 | |
---|
233 | OKAxis[0]=OKAxis[1]=OKAxis[2]=true; |
---|
234 | |
---|
235 | NegVolPars = pDx<0 || pDy<0 || pDz<0; |
---|
236 | |
---|
237 | if (!(NegVolPars || Deferred)){ |
---|
238 | solid = new G4Para(vname, pDx, pDy, pDz, pAlph, pThet, pPhi); |
---|
239 | } |
---|
240 | |
---|
241 | } else if ( shape == "PGON" ) { |
---|
242 | G4int i; |
---|
243 | G4int npdv = G4int(Rpar[2]); |
---|
244 | G4int nz = G4int(Rpar[3]); |
---|
245 | G4double pPhi1 = Rpar[0]*deg; |
---|
246 | G4double dPhi = Rpar[1]*deg; |
---|
247 | G4double *DzArray = new G4double[nz]; |
---|
248 | G4double *Rmax = new G4double[nz]; |
---|
249 | G4double *Rmin = new G4double[nz]; |
---|
250 | |
---|
251 | OKAxis[0]=OKAxis[1]=OKAxis[2]=true; |
---|
252 | |
---|
253 | NegVolPars = 0; |
---|
254 | |
---|
255 | for(i=0; i<nz; i++) { |
---|
256 | G4int i4=3*i+4; |
---|
257 | G4int i5=i4+1; |
---|
258 | G4int i6=i4+2; |
---|
259 | DzArray[i] = Rpar[i4]*cm; |
---|
260 | Rmin[i] = Rpar[i5]*cm; |
---|
261 | Rmax[i] = Rpar[i6]*cm; |
---|
262 | } |
---|
263 | solid = new G4Polyhedra(vname, pPhi1, dPhi, npdv, nz, DzArray, Rmin, Rmax); |
---|
264 | delete [] DzArray; |
---|
265 | delete [] Rmin; |
---|
266 | delete [] Rmax; |
---|
267 | |
---|
268 | } else if ( shape == "PCON" ) { |
---|
269 | G4int i; |
---|
270 | G4double pPhi1 = Rpar[0]*deg; |
---|
271 | G4double dPhi = Rpar[1]*deg; |
---|
272 | G4int nz = G4int(Rpar[2]); |
---|
273 | G4double *DzArray = new G4double[nz]; |
---|
274 | G4double *Rmax = new G4double[nz]; |
---|
275 | G4double *Rmin = new G4double[nz]; |
---|
276 | |
---|
277 | OKAxis[0]=OKAxis[1]=OKAxis[2]=true; |
---|
278 | |
---|
279 | NegVolPars = 0; |
---|
280 | |
---|
281 | for(i=0; i<nz; i++){ |
---|
282 | G4int i4=3*i+3; |
---|
283 | G4int i5=i4+1; |
---|
284 | G4int i6=i4+2; |
---|
285 | DzArray[i] = Rpar[i4]*cm; |
---|
286 | Rmin[i] = Rpar[i5]*cm; |
---|
287 | Rmax[i] = Rpar[i6]*cm; |
---|
288 | } |
---|
289 | solid = new G4Polycone(vname, pPhi1, dPhi, nz, DzArray, Rmin, Rmax); |
---|
290 | delete [] DzArray; |
---|
291 | delete [] Rmin; |
---|
292 | delete [] Rmax; |
---|
293 | |
---|
294 | } else if ( shape == "ELTU" ) { |
---|
295 | G4double dX = Rpar[0]*cm; |
---|
296 | G4double dY = Rpar[1]*cm; |
---|
297 | G4double dZ = Rpar[2]*cm; |
---|
298 | |
---|
299 | OKAxis[0]=OKAxis[1]=OKAxis[2]=true; |
---|
300 | |
---|
301 | NegVolPars = dX<0 || dY<0 || dZ<0; |
---|
302 | |
---|
303 | if (!(NegVolPars || Deferred)) { |
---|
304 | solid = new G4EllipticalTube(vname, dX, dY, dZ); |
---|
305 | } |
---|
306 | |
---|
307 | } else if ( shape == "HYPE" ) { |
---|
308 | G4double pRmin = Rpar[0]*cm; |
---|
309 | G4double pRmax = Rpar[1]*cm; |
---|
310 | G4double pDz = Rpar[2]*cm; |
---|
311 | G4double pThet = Rpar[3]*deg; |
---|
312 | |
---|
313 | NegVolPars = pRmin<0 || pRmax<0 || pDz<0; |
---|
314 | |
---|
315 | if (!(NegVolPars || Deferred)){ |
---|
316 | solid = new G4Hype(vname, pRmin, pRmax, pThet, pThet, pDz); |
---|
317 | } else { |
---|
318 | G4cerr << "Negative length parameters not supported for shape " |
---|
319 | << shape << G4endl; |
---|
320 | } |
---|
321 | |
---|
322 | } else if ( shape == "GTRA" ) { |
---|
323 | // $$$ not implemented. |
---|
324 | G4cerr << "GTRA not supported" << G4endl; |
---|
325 | |
---|
326 | } else if ( shape == "CTUB" ) { |
---|
327 | // $$$ not implemented. |
---|
328 | G4cerr << "CTUB not supported" << G4endl; |
---|
329 | } |
---|
330 | return solid; |
---|
331 | } |
---|
332 | |
---|
333 | |
---|
334 | |
---|
335 | |
---|
336 | |
---|
337 | |
---|
338 | |
---|
339 | |
---|
340 | |
---|
341 | |
---|