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 | // Test file for the class G4IntersectionSolid |
---|
27 | // |
---|
28 | // |
---|
29 | |
---|
30 | #include <assert.h> |
---|
31 | #include <cmath> |
---|
32 | |
---|
33 | #include "globals.hh" |
---|
34 | #include "geomdefs.hh" |
---|
35 | |
---|
36 | #include "ApproxEqual.hh" |
---|
37 | |
---|
38 | #include "G4ThreeVector.hh" |
---|
39 | #include "G4RotationMatrix.hh" |
---|
40 | #include "G4AffineTransform.hh" |
---|
41 | #include "G4VoxelLimits.hh" |
---|
42 | |
---|
43 | #include "G4Box.hh" |
---|
44 | #include "G4Cons.hh" |
---|
45 | #include "G4Para.hh" |
---|
46 | #include "G4Sphere.hh" |
---|
47 | #include "G4Torus.hh" |
---|
48 | #include "G4Trap.hh" |
---|
49 | #include "G4Trd.hh" |
---|
50 | #include "G4Tubs.hh" |
---|
51 | |
---|
52 | #include "G4IntersectionSolid.hh" |
---|
53 | // #include "G4DisplacedSolid.hh" |
---|
54 | |
---|
55 | |
---|
56 | int main() |
---|
57 | { |
---|
58 | G4ThreeVector pzero(0,0,0), p; |
---|
59 | G4ThreeVector ponxside(20,0,0),ponyside(0,30,0),ponzside(0,0,40), |
---|
60 | ponb2x(10,0,0),ponb2y(0,10,0),ponb2z(0,0,10), |
---|
61 | ponb2mx(-10,0,0),ponb2my(0,-10,0),ponb2mz(0,0,-10); |
---|
62 | G4ThreeVector ponmxside(-20,0,0),ponmyside(0,-30,0),ponmzside(0,0,-40); |
---|
63 | G4ThreeVector ponzsidey(0,25,40),ponmzsidey(0,25,-40), |
---|
64 | ponb2zy(0,5,10),ponb2mzy(0,5,-10) ; |
---|
65 | |
---|
66 | G4ThreeVector pbigx(100,0,0),pbigy(0,100,0),pbigz(0,0,100); |
---|
67 | G4ThreeVector pbigmx(-100,0,0),pbigmy(0,-100,0),pbigmz(0,0,-100); |
---|
68 | |
---|
69 | G4ThreeVector vx(1,0,0),vy(0,1,0),vz(0,0,1); |
---|
70 | G4ThreeVector vmx(-1,0,0),vmy(0,-1,0),vmz(0,0,-1); |
---|
71 | G4ThreeVector vxy(1/std::sqrt(2.0),1/std::sqrt(2.0),0); |
---|
72 | G4ThreeVector vmxy(-1/std::sqrt(2.0),1/std::sqrt(2.0),0); |
---|
73 | G4ThreeVector vmxmy(-1/std::sqrt(2.0),-1/std::sqrt(2.0),0); |
---|
74 | G4ThreeVector vxmy(1/std::sqrt(2.0),-1/std::sqrt(2.0),0); |
---|
75 | G4ThreeVector vxmz(1/std::sqrt(2.0),0,-1/std::sqrt(2.0)); |
---|
76 | |
---|
77 | G4double dist; |
---|
78 | G4int i; |
---|
79 | G4ThreeVector *pNorm,norm; |
---|
80 | G4bool *pgoodNorm,goodNorm,calcNorm=true; |
---|
81 | |
---|
82 | pNorm=&norm; |
---|
83 | pgoodNorm=&goodNorm; |
---|
84 | |
---|
85 | G4RotationMatrix identity, xRot ; |
---|
86 | |
---|
87 | // NOTE: xRot = rotation such that x axis->y axis & y axis->-x axis |
---|
88 | |
---|
89 | xRot.rotateZ(-pi*0.5) ; |
---|
90 | |
---|
91 | G4Transform3D transform(xRot,ponb2y) ; |
---|
92 | |
---|
93 | G4Box b1("Test Box #1",20,30,40); |
---|
94 | G4Box b2("Test Box #2",10,10,10); |
---|
95 | |
---|
96 | G4Tubs t1("Solid Tube #1",0,50,50,0,360); |
---|
97 | G4Tubs t2("Hole Tube #2",45,50,50,0,360); |
---|
98 | |
---|
99 | G4Cons c1("Hollow Full Tube",50,100,50,100,50,0,2*pi) ; |
---|
100 | G4Cons c2("Full Cone",0,50,0,100,50,0,2*pi) ; |
---|
101 | |
---|
102 | G4Tubs* tube3 = new G4Tubs( "OuterFrame", |
---|
103 | 1.0*m, |
---|
104 | 1.1*m, |
---|
105 | 0.50*m, |
---|
106 | 0*deg, |
---|
107 | 180*deg ); |
---|
108 | |
---|
109 | G4Tubs* tube4 = new G4Tubs("AnotherTubs", |
---|
110 | 1.0*m, |
---|
111 | 1.1*m, |
---|
112 | 0.50*m, |
---|
113 | 0*deg, |
---|
114 | 180*deg ); |
---|
115 | G4RotationMatrix rotmat2; |
---|
116 | rotmat2.rotateY(pi/4.0); |
---|
117 | G4Transform3D tran2 = G4Transform3D(rotmat2,G4ThreeVector(0.0,0.0,0.0)); |
---|
118 | |
---|
119 | G4VSolid* t3It4 = new G4IntersectionSolid( "Example", tube3, tube4, tran2 ); |
---|
120 | |
---|
121 | |
---|
122 | |
---|
123 | |
---|
124 | G4IntersectionSolid b1Ib2("b1Intersectionb2",&b1,&b2,transform) ; |
---|
125 | G4IntersectionSolid likeb2("b1Intersectionb2",&b1,&b2) ; |
---|
126 | G4IntersectionSolid nextb2("b2Intersectionb1",&b2,&b1) ; |
---|
127 | G4IntersectionSolid t1Ib2("t1Intersectionb2",&t1,&b2,&xRot,ponb2y) ; |
---|
128 | G4IntersectionSolid c2Ib2("c2Intersectionb2",&c2,&b2,transform) ; |
---|
129 | |
---|
130 | G4cout.precision(16); |
---|
131 | |
---|
132 | // Check Inside |
---|
133 | |
---|
134 | assert(b1Ib2.Inside(pzero)==kSurface); |
---|
135 | assert(b1Ib2.Inside(pbigz)==kOutside); |
---|
136 | assert(b1Ib2.Inside(ponb2y)==kInside); |
---|
137 | |
---|
138 | assert(t1Ib2.Inside(pzero)==kSurface); |
---|
139 | assert(t1Ib2.Inside(pbigz)==kOutside); |
---|
140 | assert(t1Ib2.Inside(ponb2y)==kInside); |
---|
141 | |
---|
142 | assert(c2Ib2.Inside(pzero)==kSurface); |
---|
143 | assert(c2Ib2.Inside(pbigz)==kOutside); |
---|
144 | assert(c2Ib2.Inside(ponb2y)==kInside); |
---|
145 | |
---|
146 | // Check Surface Normal |
---|
147 | |
---|
148 | G4ThreeVector normal; |
---|
149 | /* |
---|
150 | normal=b1Ib2.SurfaceNormal(G4ThreeVector(10,15,0)); |
---|
151 | assert(ApproxEqual(normal,G4ThreeVector(1,0,0))); |
---|
152 | |
---|
153 | normal=b1Ib2.SurfaceNormal(G4ThreeVector(-10,15,0)); |
---|
154 | assert(ApproxEqual(normal,G4ThreeVector(-1,0,0))); |
---|
155 | |
---|
156 | normal=b1Ib2.SurfaceNormal(pzero); |
---|
157 | assert(ApproxEqual(normal,G4ThreeVector(0,-1,0))); |
---|
158 | |
---|
159 | normal=b1Ib2.SurfaceNormal(G4ThreeVector(0,20,0)); |
---|
160 | assert(ApproxEqual(normal,G4ThreeVector(0,1,0))); |
---|
161 | |
---|
162 | normal=b1Ib2.SurfaceNormal(G4ThreeVector(0,15,10)); |
---|
163 | assert(ApproxEqual(normal,G4ThreeVector(0,0,1))); |
---|
164 | |
---|
165 | normal=b1Ib2.SurfaceNormal(G4ThreeVector(0,15,-10)); |
---|
166 | assert(ApproxEqual(normal,G4ThreeVector(0,0,-1))); |
---|
167 | */ |
---|
168 | |
---|
169 | |
---|
170 | // DistanceToOut(P) |
---|
171 | |
---|
172 | dist=b1Ib2.DistanceToOut(pzero); |
---|
173 | assert(ApproxEqual(dist,0)); |
---|
174 | |
---|
175 | dist=b1Ib2.DistanceToOut(vx); |
---|
176 | assert(ApproxEqual(dist,0)); |
---|
177 | |
---|
178 | dist=b1Ib2.DistanceToOut(vy); |
---|
179 | assert(ApproxEqual(dist,1)); |
---|
180 | |
---|
181 | dist=b1Ib2.DistanceToOut(vz); |
---|
182 | assert(ApproxEqual(dist,0)); |
---|
183 | |
---|
184 | // DistanceToOut(P,V) |
---|
185 | |
---|
186 | dist=b1Ib2.DistanceToOut(G4ThreeVector(0,5,0),vx,calcNorm,pgoodNorm,pNorm); |
---|
187 | assert(ApproxEqual(dist,10)&&ApproxEqual(*pNorm,vx)&&*pgoodNorm); |
---|
188 | |
---|
189 | dist=b1Ib2.DistanceToOut(G4ThreeVector(0,5,0),vmx,calcNorm,pgoodNorm,pNorm); |
---|
190 | assert(ApproxEqual(dist,10)&&ApproxEqual(norm,vmx)&&*pgoodNorm); |
---|
191 | |
---|
192 | dist=b1Ib2.DistanceToOut(pzero,vy,calcNorm,pgoodNorm,pNorm); |
---|
193 | assert(ApproxEqual(dist,20)&&ApproxEqual(norm,vy)&&*pgoodNorm); |
---|
194 | |
---|
195 | dist=b1Ib2.DistanceToOut(pzero,vmy,calcNorm,pgoodNorm,pNorm); |
---|
196 | assert(ApproxEqual(dist,0)&&ApproxEqual(norm,vmy)&&*pgoodNorm); |
---|
197 | |
---|
198 | dist=b1Ib2.DistanceToOut(G4ThreeVector(0,5,0),vz,calcNorm,pgoodNorm,pNorm); |
---|
199 | assert(ApproxEqual(dist,10)&&ApproxEqual(norm,vz)&&*pgoodNorm); |
---|
200 | |
---|
201 | dist=b1Ib2.DistanceToOut(G4ThreeVector(0,5,0),vmz,calcNorm,pgoodNorm,pNorm); |
---|
202 | assert(ApproxEqual(dist,10)&&ApproxEqual(norm,vmz)&&*pgoodNorm); |
---|
203 | |
---|
204 | dist=b1Ib2.DistanceToOut(pzero,vxy,calcNorm,pgoodNorm,pNorm); |
---|
205 | assert(ApproxEqual(dist,std::sqrt(200.0))&&*pgoodNorm); |
---|
206 | |
---|
207 | dist=b1Ib2.DistanceToOut(G4ThreeVector(10,5,0),vx,calcNorm,pgoodNorm,pNorm); |
---|
208 | assert(ApproxEqual(dist,0)&&ApproxEqual(*pNorm,vx)&&*pgoodNorm); |
---|
209 | |
---|
210 | dist=b1Ib2.DistanceToOut(ponb2x,vmx,calcNorm,pgoodNorm,pNorm); |
---|
211 | assert(ApproxEqual(dist,20)&&ApproxEqual(*pNorm,vmx)&&*pgoodNorm); |
---|
212 | |
---|
213 | dist=b1.DistanceToOut(ponxside,vy,calcNorm,pgoodNorm,pNorm); |
---|
214 | // cout<<"b1.DistanceToOut(ponxside,vy) = "<<dist<<G4endl; |
---|
215 | // assert(ApproxEqual(dist,0)&&ApproxEqual(*pNorm,vy)&&*pgoodNorm); |
---|
216 | |
---|
217 | dist=b1Ib2.DistanceToOut(ponb2mx,vmx,calcNorm,pgoodNorm,pNorm); |
---|
218 | assert(ApproxEqual(dist,0)&&ApproxEqual(norm,vmx)&&*pgoodNorm); |
---|
219 | |
---|
220 | dist=b1Ib2.DistanceToOut(ponb2y,vy,calcNorm,pgoodNorm,pNorm); |
---|
221 | assert(ApproxEqual(dist,10)&&ApproxEqual(norm,vy)&&*pgoodNorm); |
---|
222 | |
---|
223 | dist=b1Ib2.DistanceToOut(pzero,vmy,calcNorm,pgoodNorm,pNorm); |
---|
224 | assert(ApproxEqual(dist,0)&&ApproxEqual(norm,vmy)&&*pgoodNorm); |
---|
225 | |
---|
226 | |
---|
227 | //DistanceToIn(P) |
---|
228 | |
---|
229 | dist=b1Ib2.DistanceToIn(G4ThreeVector(100,1,0)); |
---|
230 | assert(ApproxEqual(dist,80)); |
---|
231 | |
---|
232 | dist=b1Ib2.DistanceToIn(G4ThreeVector(10,1,0)); |
---|
233 | assert(ApproxEqual(dist,0)); |
---|
234 | |
---|
235 | dist=b1Ib2.DistanceToIn(pbigmy); |
---|
236 | assert(ApproxEqual(dist,70)); |
---|
237 | |
---|
238 | dist=b1Ib2.DistanceToIn(pbigz); |
---|
239 | assert(ApproxEqual(dist,60)); |
---|
240 | |
---|
241 | dist=b1Ib2.DistanceToIn(pbigmz); |
---|
242 | assert(ApproxEqual(dist,60)); |
---|
243 | |
---|
244 | // DistanceToIn(P,V) |
---|
245 | |
---|
246 | dist=b1Ib2.DistanceToIn(G4ThreeVector(100,1,0),vmx); |
---|
247 | assert(ApproxEqual(dist,90)); |
---|
248 | |
---|
249 | dist=b1Ib2.DistanceToIn(G4ThreeVector(-100,1,0),vx); |
---|
250 | assert(ApproxEqual(dist,90)); |
---|
251 | |
---|
252 | dist=b1Ib2.DistanceToIn(pbigy,vmy); |
---|
253 | assert(ApproxEqual(dist,80)); |
---|
254 | |
---|
255 | dist=b1Ib2.DistanceToIn(pbigmy,vy); |
---|
256 | assert(ApproxEqual(dist,100)); |
---|
257 | |
---|
258 | dist=b1Ib2.DistanceToIn(pbigz,vmz); |
---|
259 | assert(ApproxEqual(dist,kInfinity)); |
---|
260 | |
---|
261 | dist=b1Ib2.DistanceToIn(pbigmz,vz); |
---|
262 | assert(ApproxEqual(dist,kInfinity)); |
---|
263 | |
---|
264 | dist=b1Ib2.DistanceToIn(pbigx,vxy); |
---|
265 | assert(ApproxEqual(dist,kInfinity)); |
---|
266 | |
---|
267 | dist=b1Ib2.DistanceToIn(pbigmx,vxy); |
---|
268 | assert(ApproxEqual(dist,kInfinity)); |
---|
269 | |
---|
270 | dist=b1Ib2.DistanceToIn(pzero,vmy); |
---|
271 | assert(ApproxEqual(dist,kInfinity)); |
---|
272 | // G4cout<<"(kInfinity) b1Ib2.DistanceToIn(pzero,vmy) = "<<dist<<G4endl ; |
---|
273 | |
---|
274 | dist=b1Ib2.DistanceToIn(pzero,vy); |
---|
275 | assert(ApproxEqual(dist,0)); |
---|
276 | // G4cout<<"(0) b1Ib2.DistanceToIn(pzero,vy) = "<<dist<<G4endl ; |
---|
277 | |
---|
278 | |
---|
279 | // It returns 0, probably due to G4Displaced or G4Transform3D games !? |
---|
280 | // |
---|
281 | // dist=b1Ib2.DistanceToIn(pzero,vmx); |
---|
282 | // assert(ApproxEqual(dist,kInfinity)); |
---|
283 | // G4cout<<"(kInfinity) b1Ib2.DistanceToIn(pzero,vmx) = "<<dist<<G4endl ; |
---|
284 | |
---|
285 | dist=likeb2.DistanceToIn(G4ThreeVector(10,0,0),vmx); |
---|
286 | assert(ApproxEqual(dist,0)); |
---|
287 | // G4cout<<"(0) likeb2.DistanceToIn(G4ThreeVector(10,0,0),vmx) = " |
---|
288 | // <<dist<<G4endl ; |
---|
289 | |
---|
290 | dist=b1Ib2.DistanceToIn(G4ThreeVector(10,0,0),vx); |
---|
291 | assert(ApproxEqual(dist,kInfinity)); |
---|
292 | // G4cout<<"(kInfinity) likeb2.DistanceToIn(G4ThreeVector(10,0,0),vx) = " |
---|
293 | // <<dist<<G4endl ; |
---|
294 | |
---|
295 | dist=b1Ib2.DistanceToIn(G4ThreeVector(10,0,0),vy); |
---|
296 | assert(ApproxEqual(dist,kInfinity)); |
---|
297 | // G4cout<<"(kInfinity) likeb2.DistanceToIn(G4ThreeVector(10,0,0),vy) = " |
---|
298 | // <<dist<<G4endl ; |
---|
299 | |
---|
300 | dist=b1Ib2.DistanceToIn(G4ThreeVector(10,0,0),vmy); |
---|
301 | assert(ApproxEqual(dist,kInfinity)); |
---|
302 | // G4cout<<"(kInfinity) likeb2.DistanceToIn(G4ThreeVector(10,0,0),vmy) = " |
---|
303 | // <<dist<<G4endl ; |
---|
304 | |
---|
305 | dist=t3It4->DistanceToIn( |
---|
306 | G4ThreeVector(1888.691673255004,-476.1676766307428,-295.4764663381112), |
---|
307 | G4ThreeVector(-0.8509009035458712,0.5062362036610951,-0.1403301765395527)); |
---|
308 | assert(ApproxEqual(dist,940.603760037514)); |
---|
309 | // G4cout<<"t3It4->DistanceToIn = "<<dist<<G4endl ; |
---|
310 | |
---|
311 | dist=t3It4->DistanceToIn( |
---|
312 | G4ThreeVector(1355.5204683069741804501973092556, |
---|
313 | -900.36862622234150421718368306756, |
---|
314 | -85.254645167836457630983204580843), |
---|
315 | G4ThreeVector(-0.25623628694138916861433585836494, |
---|
316 | 0.84905863423851268834141592378728, |
---|
317 | 0.46199826934689036672665451987996)); |
---|
318 | // assert(ApproxEqual(dist,940.603760037514)); |
---|
319 | assert(ApproxEqual(dist,kInfinity)); |
---|
320 | // G4cout<<"t3It4->DistanceToIn = "<<dist<<G4endl ; |
---|
321 | |
---|
322 | dist=nextb2.DistanceToIn(G4ThreeVector(10,0,0),vx); |
---|
323 | assert(ApproxEqual(dist,kInfinity)); |
---|
324 | |
---|
325 | dist=nextb2.DistanceToIn(G4ThreeVector(0,10,0),vy); |
---|
326 | assert(ApproxEqual(dist,kInfinity)); |
---|
327 | |
---|
328 | dist=nextb2.DistanceToIn(G4ThreeVector(0,0,10),vz); |
---|
329 | assert(ApproxEqual(dist,kInfinity)); |
---|
330 | |
---|
331 | dist=nextb2.DistanceToIn(G4ThreeVector(10,10,10),vx); |
---|
332 | assert(ApproxEqual(dist,kInfinity)); |
---|
333 | |
---|
334 | G4cout<<"Tracking functions are OK"<<G4endl ; |
---|
335 | |
---|
336 | |
---|
337 | // Point on surface box(10,10,10) moved 10 +Y |
---|
338 | G4cout<<G4endl; |
---|
339 | G4cout<<"Point on surface of 10x10x10 box shifted -10 along x-axis:"<<G4endl<<G4endl; |
---|
340 | for(i=0;i<10;i++) |
---|
341 | { |
---|
342 | p = b1Ib2.GetPointOnSurface(); |
---|
343 | G4cout<<p.x()<<"\t"<<p.y()<<"\t"<<p.z()<<G4endl; |
---|
344 | } |
---|
345 | G4cout<<G4endl; |
---|
346 | |
---|
347 | |
---|
348 | |
---|
349 | |
---|
350 | |
---|
351 | // CalculateExtent |
---|
352 | |
---|
353 | G4VoxelLimits limit; // Unlimited |
---|
354 | G4RotationMatrix noRot; |
---|
355 | G4AffineTransform origin; |
---|
356 | G4double min,max; |
---|
357 | |
---|
358 | assert(b1.CalculateExtent(kXAxis,limit,origin,min,max)); |
---|
359 | assert(ApproxEqual(min,-20)&&ApproxEqual(max,20)); |
---|
360 | |
---|
361 | assert(b1.CalculateExtent(kYAxis,limit,origin,min,max)); |
---|
362 | assert(ApproxEqual(min,-30)&&ApproxEqual(max,30)); |
---|
363 | |
---|
364 | assert(b1.CalculateExtent(kZAxis,limit,origin,min,max)); |
---|
365 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
366 | |
---|
367 | assert(b1Ib2.CalculateExtent(kXAxis,limit,origin,min,max)); |
---|
368 | // G4cout<<"min of b1Ib2.CalculateExtent(kXAxis,limit,origin,min,max) = " |
---|
369 | // <<min<<G4endl ; |
---|
370 | // G4cout<<"max of b1Ib2.CalculateExtent(kXAxis,limit,origin,min,max) = " |
---|
371 | // <<max<<G4endl ; |
---|
372 | assert(ApproxEqual(min,-10)&&ApproxEqual(max,10)); |
---|
373 | |
---|
374 | assert(b1Ib2.CalculateExtent(kYAxis,limit,origin,min,max)); |
---|
375 | // G4cout<<"min of b1Ib2.CalculateExtent(kYAxis,limit,origin,min,max) = " |
---|
376 | // <<min<<G4endl ; |
---|
377 | // G4cout<<"max of b1Ib2.CalculateExtent(kYAxis,limit,origin,min,max) = " |
---|
378 | // <<max<<G4endl ; |
---|
379 | assert(ApproxEqual(min,0)&&ApproxEqual(max,20)); |
---|
380 | |
---|
381 | assert(b1Ib2.CalculateExtent(kZAxis,limit,origin,min,max)); |
---|
382 | // G4cout<<"min of b1Ib2.CalculateExtent(kZAxis,limit,origin,min,max) = " |
---|
383 | // <<min<<G4endl ; |
---|
384 | // G4cout<<"max of b1Ib2.CalculateExtent(kZAxis,limit,origin,min,max) = " |
---|
385 | // <<max<<G4endl ; |
---|
386 | assert(ApproxEqual(min,-10)&&ApproxEqual(max,10)); |
---|
387 | |
---|
388 | G4ThreeVector pmxmymz(-100,-110,-120); |
---|
389 | G4AffineTransform tPosOnly(pmxmymz); |
---|
390 | |
---|
391 | assert(b1.CalculateExtent(kXAxis,limit,tPosOnly,min,max)); |
---|
392 | assert(ApproxEqual(min,-120)&&ApproxEqual(max,-80)); |
---|
393 | |
---|
394 | assert(b1.CalculateExtent(kYAxis,limit,tPosOnly,min,max)); |
---|
395 | assert(ApproxEqual(min,-140)&&ApproxEqual(max,-80)); |
---|
396 | |
---|
397 | assert(b1.CalculateExtent(kZAxis,limit,tPosOnly,min,max)); |
---|
398 | assert(ApproxEqual(min,-160)&&ApproxEqual(max,-80)); |
---|
399 | |
---|
400 | assert(b1Ib2.CalculateExtent(kYAxis,limit,tPosOnly,min,max)); |
---|
401 | assert(ApproxEqual(min,-110)&&ApproxEqual(max,-90)); |
---|
402 | |
---|
403 | |
---|
404 | G4RotationMatrix r90Z; |
---|
405 | r90Z.rotateZ(pi/2); |
---|
406 | G4AffineTransform tRotZ(r90Z,pzero); |
---|
407 | |
---|
408 | assert(b1.CalculateExtent(kXAxis,limit,tRotZ,min,max)); |
---|
409 | assert(ApproxEqual(min,-30)&&ApproxEqual(max,30)); |
---|
410 | |
---|
411 | assert(b1.CalculateExtent(kYAxis,limit,tRotZ,min,max)); |
---|
412 | assert(ApproxEqual(min,-20)&&ApproxEqual(max,20)); |
---|
413 | |
---|
414 | assert(b1.CalculateExtent(kZAxis,limit,tRotZ,min,max)); |
---|
415 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
416 | |
---|
417 | // Check that clipped away |
---|
418 | |
---|
419 | G4VoxelLimits xClip; |
---|
420 | xClip.AddLimit(kXAxis,-100,-50); |
---|
421 | assert(!b1.CalculateExtent(kXAxis,xClip,origin,min,max)); |
---|
422 | assert(!b1Ib2.CalculateExtent(kXAxis,xClip,origin,min,max)); |
---|
423 | |
---|
424 | // Assert clipped to volume |
---|
425 | |
---|
426 | G4VoxelLimits allClip; |
---|
427 | allClip.AddLimit(kXAxis,-5,+5); |
---|
428 | allClip.AddLimit(kYAxis,-5,+5); |
---|
429 | allClip.AddLimit(kZAxis,-5,+5); |
---|
430 | |
---|
431 | G4RotationMatrix genRot; |
---|
432 | genRot.rotateX(pi/6); |
---|
433 | genRot.rotateY(pi/6); |
---|
434 | genRot.rotateZ(pi/6); |
---|
435 | G4AffineTransform tGen(genRot,vx); |
---|
436 | |
---|
437 | assert(b1.CalculateExtent(kXAxis,allClip,tGen,min,max)); |
---|
438 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
439 | |
---|
440 | assert(b1.CalculateExtent(kYAxis,allClip,tGen,min,max)); |
---|
441 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
442 | |
---|
443 | assert(b1.CalculateExtent(kZAxis,allClip,tGen,min,max)); |
---|
444 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
445 | |
---|
446 | assert(b1Ib2.CalculateExtent(kXAxis,allClip,tGen,min,max)); |
---|
447 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
448 | |
---|
449 | assert(b1Ib2.CalculateExtent(kYAxis,allClip,tGen,min,max)) ; |
---|
450 | // G4cout<<"min of b1Ib2.CalculateExtent(kYAxis,allClip,tGen,min,max) = " |
---|
451 | // <<min<<G4endl ; |
---|
452 | // G4cout<<"max of b1Ib2.CalculateExtent(kYAxis,allClip,tGen,min,max) = " |
---|
453 | // <<max<<G4endl ; |
---|
454 | // Reasonable but not so obvious ?! |
---|
455 | assert(ApproxEqual(min,-3.21667)&&ApproxEqual(max,5)) ; |
---|
456 | |
---|
457 | |
---|
458 | |
---|
459 | G4VoxelLimits buggyClip2; |
---|
460 | buggyClip2.AddLimit(kXAxis,5,15); |
---|
461 | |
---|
462 | assert(b1.CalculateExtent(kXAxis,buggyClip2,origin,min,max)); |
---|
463 | assert(ApproxEqual(min,5)&&ApproxEqual(max,15)); |
---|
464 | |
---|
465 | assert(b1.CalculateExtent(kYAxis,buggyClip2,origin,min,max)); |
---|
466 | assert(ApproxEqual(min,-30)&&ApproxEqual(max,30)); |
---|
467 | |
---|
468 | assert(b1.CalculateExtent(kZAxis,buggyClip2,origin,min,max)); |
---|
469 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
470 | |
---|
471 | buggyClip2.AddLimit(kYAxis,5,15); |
---|
472 | |
---|
473 | assert(b1.CalculateExtent(kXAxis,buggyClip2,origin,min,max)); |
---|
474 | assert(ApproxEqual(min,5)&&ApproxEqual(max,15)); |
---|
475 | |
---|
476 | assert(b1.CalculateExtent(kYAxis,buggyClip2,origin,min,max)); |
---|
477 | assert(ApproxEqual(min,5)&&ApproxEqual(max,15)); |
---|
478 | |
---|
479 | assert(b1.CalculateExtent(kZAxis,buggyClip2,origin,min,max)); |
---|
480 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
481 | |
---|
482 | G4VoxelLimits buggyClip1; |
---|
483 | buggyClip1.AddLimit(kXAxis,-5,+5); |
---|
484 | |
---|
485 | assert(b1.CalculateExtent(kXAxis,buggyClip1,origin,min,max)); |
---|
486 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
487 | |
---|
488 | assert(b1.CalculateExtent(kYAxis,buggyClip1,origin,min,max)); |
---|
489 | assert(ApproxEqual(min,-30)&&ApproxEqual(max,30)); |
---|
490 | |
---|
491 | assert(b1.CalculateExtent(kZAxis,buggyClip1,origin,min,max)); |
---|
492 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
493 | |
---|
494 | assert(b1Ib2.CalculateExtent(kXAxis,buggyClip1,origin,min,max)); |
---|
495 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
496 | |
---|
497 | assert(b1Ib2.CalculateExtent(kYAxis,buggyClip1,origin,min,max)); |
---|
498 | assert(ApproxEqual(min,0)&&ApproxEqual(max,20)); |
---|
499 | |
---|
500 | assert(b1Ib2.CalculateExtent(kZAxis,buggyClip1,origin,min,max)); |
---|
501 | assert(ApproxEqual(min,-10)&&ApproxEqual(max,10)); |
---|
502 | |
---|
503 | |
---|
504 | |
---|
505 | buggyClip1.AddLimit(kYAxis,-5,+5); |
---|
506 | |
---|
507 | assert(b1.CalculateExtent(kXAxis,buggyClip1,origin,min,max)); |
---|
508 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
509 | |
---|
510 | assert(b1.CalculateExtent(kYAxis,buggyClip1,origin,min,max)); |
---|
511 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
512 | |
---|
513 | assert(b1.CalculateExtent(kZAxis,buggyClip1,origin,min,max)); |
---|
514 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
515 | |
---|
516 | G4cout<<"CalculateExtent is OK"<<G4endl ; |
---|
517 | |
---|
518 | return 0 ; |
---|
519 | } |
---|