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: testG4ExtrudedSolid.cc,v 1.4 2008/02/27 12:33:20 ivana Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ |
---|
29 | // |
---|
30 | // testG4ExtrudedSolid |
---|
31 | // |
---|
32 | // Test file for class G4ExtrudedSolid. |
---|
33 | // In the functions createSolidN(...), there are defined several |
---|
34 | // test cases of extruded solid. These functions also fill in |
---|
35 | // the vectors with explicitely defined points inside, on the surface |
---|
36 | // and outside the solid. |
---|
37 | // All the test results for the definesd solids and |
---|
38 | // points can be printed via PrintResults() function. |
---|
39 | // The tests are then defined in testXYZ() functions |
---|
40 | // using assert() on the comparison with the expected |
---|
41 | // result value. |
---|
42 | // |
---|
43 | // The functions DistanceToIn, DistanceToOut on surface |
---|
44 | // point do not give always expected values, that's why |
---|
45 | // they are not yet included in the tests with assert. |
---|
46 | // To be added tests for SurfaceNormal(p) function. |
---|
47 | // Ensure asserts are compiled in. |
---|
48 | // |
---|
49 | // Author: |
---|
50 | // Ivana Hrivnacova, IPN Orsay |
---|
51 | // |
---|
52 | |
---|
53 | #include <assert.h> |
---|
54 | #include <cmath> |
---|
55 | #include <vector> |
---|
56 | #include <iomanip> |
---|
57 | |
---|
58 | #include "globals.hh" |
---|
59 | |
---|
60 | #include "G4TwoVector.hh" |
---|
61 | #include "G4ThreeVector.hh" |
---|
62 | #include "G4ExtrudedSolid.hh" |
---|
63 | #include "G4TessellatedSolid.hh" |
---|
64 | #include "G4Box.hh" |
---|
65 | #include "G4UnionSolid.hh" |
---|
66 | #include "G4GeometryTolerance.hh" |
---|
67 | #include "G4Timer.hh" |
---|
68 | |
---|
69 | G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance(); |
---|
70 | |
---|
71 | G4ThreeVector dirx(1,0,0); |
---|
72 | G4ThreeVector diry(0,1,0); |
---|
73 | G4ThreeVector dirz(0,0,1); |
---|
74 | |
---|
75 | //_____________________________________________________________________________ |
---|
76 | G4VSolid* createSolid0(std::vector<G4ThreeVector>& inside_points, |
---|
77 | std::vector<G4ThreeVector>& surface_points, |
---|
78 | std::vector<G4ThreeVector>& outside_points) |
---|
79 | { |
---|
80 | // Create extruded solid with triangular polygon |
---|
81 | // and fill vectors with points |
---|
82 | |
---|
83 | inside_points.push_back(G4ThreeVector( 0.0*cm, 0.0*cm, 0.0*cm)); |
---|
84 | inside_points.push_back(G4ThreeVector( 5.0*cm, 5.0*cm, 5.0*cm)); |
---|
85 | inside_points.push_back(G4ThreeVector(-10.0*cm, -5.0*cm, -15.0*cm)); |
---|
86 | |
---|
87 | surface_points.push_back(G4ThreeVector( 0.0*cm, 0.0*cm, 30.0*cm)); |
---|
88 | surface_points.push_back(G4ThreeVector( 5.0*cm, 5.0*cm, 30.0*cm)); |
---|
89 | surface_points.push_back(G4ThreeVector( -5.0*cm, -5.0*cm, -30.0*cm)); |
---|
90 | surface_points.push_back(G4ThreeVector(-15.0*cm, 0.0*cm, 10.0*cm)); |
---|
91 | surface_points.push_back(G4ThreeVector(+15.0*cm, 0.0*cm, -10.0*cm)); |
---|
92 | |
---|
93 | outside_points.push_back(G4ThreeVector( 0.0*cm, 0.0*cm, 40.0*cm)); |
---|
94 | outside_points.push_back(G4ThreeVector( 5.0*cm, 5.0*cm, 40.0*cm)); |
---|
95 | outside_points.push_back(G4ThreeVector( -5.0*cm, -5.0*cm, -40.0*cm)); |
---|
96 | outside_points.push_back(G4ThreeVector(-20.0*cm, 0.0*cm, 10.0*cm)); |
---|
97 | outside_points.push_back(G4ThreeVector(+20.0*cm, 0.0*cm, -10.0*cm)); |
---|
98 | outside_points.push_back(G4ThreeVector( -5.0*cm,-35.0*cm, -20.0*cm)); |
---|
99 | outside_points.push_back(G4ThreeVector( 5.0*cm, 40.0*cm, 10.0*cm)); |
---|
100 | |
---|
101 | std::vector<G4TwoVector> polygon; |
---|
102 | polygon.push_back(G4TwoVector(-30.*cm, -30.*cm)); |
---|
103 | polygon.push_back(G4TwoVector( 0.*cm, 30.*cm)); |
---|
104 | polygon.push_back(G4TwoVector( 30.*cm, -30.*cm)); |
---|
105 | |
---|
106 | return new G4ExtrudedSolid( |
---|
107 | "extrudedSolid1", polygon, 30.*cm, |
---|
108 | G4TwoVector(), 1.0, G4TwoVector(), 1.0); |
---|
109 | } |
---|
110 | |
---|
111 | //_____________________________________________________________________________ |
---|
112 | G4VSolid* createSolid1(std::vector<G4ThreeVector>& inside_points, |
---|
113 | std::vector<G4ThreeVector>& surface_points, |
---|
114 | std::vector<G4ThreeVector>& outside_points) |
---|
115 | { |
---|
116 | // Create box defined as extruded solid |
---|
117 | // and fill vectors with points |
---|
118 | // The same solid can be defined as G4TessellatedSolid or G4Box, |
---|
119 | // when uncommenting the appropriate lines below. |
---|
120 | |
---|
121 | inside_points.push_back(G4ThreeVector( 0.0*cm, 0.0*cm, 0.0*cm)); |
---|
122 | inside_points.push_back(G4ThreeVector( 5.0*cm, 5.0*cm, 5.0*cm)); |
---|
123 | inside_points.push_back(G4ThreeVector(-10.0*cm, -5.0*cm, -15.0*cm)); |
---|
124 | |
---|
125 | surface_points.push_back(G4ThreeVector( 0.0*cm, 0.0*cm, 30.0*cm)); |
---|
126 | surface_points.push_back(G4ThreeVector( 5.0*cm, 5.0*cm, 30.0*cm)); |
---|
127 | surface_points.push_back(G4ThreeVector( 30.0*cm, 0.0*cm, 0.0*cm)); |
---|
128 | surface_points.push_back(G4ThreeVector( 30.0*cm, -5.0*cm, -5.0*cm)); |
---|
129 | surface_points.push_back(G4ThreeVector( 0.0*cm,-30.0*cm, 0.0*cm)); |
---|
130 | surface_points.push_back(G4ThreeVector( 5.0*cm,-30.0*cm, -5.0*cm)); |
---|
131 | |
---|
132 | outside_points.push_back(G4ThreeVector( 0.0*cm, 0.0*cm, 40.0*cm)); |
---|
133 | outside_points.push_back(G4ThreeVector( 5.0*cm, 5.0*cm, 40.0*cm)); |
---|
134 | outside_points.push_back(G4ThreeVector( -5.0*cm, -5.0*cm, -40.0*cm)); |
---|
135 | outside_points.push_back(G4ThreeVector(-35.0*cm, 0.0*cm, 10.0*cm)); |
---|
136 | outside_points.push_back(G4ThreeVector(+35.0*cm, 0.0*cm, -10.0*cm)); |
---|
137 | outside_points.push_back(G4ThreeVector( -5.0*cm,-40.0*cm, -20.0*cm)); |
---|
138 | outside_points.push_back(G4ThreeVector( 5.0*cm, 40.0*cm, 10.0*cm)); |
---|
139 | |
---|
140 | std::vector<G4TwoVector> polygon; |
---|
141 | polygon.push_back(G4TwoVector(-30.*cm, -30.*cm)); |
---|
142 | polygon.push_back(G4TwoVector(-30.*cm, 30.*cm)); |
---|
143 | polygon.push_back(G4TwoVector( 30.*cm, 30.*cm)); |
---|
144 | polygon.push_back(G4TwoVector( 30.*cm, -30.*cm)); |
---|
145 | |
---|
146 | G4ExtrudedSolid* extruded |
---|
147 | = new G4ExtrudedSolid( |
---|
148 | "extrudedSolid1", polygon, 30.*cm, |
---|
149 | G4TwoVector(), 1.0, G4TwoVector(), 1.0); |
---|
150 | |
---|
151 | //G4TessellatedSolid* tessellated |
---|
152 | // = new G4TessellatedSolid(*extruded); |
---|
153 | //return tessellated; |
---|
154 | |
---|
155 | //G4Box* box |
---|
156 | // = new G4Box("box", 30.*cm, 30*cm, 30*cm); |
---|
157 | // return box; |
---|
158 | |
---|
159 | return extruded; |
---|
160 | } |
---|
161 | |
---|
162 | //_____________________________________________________________________________ |
---|
163 | G4VSolid* createSolid2(std::vector<G4ThreeVector>& inside_points, |
---|
164 | std::vector<G4ThreeVector>& surface_points, |
---|
165 | std::vector<G4ThreeVector>& outside_points) |
---|
166 | { |
---|
167 | // Create extruded solid with concave polygon with 2 z- sections |
---|
168 | // and fill vectors with points |
---|
169 | |
---|
170 | inside_points.push_back(G4ThreeVector( 10.0*cm, 25.0*cm, 0.0*cm)); |
---|
171 | inside_points.push_back(G4ThreeVector(-50.0*cm, 10.0*cm, -20.0*cm)); |
---|
172 | inside_points.push_back(G4ThreeVector( 15.0*cm,-15.0*cm, 20.0*cm)); |
---|
173 | |
---|
174 | surface_points.push_back(G4ThreeVector( 20.0*cm, 30.0*cm, -25.0*cm)); |
---|
175 | surface_points.push_back(G4ThreeVector( 0.0*cm, 10.0*cm, 25.0*cm)); |
---|
176 | surface_points.push_back(G4ThreeVector(-40.0*cm, 0.0*cm, 0.0*cm)); |
---|
177 | surface_points.push_back(G4ThreeVector( 20.0*cm, -5.0*cm, 0.0*cm)); |
---|
178 | surface_points.push_back(G4ThreeVector( 20.0*cm, 5.0*cm, 0.0*cm)); |
---|
179 | |
---|
180 | outside_points.push_back(G4ThreeVector( 0.0*cm, 0.0*cm, 30.0*cm)); |
---|
181 | outside_points.push_back(G4ThreeVector( 10.0*cm, 5.0*cm, -40.0*cm)); |
---|
182 | outside_points.push_back(G4ThreeVector( 0.0*cm, 0.0*cm, 0.0*cm)); |
---|
183 | outside_points.push_back(G4ThreeVector(-40.0*cm, 0.0*cm, 10.0*cm)); |
---|
184 | outside_points.push_back(G4ThreeVector( 40.0*cm, 0.0*cm, -10.0*cm)); |
---|
185 | |
---|
186 | std::vector<G4TwoVector> polygon; |
---|
187 | polygon.push_back(G4TwoVector(-30.*cm, -30.*cm)); |
---|
188 | polygon.push_back(G4TwoVector(-30.*cm, 30.*cm)); |
---|
189 | polygon.push_back(G4TwoVector( 30.*cm, 30.*cm)); |
---|
190 | polygon.push_back(G4TwoVector( 30.*cm, -30.*cm)); |
---|
191 | polygon.push_back(G4TwoVector( 15.*cm, -30.*cm)); |
---|
192 | polygon.push_back(G4TwoVector( 15.*cm, 15.*cm)); |
---|
193 | polygon.push_back(G4TwoVector(-15.*cm, 15.*cm)); |
---|
194 | polygon.push_back(G4TwoVector(-15.*cm, -30.*cm)); |
---|
195 | |
---|
196 | return new G4ExtrudedSolid( |
---|
197 | "extrudedSolid3", polygon, 25.*cm, |
---|
198 | G4TwoVector(-20.*cm, 10.*cm), 1.5, G4TwoVector(), 0.5); |
---|
199 | } |
---|
200 | |
---|
201 | |
---|
202 | //_____________________________________________________________________________ |
---|
203 | G4VSolid* createSolid3(std::vector<G4ThreeVector>& inside_points, |
---|
204 | std::vector<G4ThreeVector>& surface_points, |
---|
205 | std::vector<G4ThreeVector>& outside_points) |
---|
206 | { |
---|
207 | // Extruded solid with the same polygon as solid3 bit with 4 z-sections |
---|
208 | |
---|
209 | inside_points.push_back(G4ThreeVector(-50.0*cm, 10.0*cm, -35.0*cm)); |
---|
210 | inside_points.push_back(G4ThreeVector( 10.0*cm, 10.0*cm, 0.0*cm)); |
---|
211 | inside_points.push_back(G4ThreeVector(-15.0*cm, 0.0*cm, 12.0*cm)); |
---|
212 | inside_points.push_back(G4ThreeVector( 35.0*cm, -5.0*cm, 30.0*cm)); |
---|
213 | |
---|
214 | surface_points.push_back(G4ThreeVector(-50.0*cm, 10.0*cm, -40.0*cm)); |
---|
215 | surface_points.push_back(G4ThreeVector( 15.0*cm, 0.0*cm, 10.0*cm)); |
---|
216 | surface_points.push_back(G4ThreeVector( -5.0*cm, 10.5*cm, 15.0*cm)); |
---|
217 | surface_points.push_back(G4ThreeVector( 45.0*cm, 33.5*cm, 40.0*cm)); |
---|
218 | |
---|
219 | outside_points.push_back(G4ThreeVector(-50.0*cm, 10.0*cm, -50.0*cm)); |
---|
220 | outside_points.push_back(G4ThreeVector( 25.0*cm, 0.0*cm, 10.0*cm)); |
---|
221 | outside_points.push_back(G4ThreeVector( -5.0*cm, 5.0*cm, 15.0*cm)); |
---|
222 | outside_points.push_back(G4ThreeVector( 45.0*cm, 40.0*cm, 45.0*cm)); |
---|
223 | |
---|
224 | std::vector<G4TwoVector> polygon; |
---|
225 | polygon.push_back(G4TwoVector(-30.*cm, -30.*cm)); |
---|
226 | polygon.push_back(G4TwoVector(-30.*cm, 30.*cm)); |
---|
227 | polygon.push_back(G4TwoVector( 30.*cm, 30.*cm)); |
---|
228 | polygon.push_back(G4TwoVector( 30.*cm, -30.*cm)); |
---|
229 | polygon.push_back(G4TwoVector( 15.*cm, -30.*cm)); |
---|
230 | polygon.push_back(G4TwoVector( 15.*cm, 15.*cm)); |
---|
231 | polygon.push_back(G4TwoVector(-15.*cm, 15.*cm)); |
---|
232 | polygon.push_back(G4TwoVector(-15.*cm, -30.*cm)); |
---|
233 | |
---|
234 | std::vector<G4ExtrudedSolid::ZSection> zsections; |
---|
235 | zsections.push_back(G4ExtrudedSolid::ZSection(-40.*cm, G4TwoVector(-20.*cm, 10.*cm), 1.5)); |
---|
236 | zsections.push_back(G4ExtrudedSolid::ZSection( 10.*cm, G4TwoVector( 0.*cm, 0.*cm), 0.5)); |
---|
237 | zsections.push_back(G4ExtrudedSolid::ZSection( 15.*cm, G4TwoVector( 0.*cm, 0.*cm), 0.7)); |
---|
238 | zsections.push_back(G4ExtrudedSolid::ZSection( 40.*cm, G4TwoVector( 20.*cm, 20.*cm), 0.9)); |
---|
239 | |
---|
240 | G4ExtrudedSolid* extruded |
---|
241 | = new G4ExtrudedSolid("extrudedSolid4", polygon, zsections); |
---|
242 | |
---|
243 | return extruded; |
---|
244 | |
---|
245 | G4TessellatedSolid* tessellated |
---|
246 | = new G4TessellatedSolid(*extruded); |
---|
247 | return tessellated; |
---|
248 | } |
---|
249 | |
---|
250 | |
---|
251 | //_____________________________________________________________________________ |
---|
252 | G4VSolid* createSolid4(std::vector<G4ThreeVector>& /*inside_points*/, |
---|
253 | std::vector<G4ThreeVector>& /*surface_points*/, |
---|
254 | std::vector<G4ThreeVector>& /*outside_points*/) |
---|
255 | { |
---|
256 | // Extruded solid with 4 z-sections, with 2 sections with the same z position |
---|
257 | // defined via union solid |
---|
258 | |
---|
259 | std::vector<G4TwoVector> polygon; |
---|
260 | polygon.push_back(G4TwoVector(-30.*cm, -30.*cm)); |
---|
261 | polygon.push_back(G4TwoVector(-30.*cm, 30.*cm)); |
---|
262 | polygon.push_back(G4TwoVector( 30.*cm, 30.*cm)); |
---|
263 | polygon.push_back(G4TwoVector( 30.*cm, -30.*cm)); |
---|
264 | polygon.push_back(G4TwoVector( 15.*cm, -30.*cm)); |
---|
265 | polygon.push_back(G4TwoVector( 15.*cm, 15.*cm)); |
---|
266 | polygon.push_back(G4TwoVector(-15.*cm, 15.*cm)); |
---|
267 | polygon.push_back(G4TwoVector(-15.*cm, -30.*cm)); |
---|
268 | |
---|
269 | G4ExtrudedSolid* xtruS1 |
---|
270 | = new G4ExtrudedSolid("XtruS1", polygon, 25.*cm, |
---|
271 | G4TwoVector(-20.*cm, 10.*cm), 1.5, G4TwoVector(), 0.5); |
---|
272 | |
---|
273 | G4ExtrudedSolid* xtruS2 |
---|
274 | = new G4ExtrudedSolid("XtruS2", polygon, 15.*cm, |
---|
275 | G4TwoVector(), 0.7, G4TwoVector(20.*cm, 20.*cm), 0.9); |
---|
276 | |
---|
277 | |
---|
278 | return new G4UnionSolid( |
---|
279 | "unionExtrudedSolid", xtruS1, xtruS2, |
---|
280 | 0, G4ThreeVector(0., 0., 40.*cm)); |
---|
281 | } |
---|
282 | |
---|
283 | |
---|
284 | //_____________________________________________________________________________ |
---|
285 | G4VSolid* createSolid(G4int testCase, |
---|
286 | std::vector<G4ThreeVector>& inside_points, |
---|
287 | std::vector<G4ThreeVector>& surface_points, |
---|
288 | std::vector<G4ThreeVector>& outside_points) |
---|
289 | { |
---|
290 | // Create selected test solid and fill vectors with points |
---|
291 | |
---|
292 | switch ( testCase ) { |
---|
293 | case 0: return createSolid0(inside_points, surface_points, outside_points); |
---|
294 | case 1: return createSolid1(inside_points, surface_points, outside_points); |
---|
295 | case 2: return createSolid2(inside_points, surface_points, outside_points); |
---|
296 | case 3: return createSolid3(inside_points, surface_points, outside_points); |
---|
297 | case 4: return createSolid4(inside_points, surface_points, outside_points); |
---|
298 | default: return 0; |
---|
299 | } |
---|
300 | } |
---|
301 | |
---|
302 | //_____________________________________________________________________________ |
---|
303 | void printResults(G4int testCase) |
---|
304 | { |
---|
305 | |
---|
306 | std::vector<G4ThreeVector> inside_points; |
---|
307 | std::vector<G4ThreeVector> surface_points; |
---|
308 | std::vector<G4ThreeVector> outside_points; |
---|
309 | G4VSolid* solid = createSolid(testCase, inside_points, surface_points, outside_points); |
---|
310 | |
---|
311 | // Set precision |
---|
312 | G4cout << std::setprecision(20) << G4endl; |
---|
313 | |
---|
314 | // |
---|
315 | // Test Inside |
---|
316 | // |
---|
317 | |
---|
318 | for (G4int i=0; i<G4int(inside_points.size()); ++i) { |
---|
319 | G4cout << i << "th inside_point Inside(p): " |
---|
320 | << solid->Inside(inside_points[i]) << G4endl; |
---|
321 | } |
---|
322 | G4cout << G4endl; |
---|
323 | |
---|
324 | for (G4int i=0; i<G4int(surface_points.size()); ++i) { |
---|
325 | G4cout << i << "th surface_point Inside(p): " |
---|
326 | << solid->Inside(surface_points[i]) << G4endl; |
---|
327 | } |
---|
328 | G4cout << G4endl; |
---|
329 | |
---|
330 | for (G4int i=0; i<G4int(outside_points.size()); ++i) { |
---|
331 | G4cout << i << "th outside_point Inside(p): " |
---|
332 | << solid->Inside(outside_points[i]) << G4endl; |
---|
333 | } |
---|
334 | G4cout << G4endl; |
---|
335 | |
---|
336 | // |
---|
337 | // Test DistanceToIn(p, v) |
---|
338 | // |
---|
339 | |
---|
340 | for (G4int i=0; i<G4int(surface_points.size()); ++i) { |
---|
341 | G4cout << i << "th surface_point DistanceToIn(p, vx) " |
---|
342 | << solid->DistanceToIn(surface_points[i], dirx) << G4endl; |
---|
343 | G4cout << i << "th surface_point DistanceToIn(p, -vx) " |
---|
344 | << solid->DistanceToIn(surface_points[i], -dirx) << G4endl; |
---|
345 | G4cout << i << "th surface_point DistanceToIn(p, vy) " |
---|
346 | << solid->DistanceToIn(surface_points[i], diry) << G4endl; |
---|
347 | G4cout << i << "th surface_point DistanceToIn(p, -vy) " |
---|
348 | << solid->DistanceToIn(surface_points[i], -diry) << G4endl; |
---|
349 | G4cout << i << "th surface_point DistanceToIn(p, vz) " |
---|
350 | << solid->DistanceToIn(surface_points[i], dirz) << G4endl; |
---|
351 | G4cout << i << "th surface_point DistanceToIn(p, -vz) " |
---|
352 | << solid->DistanceToIn(surface_points[i], -dirz) << G4endl; |
---|
353 | } |
---|
354 | G4cout << G4endl; |
---|
355 | |
---|
356 | for (G4int i=0; i<G4int(outside_points.size()); ++i) { |
---|
357 | G4cout << i << "th outside_point DistanceToIn(p, vx) " |
---|
358 | << solid->DistanceToIn(outside_points[i], dirx) << G4endl; |
---|
359 | G4cout << i << "th outside_point DistanceToIn(p, -vx) " |
---|
360 | << solid->DistanceToIn(outside_points[i], -dirx) << G4endl; |
---|
361 | G4cout << i << "th outside_point DistanceToIn(p, vy) " |
---|
362 | << solid->DistanceToIn(outside_points[i], diry) << G4endl; |
---|
363 | G4cout << i << "th outside_point DistanceToIn(p, -vy) " |
---|
364 | << solid->DistanceToIn(outside_points[i], -diry) << G4endl; |
---|
365 | G4cout << i << "th outside_point DistanceToIn(p, vz) " |
---|
366 | << solid->DistanceToIn(outside_points[i], dirz) << G4endl; |
---|
367 | G4cout << i << "th outside_point DistanceToIn(p, -vz) " |
---|
368 | << solid->DistanceToIn(outside_points[i], -dirz) << G4endl; |
---|
369 | } |
---|
370 | G4cout << G4endl; |
---|
371 | |
---|
372 | // |
---|
373 | // Test DistanceToOut(p, v) function. |
---|
374 | // |
---|
375 | |
---|
376 | for (G4int i=0; i<G4int(surface_points.size()); ++i) { |
---|
377 | G4cout << i << "th surface_point DistanceToOut(p, vx) " |
---|
378 | << solid->DistanceToOut(surface_points[i], dirx, false, 0, 0) << G4endl; |
---|
379 | G4cout << i << "th surface_point DistanceToOut(p, -vx) " |
---|
380 | << solid->DistanceToOut(surface_points[i], -dirx, false, 0, 0) << G4endl; |
---|
381 | G4cout << i << "th surface_point DistanceToOut(p, vy) " |
---|
382 | << solid->DistanceToOut(surface_points[i], diry, false, 0, 0) << G4endl; |
---|
383 | G4cout << i << "th surface_point DistanceToOut(p, -vy) " |
---|
384 | << solid->DistanceToOut(surface_points[i], -diry, false, 0, 0) << G4endl; |
---|
385 | G4cout << i << "th surface_point DistanceToOut(p, vz) " |
---|
386 | << solid->DistanceToOut(surface_points[i], dirz, false, 0, 0) << G4endl; |
---|
387 | G4cout << i << "th surface_point DistanceToOut(p, -vz) " |
---|
388 | << solid->DistanceToOut(surface_points[i], -dirz, false, 0, 0) << G4endl; |
---|
389 | } |
---|
390 | G4cout << G4endl; |
---|
391 | |
---|
392 | for (G4int i=0; i<G4int(inside_points.size()); ++i) { |
---|
393 | G4cout << i << "th inside_point DistanceToOut(p, vx) " |
---|
394 | << solid->DistanceToOut(inside_points[i], dirx, false, 0, 0) << G4endl; |
---|
395 | G4cout << i << "th inside_point DistanceToOut(p, -vx) " |
---|
396 | << solid->DistanceToOut(inside_points[i], -dirx, false, 0, 0) << G4endl; |
---|
397 | G4cout << i << "th inside_point DistanceToOut(p, vy) " |
---|
398 | << solid->DistanceToOut(inside_points[i], diry, false, 0, 0) << G4endl; |
---|
399 | G4cout << i << "th inside_point DistanceToOut(p, -vy) " |
---|
400 | << solid->DistanceToOut(inside_points[i], -diry, false, 0, 0) << G4endl; |
---|
401 | G4cout << i << "th inside_point DistanceToOut(p, vz) " |
---|
402 | << solid->DistanceToOut(inside_points[i], dirz, false, 0, 0) << G4endl; |
---|
403 | G4cout << i << "th inside_point DistanceToOut(p, -vz) " |
---|
404 | << solid->DistanceToOut(inside_points[i], -dirz, false, 0, 0) << G4endl; |
---|
405 | } |
---|
406 | G4cout << G4endl; |
---|
407 | |
---|
408 | // |
---|
409 | // Test surface area |
---|
410 | // |
---|
411 | G4cout << "Surface: " << solid->GetSurfaceArea() << G4endl; |
---|
412 | G4cout << G4endl; |
---|
413 | |
---|
414 | // |
---|
415 | // Test volume |
---|
416 | // |
---|
417 | G4int ntrial = 10; |
---|
418 | G4double sum = 0; |
---|
419 | G4double min = DBL_MAX; |
---|
420 | G4double max = -DBL_MAX; |
---|
421 | |
---|
422 | G4cout << "Evaluating volume ..." << G4endl; |
---|
423 | G4Timer time; |
---|
424 | time.Start(); |
---|
425 | for (G4int i=0; i<ntrial; ++i ) { |
---|
426 | G4VSolid* solid0 = createSolid(testCase, inside_points, surface_points, outside_points); |
---|
427 | G4double value = solid0->GetCubicVolume(); |
---|
428 | sum += value; |
---|
429 | if ( value < min ) min = value; |
---|
430 | if ( value > max ) max = value; |
---|
431 | delete solid0; |
---|
432 | } |
---|
433 | time.Stop(); |
---|
434 | G4cout << "Average volume after " << ntrial << " trials: " << sum/ntrial << G4endl; |
---|
435 | G4cout << " in the interval: " << max-min << G4endl; |
---|
436 | G4cout << "Time taken was: " << time.GetRealElapsed() << " seconds. " << G4endl; |
---|
437 | G4cout << G4endl; |
---|
438 | |
---|
439 | delete solid; |
---|
440 | } |
---|
441 | |
---|
442 | |
---|
443 | //_____________________________________________________________________________ |
---|
444 | void testInside(G4int testCase) |
---|
445 | { |
---|
446 | // Test Inside |
---|
447 | |
---|
448 | std::vector<G4ThreeVector> inside_points; |
---|
449 | std::vector<G4ThreeVector> surface_points; |
---|
450 | std::vector<G4ThreeVector> outside_points; |
---|
451 | G4VSolid* solid = createSolid(testCase, inside_points, surface_points, outside_points); |
---|
452 | |
---|
453 | // |
---|
454 | // Test Inside |
---|
455 | // |
---|
456 | |
---|
457 | for (G4int i=0; i<G4int(inside_points.size()); ++i) { |
---|
458 | assert( solid->Inside(inside_points[i]) == kInside ); |
---|
459 | } |
---|
460 | |
---|
461 | for (G4int i=0; i<G4int(surface_points.size()); ++i) { |
---|
462 | assert( solid->Inside(surface_points[i]) == kSurface ); |
---|
463 | } |
---|
464 | |
---|
465 | for (G4int i=0; i<G4int(outside_points.size()); ++i) { |
---|
466 | assert( solid->Inside(outside_points[i]) == kOutside ); |
---|
467 | } |
---|
468 | |
---|
469 | delete solid; |
---|
470 | } |
---|
471 | |
---|
472 | //_____________________________________________________________________________ |
---|
473 | void testDistanceToInPV(G4int testCase) |
---|
474 | { |
---|
475 | // Test DistanceToIn |
---|
476 | |
---|
477 | std::vector<G4ThreeVector> inside_points; |
---|
478 | std::vector<G4ThreeVector> surface_points; |
---|
479 | std::vector<G4ThreeVector> outside_points; |
---|
480 | G4VSolid* solid = createSolid(testCase, inside_points, surface_points, outside_points); |
---|
481 | |
---|
482 | if ( testCase == 0 ) { |
---|
483 | assert( std::fabs(solid->DistanceToIn(outside_points[0], -dirz) - 100.0 )< kCarTolerance ); |
---|
484 | assert( std::fabs(solid->DistanceToIn(outside_points[1], -dirz) - 100.0 )< kCarTolerance ); |
---|
485 | assert( std::fabs(solid->DistanceToIn(outside_points[2], dirz) - 100.0 )< kCarTolerance ); |
---|
486 | assert( std::fabs(solid->DistanceToIn(outside_points[3], dirx) - 50.0 )< kCarTolerance ); |
---|
487 | assert( std::fabs(solid->DistanceToIn(outside_points[4], -dirx) - 50.0 )< kCarTolerance ); |
---|
488 | assert( std::fabs(solid->DistanceToIn(outside_points[4], -diry) - 100.0 )< kCarTolerance ); |
---|
489 | assert( std::fabs(solid->DistanceToIn(outside_points[5], diry) - 50.0 )< kCarTolerance ); |
---|
490 | assert( std::fabs(solid->DistanceToIn(outside_points[6], -diry) - 200.0 )< kCarTolerance ); |
---|
491 | |
---|
492 | // For points on surface we get testDistanceToIn = 9e+99, is it ok ? |
---|
493 | } |
---|
494 | else if ( testCase == 1 ) { |
---|
495 | assert( std::fabs(solid->DistanceToIn(outside_points[0], -dirz) - 100.0 )< kCarTolerance ); |
---|
496 | assert( std::fabs(solid->DistanceToIn(outside_points[1], -dirz) - 100.0 )< kCarTolerance ); |
---|
497 | assert( std::fabs(solid->DistanceToIn(outside_points[2], dirz) - 100.0 )< kCarTolerance ); |
---|
498 | assert( std::fabs(solid->DistanceToIn(outside_points[3], dirx) - 50.0 )< kCarTolerance ); |
---|
499 | assert( std::fabs(solid->DistanceToIn(outside_points[4], -dirx) - 50.0 )< kCarTolerance ); |
---|
500 | assert( std::fabs(solid->DistanceToIn(outside_points[5], diry) - 100.0 )< kCarTolerance ); |
---|
501 | assert( std::fabs(solid->DistanceToIn(outside_points[6], -diry) - 100.0 )< kCarTolerance ); |
---|
502 | |
---|
503 | // Add points on surface |
---|
504 | } |
---|
505 | else if ( testCase == 2 ) { |
---|
506 | //assert( std::fabs(solid->DistanceToIn(outside_points[0], -dirz) - 100.0 )< kCarTolerance ); |
---|
507 | assert( std::fabs(solid->DistanceToIn(outside_points[1], dirz) - 150.0 )< kCarTolerance ); |
---|
508 | assert( std::fabs(solid->DistanceToIn(outside_points[2], dirx) - 50.0 )< kCarTolerance ); |
---|
509 | assert( std::fabs(solid->DistanceToIn(outside_points[2], diry) - 200.0 )< kCarTolerance ); |
---|
510 | assert( std::fabs(solid->DistanceToIn(outside_points[3], dirx) - 100.0 )< kCarTolerance ); |
---|
511 | assert( std::fabs(solid->DistanceToIn(outside_points[3], -dirz) - 100.0 )< kCarTolerance ); |
---|
512 | assert( std::fabs(solid->DistanceToIn(outside_points[4], -dirx) - 180.0 )< kCarTolerance ); |
---|
513 | |
---|
514 | // Add points on surface |
---|
515 | } |
---|
516 | else if ( testCase == 3 ) { |
---|
517 | assert( std::fabs(solid->DistanceToIn(outside_points[0], dirz) - 100.0 )< kCarTolerance ); |
---|
518 | assert( std::fabs(solid->DistanceToIn(outside_points[1], -dirx) - 100.0 )< kCarTolerance ); |
---|
519 | assert( std::fabs(solid->DistanceToIn(outside_points[1], dirz) - 88.4615384615384670045 )< kCarTolerance ); |
---|
520 | assert( std::fabs(solid->DistanceToIn(outside_points[1], -dirz) - 500.0 )< kCarTolerance ); |
---|
521 | assert( std::fabs(solid->DistanceToIn(outside_points[2], dirx) - 155.0 )< kCarTolerance ); |
---|
522 | assert( std::fabs(solid->DistanceToIn(outside_points[2], -dirx) - 55.0 )< kCarTolerance ); |
---|
523 | assert( std::fabs(solid->DistanceToIn(outside_points[2], diry) - 55.0 )< kCarTolerance ); |
---|
524 | assert( std::fabs(solid->DistanceToIn(outside_points[2], dirz) - 80.882352941176478112 )< kCarTolerance ); |
---|
525 | assert( std::fabs(solid->DistanceToIn(outside_points[3], -dirz) - 50.0 )< kCarTolerance ); |
---|
526 | |
---|
527 | // Add points on surface |
---|
528 | } |
---|
529 | |
---|
530 | delete solid; |
---|
531 | } |
---|
532 | |
---|
533 | |
---|
534 | //_____________________________________________________________________________ |
---|
535 | void testDistanceToOutPV(G4int testCase) |
---|
536 | { |
---|
537 | // Test DistanceToOutPV |
---|
538 | |
---|
539 | std::vector<G4ThreeVector> inside_points; |
---|
540 | std::vector<G4ThreeVector> surface_points; |
---|
541 | std::vector<G4ThreeVector> outside_points; |
---|
542 | G4VSolid* solid = createSolid(testCase, inside_points, surface_points, outside_points); |
---|
543 | |
---|
544 | if ( testCase == 0 ) { |
---|
545 | assert( std::fabs(solid->DistanceToOut(inside_points[0], dirx) - 150.0 )< kCarTolerance ); |
---|
546 | assert( std::fabs(solid->DistanceToOut(inside_points[0], -dirx) - 150.0 )< kCarTolerance ); |
---|
547 | assert( std::fabs(solid->DistanceToOut(inside_points[0], diry) - 300.0 )< kCarTolerance ); |
---|
548 | assert( std::fabs(solid->DistanceToOut(inside_points[0], -diry) - 300.0 )< kCarTolerance ); |
---|
549 | assert( std::fabs(solid->DistanceToOut(inside_points[0], dirz) - 300.0 )< kCarTolerance ); |
---|
550 | assert( std::fabs(solid->DistanceToOut(inside_points[0], -dirz) - 300.0 )< kCarTolerance ); |
---|
551 | assert( std::fabs(solid->DistanceToOut(inside_points[1], dirx) - 75.0 )< kCarTolerance ); |
---|
552 | assert( std::fabs(solid->DistanceToOut(inside_points[1], -dirx) - 175.0 )< kCarTolerance ); |
---|
553 | assert( std::fabs(solid->DistanceToOut(inside_points[1], diry) - 150.0 )< kCarTolerance ); |
---|
554 | assert( std::fabs(solid->DistanceToOut(inside_points[1], -diry) - 350.0 )< kCarTolerance ); |
---|
555 | assert( std::fabs(solid->DistanceToOut(inside_points[1], dirz) - 250.0 )< kCarTolerance ); |
---|
556 | assert( std::fabs(solid->DistanceToOut(inside_points[1], -dirz) - 350.0 )< kCarTolerance ); |
---|
557 | assert( std::fabs(solid->DistanceToOut(inside_points[2], dirx) - 275.0 )< kCarTolerance ); |
---|
558 | assert( std::fabs(solid->DistanceToOut(inside_points[2], -dirx) - 75.0 )< kCarTolerance ); |
---|
559 | assert( std::fabs(solid->DistanceToOut(inside_points[2], diry) - 150.0 )< kCarTolerance ); |
---|
560 | assert( std::fabs(solid->DistanceToOut(inside_points[2], -diry) - 250.0 )< kCarTolerance ); |
---|
561 | assert( std::fabs(solid->DistanceToOut(inside_points[2], dirz) - 450.0 )< kCarTolerance ); |
---|
562 | assert( std::fabs(solid->DistanceToOut(inside_points[2], -dirz) - 150.0 )< kCarTolerance ); |
---|
563 | |
---|
564 | // For Add points on surface |
---|
565 | } |
---|
566 | else if ( testCase == 1 ) { |
---|
567 | assert( std::fabs(solid->DistanceToOut(inside_points[0], dirx) - 300.0 )< kCarTolerance ); |
---|
568 | assert( std::fabs(solid->DistanceToOut(inside_points[0], -dirx) - 300.0 )< kCarTolerance ); |
---|
569 | assert( std::fabs(solid->DistanceToOut(inside_points[0], diry) - 300.0 )< kCarTolerance ); |
---|
570 | assert( std::fabs(solid->DistanceToOut(inside_points[0], -diry) - 300.0 )< kCarTolerance ); |
---|
571 | assert( std::fabs(solid->DistanceToOut(inside_points[0], dirz) - 300.0 )< kCarTolerance ); |
---|
572 | assert( std::fabs(solid->DistanceToOut(inside_points[0], -dirz) - 300.0 )< kCarTolerance ); |
---|
573 | assert( std::fabs(solid->DistanceToOut(inside_points[1], dirx) - 250.0 )< kCarTolerance ); |
---|
574 | assert( std::fabs(solid->DistanceToOut(inside_points[1], -dirx) - 350.0 )< kCarTolerance ); |
---|
575 | assert( std::fabs(solid->DistanceToOut(inside_points[1], diry) - 250.0 )< kCarTolerance ); |
---|
576 | assert( std::fabs(solid->DistanceToOut(inside_points[1], -diry) - 350.0 )< kCarTolerance ); |
---|
577 | assert( std::fabs(solid->DistanceToOut(inside_points[1], dirz) - 250.0 )< kCarTolerance ); |
---|
578 | assert( std::fabs(solid->DistanceToOut(inside_points[1], -dirz) - 350.0 )< kCarTolerance ); |
---|
579 | assert( std::fabs(solid->DistanceToOut(inside_points[2], dirx) - 400.0 )< kCarTolerance ); |
---|
580 | assert( std::fabs(solid->DistanceToOut(inside_points[2], -dirx) - 200.0 )< kCarTolerance ); |
---|
581 | assert( std::fabs(solid->DistanceToOut(inside_points[2], diry) - 350.0 )< kCarTolerance ); |
---|
582 | assert( std::fabs(solid->DistanceToOut(inside_points[2], -diry) - 250.0 )< kCarTolerance ); |
---|
583 | assert( std::fabs(solid->DistanceToOut(inside_points[2], dirz) - 450.0 )< kCarTolerance ); |
---|
584 | assert( std::fabs(solid->DistanceToOut(inside_points[2], -dirz) - 150.0 )< kCarTolerance ); |
---|
585 | |
---|
586 | // For Add points on surface |
---|
587 | } |
---|
588 | else if ( testCase == 2 ) { |
---|
589 | assert( std::fabs(solid->DistanceToOut(inside_points[0], dirx) - 100.0 )< kCarTolerance ); |
---|
590 | assert( std::fabs(solid->DistanceToOut(inside_points[0], -dirx) - 500.0 )< kCarTolerance ); |
---|
591 | assert( std::fabs(solid->DistanceToOut(inside_points[0], diry) - 100.0 )< kCarTolerance ); |
---|
592 | assert( std::fabs(solid->DistanceToOut(inside_points[0], -diry) - 500.0 )< kCarTolerance ); |
---|
593 | assert( std::fabs(solid->DistanceToOut(inside_points[0], dirz) - 125.0 )< kCarTolerance ); |
---|
594 | assert( std::fabs(solid->DistanceToOut(inside_points[0], -dirz) - 250.0 )< kCarTolerance ); |
---|
595 | assert( std::fabs(solid->DistanceToOut(inside_points[1], dirx) - 110.0 )< kCarTolerance ); |
---|
596 | assert( std::fabs(solid->DistanceToOut(inside_points[1], -dirx) - 100.0 )< kCarTolerance ); |
---|
597 | assert( std::fabs(solid->DistanceToOut(inside_points[1], diry) - 410.0 )< kCarTolerance ); |
---|
598 | assert( std::fabs(solid->DistanceToOut(inside_points[1], -diry) - 430.0 )< kCarTolerance ); |
---|
599 | assert( std::fabs(solid->DistanceToOut(inside_points[1], dirz) - 100.0 )< kCarTolerance ); |
---|
600 | assert( std::fabs(solid->DistanceToOut(inside_points[1], -dirz) - 50.0 )< kCarTolerance ); |
---|
601 | assert( std::fabs(solid->DistanceToOut(inside_points[2], dirx) - 10.0 )< kCarTolerance ); |
---|
602 | assert( std::fabs(solid->DistanceToOut(inside_points[2], -dirx) - 80.0 )< kCarTolerance ); |
---|
603 | assert( std::fabs(solid->DistanceToOut(inside_points[2], diry) - 340.0 )< kCarTolerance ); |
---|
604 | assert( std::fabs(solid->DistanceToOut(inside_points[2], -diry) - 20.0 )< kCarTolerance ); |
---|
605 | assert( std::fabs(solid->DistanceToOut(inside_points[2], dirz) - 50.0 )< kCarTolerance ); |
---|
606 | assert( std::fabs(solid->DistanceToOut(inside_points[2], -dirz) - 450.0 )< kCarTolerance ); |
---|
607 | |
---|
608 | // For Add points on surface |
---|
609 | } |
---|
610 | else if ( testCase == 3 ) { |
---|
611 | assert( std::fabs(solid->DistanceToOut(inside_points[0], dirx) - 110.0 )< kCarTolerance ); |
---|
612 | assert( std::fabs(solid->DistanceToOut(inside_points[0], -dirx) - 100.0 )< kCarTolerance ); |
---|
613 | assert( std::fabs(solid->DistanceToOut(inside_points[0], diry) - 410.0 )< kCarTolerance ); |
---|
614 | assert( std::fabs(solid->DistanceToOut(inside_points[0], -diry) - 430.0 )< kCarTolerance ); |
---|
615 | assert( std::fabs(solid->DistanceToOut(inside_points[0], dirz) - 100.0 )< kCarTolerance ); |
---|
616 | assert( std::fabs(solid->DistanceToOut(inside_points[0], -dirz) - 50.0 )< kCarTolerance ); |
---|
617 | assert( std::fabs(solid->DistanceToOut(inside_points[1], dirx) - 70.0 )< kCarTolerance ); |
---|
618 | assert( std::fabs(solid->DistanceToOut(inside_points[1], -dirx) - 35.0 )< kCarTolerance ); |
---|
619 | assert( std::fabs(solid->DistanceToOut(inside_points[1], diry) - 130.0 )< kCarTolerance ); |
---|
620 | assert( std::fabs(solid->DistanceToOut(inside_points[1], -diry) - 290.0 )< kCarTolerance ); |
---|
621 | assert( std::fabs(solid->DistanceToOut(inside_points[1], dirz) - 141.66666666666668561 )< kCarTolerance ); |
---|
622 | assert( std::fabs(solid->DistanceToOut(inside_points[1], -dirz) - 400.0 )< kCarTolerance ); |
---|
623 | assert( std::fabs(solid->DistanceToOut(inside_points[2], dirx) - 63.0 )< kCarTolerance ); |
---|
624 | assert( std::fabs(solid->DistanceToOut(inside_points[2], -dirx) - 24.0 )< kCarTolerance ); |
---|
625 | assert( std::fabs(solid->DistanceToOut(inside_points[2], diry) - 174.0 )< kCarTolerance ); |
---|
626 | assert( std::fabs(solid->DistanceToOut(inside_points[2], -diry) - 174.0 )< kCarTolerance ); |
---|
627 | assert( std::fabs(solid->DistanceToOut(inside_points[2], dirz) - 137.1428571428571388 )< kCarTolerance ); |
---|
628 | assert( std::fabs(solid->DistanceToOut(inside_points[2], -dirz) - 20.0 )< kCarTolerance ); |
---|
629 | assert( std::fabs(solid->DistanceToOut(inside_points[3], dirx) - 16.0 )< kCarTolerance ); |
---|
630 | assert( std::fabs(solid->DistanceToOut(inside_points[3], -dirx) - 107.0 )< kCarTolerance ); |
---|
631 | assert( std::fabs(solid->DistanceToOut(inside_points[3], diry) - 416.0 )< kCarTolerance ); |
---|
632 | assert( std::fabs(solid->DistanceToOut(inside_points[3], -diry) - 76.0 )< kCarTolerance ); |
---|
633 | assert( std::fabs(solid->DistanceToOut(inside_points[3], dirz) - 100.0 )< kCarTolerance ); |
---|
634 | assert( std::fabs(solid->DistanceToOut(inside_points[3], -dirz) - 15.384615384615381473 )< kCarTolerance ); |
---|
635 | |
---|
636 | // For Add points on surface |
---|
637 | } |
---|
638 | |
---|
639 | delete solid; |
---|
640 | } |
---|
641 | |
---|
642 | //_____________________________________________________________________________ |
---|
643 | void testSurface(G4int testCase) |
---|
644 | { |
---|
645 | // Test surface |
---|
646 | |
---|
647 | std::vector<G4ThreeVector> inside_points; |
---|
648 | std::vector<G4ThreeVector> surface_points; |
---|
649 | std::vector<G4ThreeVector> outside_points; |
---|
650 | G4VSolid* solid = createSolid(testCase, inside_points, surface_points, outside_points); |
---|
651 | |
---|
652 | if ( testCase == 0 ) { |
---|
653 | assert( std::fabs(solid->GetSurfaceArea() - 1524984.4718999243341 ) < 1e-6 ); |
---|
654 | } |
---|
655 | if ( testCase == 1 ) { |
---|
656 | assert( std::fabs(solid->GetSurfaceArea() - 2160000 ) < 1e-6 ); |
---|
657 | } |
---|
658 | if ( testCase == 2 ) { |
---|
659 | assert( std::fabs(solid->GetSurfaceArea() - 2506922.4391292142682 ) < 1e-6 ); |
---|
660 | } |
---|
661 | if ( testCase == 3 ) { |
---|
662 | assert( std::fabs(solid->GetSurfaceArea() - 3638542.9775616745465 ) < 1e-6 ); |
---|
663 | } |
---|
664 | |
---|
665 | delete solid; |
---|
666 | } |
---|
667 | |
---|
668 | //_____________________________________________________________________________ |
---|
669 | void testVolume(G4int testCase) |
---|
670 | { |
---|
671 | // Test volume |
---|
672 | // The volume is evaluated via G4VSolid, that's why the precision is very low |
---|
673 | |
---|
674 | std::vector<G4ThreeVector> inside_points; |
---|
675 | std::vector<G4ThreeVector> surface_points; |
---|
676 | std::vector<G4ThreeVector> outside_points; |
---|
677 | G4VSolid* solid = createSolid(testCase, inside_points, surface_points, outside_points); |
---|
678 | |
---|
679 | if ( testCase == 0 ) { |
---|
680 | assert( std::fabs(solid->GetCubicVolume() - 108.0e+6 ) < 1.0e+6 ); |
---|
681 | } |
---|
682 | if ( testCase == 1 ) { |
---|
683 | assert( std::fabs(solid->GetCubicVolume() - 216.0e+6 ) < 1.0e+6 ); |
---|
684 | } |
---|
685 | if ( testCase == 2 ) { |
---|
686 | assert( std::fabs(solid->GetCubicVolume() - 121.7e+6 ) < 1.0e+6 ); |
---|
687 | } |
---|
688 | |
---|
689 | if ( testCase == 3 ) { |
---|
690 | assert( std::fabs(solid->GetCubicVolume() - 162.1e+6 ) < 1.0e+6 ); |
---|
691 | } |
---|
692 | |
---|
693 | delete solid; |
---|
694 | } |
---|
695 | |
---|
696 | |
---|
697 | //_____________________________________________________________________________ |
---|
698 | int main() |
---|
699 | { |
---|
700 | // Uncomment this line to print the results for a tested solid case |
---|
701 | // printResults(1); |
---|
702 | |
---|
703 | for ( G4int testCase = 0; testCase < 4; ++testCase ) { |
---|
704 | testInside(testCase); |
---|
705 | testDistanceToInPV(testCase); |
---|
706 | testDistanceToOutPV(testCase); |
---|
707 | testSurface(testCase); |
---|
708 | testVolume(testCase); |
---|
709 | } |
---|
710 | |
---|
711 | return 0; |
---|
712 | } |
---|