source: trunk/source/visualization/test/src/BuildHouse.cc@ 1231

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

remise a jour

File size: 8.7 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: BuildHouse.cc,v 1.3 2006/06/29 21:34:16 gunter Exp $
28// GEANT4 tag $Name: $
29//
30//
31
32#include "BuildHouse.hh"
33
34#include "G4Material.hh"
35#include "G4Box.hh"
36#include "G4SubtractionSolid.hh"
37#include "G4UnionSolid.hh"
38#include "G4PVPlacement.hh"
39#include "G4LogicalVolume.hh"
40#include "G4VisAttributes.hh"
41
42G4VPhysicalVolume* BuildHouse()
43{
44 // Let's have x = east, y = up and z = south.
45 const double worldx = 5 * m; // World half-length east-west.
46 const double worldy = 5 * m; // World half-length vertical.
47 const double worldz = 5 * m; // World half-length north-south.
48 const double roomx = 2 * m; // Inner room half-length east-west.
49 const double roomy = 1 * m; // Inner room half-length vertical.
50 const double roomz = 2 * m; // Inner room half-length north-south.
51 const double wall = 10 * cm; // Wall thickness.
52
53 // For other things, lengths, widths and/or depths are horizontal,
54 // heights are vertical.
55 const double wx = 1 * m; // Window half-length.
56 const double wy = 50 * cm; // Window half-height.
57 const double wz = wall + 1 * mm; // Window half-depth, larger than
58 // wall for safe subtraction.
59 const double ledgeProtrusion = 5 * cm;
60 const double lx = 1.1 * m; // Window ledge half-length.
61 const double ly = 2.5 * cm; // Window ledge half-height.
62 const double lz = wall + ledgeProtrusion; // Window ledge
63 // half-depth (protrudes
64 // into room and out into
65 // world).
66 //const double ttx; // Table top half-length.
67 //const double tty; // Table top half-height.
68 //const double ttz; // Table top half-width.
69 //const double tlx; // Table leg half-width.
70 //const double tly; // Table leg half-height (normally "length" of leg).
71 //const double tlz; // Table leg half-width.
72
73 const G4ThreeVector nullVector;
74
75 G4Material* air =
76 new G4Material
77 ("Air", 7., 14.4 * g/mole, 0.001 * g/cm3);
78 G4Material* wallMaterial =
79 new G4Material
80 ("Brick", 20., 40. * g/mole, 3 * g/cm3);
81 G4Material* tableMaterial =
82 new G4Material
83 ("Wood", 7., 14. * g/mole, 0.9 * g/cm3);
84
85 // World...
86 G4Box * world =
87 new G4Box
88 ("World", worldx, worldy, worldz);
89 G4LogicalVolume * world_log =
90 new G4LogicalVolume
91 (world, air, "World", 0, 0, 0);
92 world_log -> SetVisAttributes (G4VisAttributes::Invisible);
93 G4VPhysicalVolume * world_phys =
94 new G4PVPlacement
95 (0, G4ThreeVector(), "worldP", world_log, 0, false, 0);
96
97 // Window hole...
98 G4VSolid* windowHole =
99 new G4Box
100 ("Window hole", wx, wy, wz);
101
102 // Make a house out of walls...
103
104 // North/south wall...
105 G4VSolid* wallNS =
106 new G4Box
107 ("North/south wall", roomx + wall, roomy, wall / 2.);
108 G4VSolid* wallNSWithWindowHole =
109 new G4SubtractionSolid
110 ("North/south wall with window hole", wallNS, windowHole,
111 0, G4ThreeVector());
112
113 // East/west wall...
114 G4VSolid* wallEW =
115 new G4Box
116 ("North/south wall", roomx, roomy, wall / 2.);
117 G4VSolid* wallEWWithWindowHole =
118 new G4SubtractionSolid
119 ("North/south wall with window hole", wallEW, windowHole,
120 0, G4ThreeVector());
121
122 // North wall...
123 G4LogicalVolume * northWall_log =
124 new G4LogicalVolume
125 (wallNSWithWindowHole,
126 //(wallNS, // if window not required.
127 wallMaterial, "North wall", 0, 0, 0);
128 // G4VPhysicalVolume* northWall_phys =
129 new G4PVPlacement
130 (0, G4ThreeVector(0., 0., -(roomz + wall / 2.)),
131 northWall_log, "North wall",
132 world_log, false, 0);
133
134 // South wall...
135 G4LogicalVolume * southWall_log =
136 new G4LogicalVolume
137 (wallNSWithWindowHole,
138 //(wallNS, // if window not required.
139 wallMaterial, "South wall", 0, 0, 0);
140 G4RotationMatrix* rmS = new G4RotationMatrix;
141 rmS->rotateY(180*deg);
142 // G4VPhysicalVolume* southWall_phys =
143 new G4PVPlacement
144 (rmS, G4ThreeVector(0., 0., roomz + wall / 2.),
145 southWall_log, "South wall",
146 world_log, false, 0);
147
148 // East wall...
149 G4LogicalVolume * eastWall_log =
150 new G4LogicalVolume
151 (wallEWWithWindowHole,
152 //(wallEW, // if window not required.
153 wallMaterial, "East wall", 0, 0, 0);
154 G4RotationMatrix* rmE = new G4RotationMatrix;
155 rmE->rotateY(-90*deg);
156 // G4VPhysicalVolume* eastWall_phys =
157 new G4PVPlacement
158 (rmE, G4ThreeVector(roomz + wall / 2., 0., 0.),
159 eastWall_log, "East wall",
160 world_log, false, 0);
161
162 // West wall...
163 G4LogicalVolume * westWall_log =
164 new G4LogicalVolume
165 (wallEWWithWindowHole,
166 //(wallEW, // if window not required.
167 wallMaterial, "West wall", 0, 0, 0);
168 G4RotationMatrix* rmW = new G4RotationMatrix;
169 rmW->rotateY(90*deg);
170 // G4VPhysicalVolume* westWall_phys =
171 new G4PVPlacement
172 (rmW, G4ThreeVector(-(roomz + wall / 2.), 0., 0.),
173 westWall_log, "West wall",
174 world_log, false, 0);
175
176 /*
177 // House with holes for windows
178 G4VSolid* houseOuter =
179 new G4Box
180 ("House outer", roomx + wall, roomy + wall, roomz + wall);
181 G4VSolid* windowHole =
182 new G4Box
183 ("Window hole", wx, wy, wz);
184 // East window...
185 G4RotationMatrix* rm1 = new G4RotationMatrix;
186 rm1->rotateY(-90*deg);
187 G4VSolid* houseOuterWithWindowHoleE =
188 new G4SubtractionSolid
189 ("House with window E", houseOuter, windowHole,
190 rm1, G4ThreeVector(roomx + wall / 2., 0., 0.));
191 // North window...
192 G4VSolid* houseOuterWithWindowHoleEN =
193 new G4SubtractionSolid
194 ("House with windows E and N", houseOuterWithWindowHoleE, windowHole,
195 0, G4ThreeVector(0., 0., -(roomz + wall / 2.)));
196 // Other windows...
197 // Solid house...
198 G4LogicalVolume * houseOuterWithWindowHoles_log =
199 new G4LogicalVolume
200 (houseOuterWithWindowHoleEN,
201 wallMaterial, "House with window holes", 0, 0, 0);
202 // G4VPhysicalVolume* houseOuterWithWindowHoles_phys =
203 new G4PVPlacement
204 (0, G4ThreeVector(), houseOuterWithWindowHoles_log, "House",
205 world_log, false, 0);
206 // Inner...
207 G4VSolid* houseInner =
208 new G4Box
209 ("House inner", roomx, roomy, roomz);
210 // Room...
211 G4LogicalVolume * room_log =
212 new G4LogicalVolume
213 (houseInner, air, "Room", 0, 0, 0);
214 room_log -> SetVisAttributes (G4VisAttributes::Invisible);
215 // G4VPhysicalVolume* room_phys =
216 new G4PVPlacement
217 (0, G4ThreeVector(), room_log, "Room",
218 houseOuterWithWindowHoles_log, false, 0);
219 */
220
221 /*
222 G4VSolid* houseInner =
223 new G4Box
224 ("House inner", roomx, roomy, roomz);
225
226 G4VSolid* walls
227 new G4SubtractionSolid
228 ("Walls", houseOuter, houseInner, 0, nullVector);
229
230 G4VSolid* windowHole =
231 new G4Box
232 ("Window hole", wx, wy, wz);
233
234 G4RotationMatrix* rm1 = new G4RotationMatrix;
235 rm1->rotateZ(90*deg);
236 G4VSolid* wallsWithWindowHole1 =
237 new G4SubtractionSolid
238 ("Walls with windows", walls, windowHole, rm1, roomx + wall / 2.);
239
240 G4LogicalVolume * wallsWithWindowHole1_log =
241 new G4LogicalVolume
242 //(wallsWithWindowHole1, wallMaterial, "Walls with windows", 0, 0, 0);
243 (walls, wallMaterial, "Walls", 0, 0, 0);
244
245 G4VPhysicalVolume* house =
246 new G4PVPlacement
247 (0, G4ThreeVector(), "House", wallsWithWindowHole1_log, world, false, 0);
248 */
249
250 return world_phys;
251}
Note: See TracBrowser for help on using the repository browser.