source: trunk/environments/g4py/site-modules/geometries/ezgeom/G4EzWorld.cc @ 1337

Last change on this file since 1337 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 4.8 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// $Id: G4EzWorld.cc,v 1.1 2008/12/01 07:07:34 kmura Exp $
27// $Name: geant4-09-04-beta-01 $
28// ====================================================================
29//   G4EzWorld.cc
30//
31//                                         2005 Q
32// ====================================================================
33#include "G4EzWorld.hh"
34#include "G4Element.hh"
35#include "G4Material.hh"
36#include "G4Box.hh"
37#include "G4LogicalVolume.hh"
38#include "G4PVPlacement.hh"
39#include "G4VisAttributes.hh"
40#include "G4RunManager.hh"
41
42G4VPhysicalVolume* G4EzWorld::world= G4EzWorld::CreateWorld();
43
44// ====================================================================
45//
46// class description
47//
48// ====================================================================
49
50//////////////////////
51G4EzWorld::G4EzWorld()
52//////////////////////
53{
54}
55
56///////////////////////
57G4EzWorld::~G4EzWorld()
58///////////////////////
59{
60  world= 0;
61}
62
63
64//////////////////////////////////////////////////////////
65G4VPhysicalVolume* G4EzWorld::CreateWorld
66                   (G4double dx, G4double dy, G4double dz)
67//////////////////////////////////////////////////////////
68{
69  // default matetial is "vacuum"
70  G4Material* vacuum= G4Material::GetMaterial("_Vacuum", false);
71
72  if(vacuum==0) {
73    G4Element* elN= new G4Element("_N", "",  7.,  14.00674*g/mole);
74    G4Element* elO= new G4Element("_O", "",  8.,  15.9994*g/mole);
75
76    vacuum= new G4Material("_Vacuum", universe_mean_density, 2);
77    vacuum-> AddElement(elN,  0.7);
78    vacuum-> AddElement(elO,  0.3);
79  }
80
81  G4Box* sdworld= new G4Box("world", dx/2., dy/2., dz/2.);
82  G4LogicalVolume* lvworld= new G4LogicalVolume(sdworld, vacuum, "word");
83  G4PVPlacement* aworld= new G4PVPlacement(0, G4ThreeVector(), "world",
84                                           lvworld, 0, false, 0);
85 
86  // vis. attributes
87  G4VisAttributes* vaworld= new G4VisAttributes(G4Color(1.,1.,1.));
88  vaworld-> SetForceWireframe(true);
89  lvworld-> SetVisAttributes(vaworld);
90
91  return aworld;
92
93}
94
95
96////////////////////////////////////////////////////////////
97void G4EzWorld::Reset(G4double dx, G4double dy, G4double dz)
98////////////////////////////////////////////////////////////
99{
100  delete world;
101  world= CreateWorld(dx, dy, dz);
102
103  G4RunManager* runManager= G4RunManager::GetRunManager();
104  runManager-> DefineWorldVolume(world);
105}
106
107
108/////////////////////////////////////////////////////////////
109void G4EzWorld::Resize(G4double dx, G4double dy, G4double dz)
110/////////////////////////////////////////////////////////////
111{
112  G4Box* box= dynamic_cast<G4Box*>(world-> GetLogicalVolume()-> GetSolid());
113  box-> SetXHalfLength(dx/2.);
114  box-> SetYHalfLength(dy/2.);
115  box-> SetZHalfLength(dz/2.);
116
117  G4RunManager* runManager= G4RunManager::GetRunManager();
118  runManager-> GeometryHasBeenModified();
119}
120
121
122//////////////////////////////////////////////////
123void G4EzWorld::SetMaterial(G4Material* amaterial)
124//////////////////////////////////////////////////
125{
126  world-> GetLogicalVolume()-> SetMaterial(amaterial);
127}
128
129
130//////////////////////////////////////////
131void G4EzWorld::SetVisibility(G4bool qvis)
132//////////////////////////////////////////
133{
134  G4VisAttributes* vaworld= const_cast<G4VisAttributes*>(
135    world-> GetLogicalVolume()-> GetVisAttributes());
136  vaworld-> SetVisibility(qvis);
137}
138
Note: See TracBrowser for help on using the repository browser.