source: trunk/source/visualization/test/src/BuildShapes.cc@ 1317

Last change on this file since 1317 was 954, checked in by garnier, 17 years ago

remise a jour

File size: 13.1 KB
Line 
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: BuildShapes.cc,v 1.6 2006/06/29 21:34:20 gunter Exp $
28// GEANT4 tag $Name: $
29//
30//
31
32#include "BuildShapes.hh"
33
34#include "G4PVPlacement.hh"
35#include "G4LogicalVolume.hh"
36
37#include "G4Material.hh"
38#include "G4VisAttributes.hh"
39
40#include "G4Box.hh"
41#include "G4Cons.hh"
42#include "G4Tubs.hh"
43#include "G4Trd.hh"
44#include "G4Trap.hh"
45#include "G4Sphere.hh"
46#include "G4Para.hh"
47
48// #define USE_BREP_SOLID
49
50#if defined USE_BREP_SOLID
51
52#include"G4BREPSolidPCone.h"
53#include"G4BREPSolidPolyhedra.h"
54
55#endif
56
57G4VPhysicalVolume* TheWorld ()
58{
59 G4double a, iz, density;
60 G4String name, symbol;
61 G4int nel;
62 a = 14.01*g/mole;
63 G4Element* elN = new G4Element(name="Nitrogen", symbol="N", iz=7., a);
64 a = 16.00*g/mole;
65 G4Element* elO = new G4Element(name="Oxigen", symbol="O", iz=8., a);
66 density = 1.29e-03*g/cm3;
67 G4Material* Air = new G4Material(name="Air", density, nel=2);
68 Air->AddElement(elN, .7);
69 Air->AddElement(elO, .3);
70
71 G4Box *myWorldBox= new G4Box("WBox",10.0, 10.0, 10.0); // Big enough!
72 G4LogicalVolume *myWorldLog=new G4LogicalVolume(myWorldBox,Air,
73 "WLog", 0, 0, 0);
74 myWorldLog -> SetVisAttributes (&G4VisAttributes::Invisible);
75 G4PVPlacement *myWorldPhys=new G4PVPlacement(0,G4ThreeVector(),
76 "WPhys",
77 myWorldLog,
78 0,false,0);
79 return myWorldPhys;
80}
81
82G4VPhysicalVolume* BuildBox()
83{
84 G4VPhysicalVolume* theWorld = TheWorld ();
85
86 //----- material
87 G4double z = 13.;
88 G4double a = 26.98*g/mole;
89 G4double density = 2.7*g/cm3;
90 G4Material myMaterial("Aluminium", z, a, density);
91
92 //----- Vis Attributes
93 G4VisAttributes* pVA = new G4VisAttributes (G4Colour(1,0,0));
94
95 //----- Solid
96 G4Box *box = new G4Box ("Box", 1 ,4, 9 );
97
98 //----- Logical Volume
99 G4LogicalVolume *boxLog=new G4LogicalVolume( box, &myMaterial,
100 "BoxLog",0,0,0);
101 boxLog -> SetVisAttributes ( pVA );
102
103 //----- physical volume
104 new G4PVPlacement( 0,G4ThreeVector(),
105 "BoxPhys",
106 boxLog,
107 theWorld,
108 false,0);
109
110 return theWorld;
111
112} // BuildBox
113
114
115G4VPhysicalVolume* BuildCylinder()
116{
117 G4VPhysicalVolume* theWorld = TheWorld ();
118
119 //----- material
120 G4double z = 13.;
121 G4double a = 26.98*g/mole;
122 G4double density = 2.7*g/cm3;
123 G4Material myMaterial("Aluminium", z, a, density);
124
125 //----- Vis Attributes
126 G4VisAttributes* pVA = new G4VisAttributes (G4Colour(0,1,0));
127
128 //----- Solid
129 G4Tubs *tubs = new G4Tubs ("Tubs", 0. , 1.5, 2.0 , 0., twopi);
130
131 //----- Logical Volume
132 G4LogicalVolume *tubsLog=new G4LogicalVolume( tubs, &myMaterial,
133 "tubsLog",0,0,0);
134 tubsLog -> SetVisAttributes ( pVA );
135
136 //----- physical volume
137 new G4PVPlacement( 0,G4ThreeVector(),
138 "tubsPhys",
139 tubsLog,
140 theWorld,
141 false,0);
142
143 return theWorld;
144
145}// BuildCyllinder
146
147
148
149G4VPhysicalVolume* BuildTubs()
150{
151 G4VPhysicalVolume* theWorld = TheWorld ();
152
153 //----- material
154 G4double z = 13.;
155 G4double a = 26.98*g/mole;
156 G4double density = 2.7*g/cm3;
157 G4Material myMaterial("Aluminium", z, a, density);
158
159 //----- Vis Attributes
160 G4VisAttributes* pVA = new G4VisAttributes (G4Colour(0,1,0));
161
162 //----- Solid
163 G4Tubs *tubs = new G4Tubs ("Tubs", 1.0 , 1.5, 2.0 , 1.5, 4.5 );
164
165 //----- Logical Volume
166 G4LogicalVolume *tubsLog=new G4LogicalVolume( tubs, &myMaterial,
167 "tubsLog",0,0,0);
168 tubsLog -> SetVisAttributes ( pVA );
169
170 //----- physical volume
171 new G4PVPlacement( 0,G4ThreeVector(),
172 "tubsPhys",
173 tubsLog,
174 theWorld,
175 false,0);
176
177 return theWorld;
178
179}// BuildTubs
180
181
182
183G4VPhysicalVolume* BuildCons()
184{
185 G4VPhysicalVolume* theWorld = TheWorld ();
186
187 //----- material
188 G4double z = 13.;
189 G4double a = 26.98*g/mole;
190 G4double density = 2.7*g/cm3;
191 G4Material myMaterial("Aluminium", z, a, density);
192
193 //----- Vis Attributes
194 G4VisAttributes* pVA = new G4VisAttributes (G4Colour(0,0,1));
195
196 //----- Solid
197 G4Cons *cons = new G4Cons ("Cons", 1.0 , 1.5, 0.5, 1.0 ,2.0, 1.5, 4.5 );
198
199 //----- Logical Volume
200 G4LogicalVolume *consLog=new G4LogicalVolume( cons, &myMaterial,
201 "consLog",0,0,0);
202 consLog -> SetVisAttributes ( pVA );
203
204 //----- physical volume
205 new G4PVPlacement( 0,G4ThreeVector(),
206 "consPhys",
207 consLog,
208 theWorld,
209 false,0);
210
211 return theWorld;
212
213}// BuildCons
214
215
216G4VPhysicalVolume* BuildTrd()
217{
218 G4VPhysicalVolume* theWorld = TheWorld ();
219
220 //----- material
221 G4double z = 13.;
222 G4double a = 26.98*g/mole;
223 G4double density = 2.7*g/cm3;
224 G4Material myMaterial("Aluminium", z, a, density);
225
226 //----- Vis Attributes
227 G4VisAttributes* pVA = new G4VisAttributes (G4Colour(0,1,1));
228
229 //----- Solid
230 G4Trd *trd = new G4Trd ("Trd", 1.0 , 0.5, 1.0, 0.5, 4.0 );
231
232 //----- Logical Volume
233 G4LogicalVolume *trdLog=new G4LogicalVolume( trd, &myMaterial,
234 "trdLog",0,0,0);
235 trdLog -> SetVisAttributes ( pVA );
236
237 //----- physical volume
238 new G4PVPlacement( 0,G4ThreeVector(),
239 "trdPhys",
240 trdLog,
241 theWorld,
242 false,0);
243
244 return theWorld;
245
246}// BuildTrd
247
248
249
250G4VPhysicalVolume* BuildTrap()
251{
252 G4VPhysicalVolume* theWorld = TheWorld ();
253
254 //----- material
255 G4double z = 13.;
256 G4double a = 26.98*g/mole;
257 G4double density = 2.7*g/cm3;
258 G4Material myMaterial("Aluminium", z, a, density);
259
260 //----- Vis Attributes
261 G4VisAttributes* pVA = new G4VisAttributes (G4Colour(1,0,1));
262
263 //----- Solid
264 G4Trap *trap = new G4Trap ("Trap", 2.0, 0.26, 0.0, 1.0, \
265 0.7, 1.2, 0.0, 0.5, 0.35, 0.6, 0.0 );
266
267 //----- Logical Volume
268 G4LogicalVolume *trapLog=new G4LogicalVolume( trap, &myMaterial,
269 "trapLog",0,0,0);
270 trapLog -> SetVisAttributes ( pVA );
271
272 //----- physical volume
273 new G4PVPlacement( 0,G4ThreeVector(),
274 "trapPhys",
275 trapLog,
276 theWorld,
277 false,0);
278
279 return theWorld;
280
281}// BuildTrap
282
283
284G4VPhysicalVolume* BuildSphereFull()
285{
286 G4VPhysicalVolume* theWorld = TheWorld ();
287
288 //----- material
289 G4double z = 13.;
290 G4double a = 26.98*g/mole;
291 G4double density = 2.7*g/cm3;
292 G4Material myMaterial("Aluminium", z, a, density);
293
294 //----- Vis Attributes
295 G4VisAttributes* pVA = new G4VisAttributes (G4Colour(1,1,0));
296
297 //----- Solid
298 G4Sphere *Sphere = new G4Sphere ("Sphere", 1.6, 1.8, 0.0, (twopi), 0.0, (twopi) );
299
300 //----- Logical Volume
301 G4LogicalVolume *SphereLog=new G4LogicalVolume( Sphere, &myMaterial,
302 "SphereLog",0,0,0);
303 SphereLog -> SetVisAttributes ( pVA );
304
305 //----- physical volume
306 new G4PVPlacement( 0,G4ThreeVector(),
307 "SpherePhys",
308 SphereLog,
309 theWorld,
310 false,0);
311
312 return theWorld;
313
314} // BuildSphereFull
315
316
317G4VPhysicalVolume* BuildSphereSeg()
318{
319 G4VPhysicalVolume* theWorld = TheWorld ();
320
321 //----- material
322 G4double z = 13.;
323 G4double a = 26.98*g/mole;
324 G4double density = 2.7*g/cm3;
325 G4Material myMaterial("Aluminium", z, a, density);
326
327 //----- Vis Attributes
328 G4VisAttributes* pVA = new G4VisAttributes (G4Colour(1,1,0));
329
330 //----- Solid
331 G4Sphere *Sphere = new G4Sphere ("Sphere", 1.6, 1.8, 0.0, 6.0, 0.5, 2.5 );
332
333 //----- Logical Volume
334 G4LogicalVolume *SphereLog=new G4LogicalVolume( Sphere, &myMaterial,
335 "SphereLog",0,0,0);
336 SphereLog -> SetVisAttributes ( pVA );
337
338 //----- physical volume
339 new G4PVPlacement( 0,G4ThreeVector(),
340 "SpherePhys",
341 SphereLog,
342 theWorld,
343 false,0);
344
345 return theWorld;
346
347} // BuildSphereSeg
348
349
350
351G4VPhysicalVolume* BuildPara()
352{
353 G4VPhysicalVolume* theWorld = TheWorld ();
354
355 //----- material
356 G4double z = 13.;
357 G4double a = 26.98*g/mole;
358 G4double density = 2.7*g/cm3;
359 G4Material myMaterial("Aluminium", z, a, density);
360
361 //----- Vis Attributes
362 G4VisAttributes* pVA = new G4VisAttributes (G4Colour(1,0,0));
363
364 //----- Solid
365// G4Para *para = new G4Para ("Para", 1.0 ,1.0, 3.0, 0.0, 0.0, 0.0 );
366 G4Para *para = new G4Para ("Para", 1.0 ,1.0, 3.0, pi/6.0, pi/12.0, pi/12.0 );
367
368 //----- Logical Volume
369 G4LogicalVolume *paraLog=new G4LogicalVolume( para, &myMaterial,
370 "ParaLog",0,0,0);
371 paraLog -> SetVisAttributes ( pVA );
372
373 //----- physical volume
374 new G4PVPlacement( 0,G4ThreeVector(),
375 "ParaPhys",
376 paraLog,
377 theWorld,
378 false,0);
379
380 return theWorld;
381
382} // BuildPara
383
384
385
386
387G4VPhysicalVolume* BuildPCon()
388{
389#if defined USE_BREP_SOLID
390 G4VPhysicalVolume* theWorld = TheWorld ();
391
392 //----- material
393 G4double z = 13.;
394 G4double a = 26.98*g/mole;
395 G4double density = 2.7*g/cm3;
396 G4Material myMaterial("Aluminium", z, a, density);
397
398 //----- shape
399 G4double sphi = 1.8 ;
400 G4double dphi = 4.71 ;
401 G4int nz = 4 ;
402 G4double DzArray [] = { -3.0, 1.0, 1.0, 3.0 };
403 G4double RminArray [] = { 1.0, 0.5, 1.5, 1.0 };
404 G4double RmaxArray [] = { 1.5, 1.0, 2.0, 1.5 };
405
406 //----- Vis Attributes
407 G4VisAttributes* pVA = new G4VisAttributes (G4Colour(0,1,0));
408
409 //----- Solid
410 G4BREPSolidPCone *pcon = new G4BREPSolidPCone ("Pcon", sphi , dphi, nz, DzArray[0], \
411 DzArray, RminArray, RmaxArray );
412
413 //----- Logical Volume
414 G4LogicalVolume *pconLog=new G4LogicalVolume( pcon, &myMaterial,
415 "PconLog",0,0,0);
416 pconLog -> SetVisAttributes ( pVA );
417
418 //----- physical volume
419 new G4PVPlacement( 0,G4ThreeVector(),
420 "PconPhys",
421 pconLog,
422 theWorld,
423 false,0);
424
425 return theWorld;
426
427#else
428 return NULL ;
429#endif
430
431} // BuildPCon
432
433
434G4VPhysicalVolume* BuildPGon()
435{
436#if defined USE_BREP_SOLID
437 G4VPhysicalVolume* theWorld = TheWorld ();
438
439 //----- material
440 G4double z = 13.;
441 G4double a = 26.98*g/mole;
442 G4double density = 2.7*g/cm3;
443 G4Material myMaterial("Aluminium", z, a, density);
444
445 //----- shape
446 G4double sphi = 1.8 ;
447 G4double dphi = 4.71 ;
448 G4int nside = 5 ;
449 G4int nz = 4 ;
450 G4double DzArray [] = { -3.0, 1.0, 1.0, 3.0 };
451 G4double RminArray [] = { 1.0, 0.5, 1.5, 1.0 };
452 G4double RmaxArray [] = { 1.5, 1.0, 2.0, 1.5 };
453
454 //----- Vis Attributes
455 G4VisAttributes* pVA = new G4VisAttributes (G4Colour(1,0,0));
456
457 //----- Solid
458 G4BREPSolidPolyhedra *pgon = new G4BREPSolidPolyhedra ("Pcon", sphi , dphi, nside, nz, \
459 DzArray[0], \
460 DzArray, RminArray, RmaxArray );
461
462 //----- Logical Volume
463 G4LogicalVolume *pgonLog=new G4LogicalVolume( pgon, &myMaterial,
464 "PgonLog",0,0,0);
465 pgonLog -> SetVisAttributes ( pVA );
466
467 //----- physical volume
468 new G4PVPlacement( 0,G4ThreeVector(),
469 "PgonPhys",
470 pgonLog,
471 theWorld,
472 false,0);
473
474 return theWorld;
475#else
476 return NULL ;
477#endif
478} // BuildPGon
479
480G4VPhysicalVolume* BuildForcedWireframeBox()
481{
482 G4VPhysicalVolume* theWorld = TheWorld ();
483
484 //----- material
485 G4double z = 13.;
486 G4double a = 26.98*g/mole;
487 G4double density = 2.7*g/cm3;
488 G4Material myMaterial("Aluminium", z, a, density);
489
490 //----- Vis Attributes
491 G4VisAttributes* pVA = new G4VisAttributes (G4Colour(1,0,0)); // for box
492 pVA->SetForceWireframe( true );
493 G4VisAttributes* pVA2 = new G4VisAttributes (G4Colour(0,1,1)); // for tubs
494
495 //----- Solid
496 G4Box *box = new G4Box ("Box", 2 ,4, 6 );
497 G4Tubs *tubs = new G4Tubs ("Tubs", 1.0 , 1.5, 2.0 , 1.5, 4.5 );
498
499 //----- Logical Volume
500 G4LogicalVolume *boxLog=new G4LogicalVolume( box, &myMaterial,
501 "BoxLog",0,0,0);
502 boxLog -> SetVisAttributes ( pVA );
503 G4LogicalVolume *tubsLog=new G4LogicalVolume( tubs, &myMaterial,
504 "tubsLog",0,0,0);
505 tubsLog -> SetVisAttributes ( pVA2 );
506
507 //----- physical volume
508 G4PVPlacement *boxPhys=new G4PVPlacement( 0,G4ThreeVector(),
509 "BoxPhys",
510 boxLog,
511 theWorld,
512 false,0);
513 new G4PVPlacement( 0,G4ThreeVector(),
514 "tubsPhys",
515 tubsLog,
516 boxPhys ,false,0);
517 return theWorld;
518
519} // G4VPhysicalVolume* BuidlForcedWireFrameBox()
Note: See TracBrowser for help on using the repository browser.