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