[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 | // $Id: testG4Trap.cc,v 1.13 2006/06/29 18:46:25 gunter Exp $ |
---|
[1347] | 28 | // GEANT4 tag $Name: geant4-09-04-ref-00 $ |
---|
[1316] | 29 | // |
---|
| 30 | |
---|
| 31 | // testG4Trap |
---|
| 32 | // Ensure asserts are compiled in |
---|
| 33 | |
---|
| 34 | #include <assert.h> |
---|
| 35 | #include <cmath> |
---|
| 36 | #include "G4ios.hh" |
---|
| 37 | |
---|
| 38 | #include "globals.hh" |
---|
| 39 | #include "geomdefs.hh" |
---|
| 40 | |
---|
| 41 | #include "ApproxEqual.hh" |
---|
| 42 | |
---|
| 43 | #include "G4ThreeVector.hh" |
---|
| 44 | #include "G4Trap.hh" |
---|
| 45 | #include "G4RotationMatrix.hh" |
---|
| 46 | #include "G4AffineTransform.hh" |
---|
| 47 | #include "G4VoxelLimits.hh" |
---|
| 48 | |
---|
| 49 | G4bool testG4Trap() |
---|
| 50 | { |
---|
| 51 | G4ThreeVector pzero(0,0,0); |
---|
| 52 | G4ThreeVector ponxside(20,0,0),ponyside(0,30,0),ponzside(0,0,40); |
---|
| 53 | G4ThreeVector ponmxside(-20,0,0),ponmyside(0,-30,0),ponmzside(0,0,-40); |
---|
| 54 | G4ThreeVector ponzsidey(0,25,40),ponmzsidey(0,25,-40); |
---|
| 55 | |
---|
| 56 | G4ThreeVector pbigx(100,0,0),pbigy(0,100,0),pbigz(0,0,100), pbig(100,100,100); |
---|
| 57 | G4ThreeVector pbigmx(-100,0,0),pbigmy(0,-100,0),pbigmz(0,0,-100); |
---|
| 58 | |
---|
| 59 | G4ThreeVector vx(1,0,0),vy(0,1,0),vz(0,0,1); |
---|
| 60 | G4ThreeVector vmx(-1,0,0),vmy(0,-1,0),vmz(0,0,-1); |
---|
| 61 | G4ThreeVector vxy(1/std::sqrt(2.0),1/std::sqrt(2.0),0); |
---|
| 62 | G4ThreeVector vmxy(-1/std::sqrt(2.0),1/std::sqrt(2.0),0); |
---|
| 63 | G4ThreeVector vmxmy(-1/std::sqrt(2.0),-1/std::sqrt(2.0),0); |
---|
| 64 | G4ThreeVector vxmy(1/std::sqrt(2.0),-1/std::sqrt(2.0),0); |
---|
| 65 | |
---|
| 66 | G4ThreeVector vxmz(1/std::sqrt(2.0),0,-1/std::sqrt(2.0)); |
---|
| 67 | G4ThreeVector vymz(0,1/std::sqrt(2.0),-1/std::sqrt(2.0)); |
---|
| 68 | G4ThreeVector vmxmz(-1/std::sqrt(2.0),0,-1/std::sqrt(2.0)); |
---|
| 69 | G4ThreeVector vmymz(0,-1/std::sqrt(2.0),-1/std::sqrt(2.0)); |
---|
| 70 | G4ThreeVector vxz(1/std::sqrt(2.0),0,1/std::sqrt(2.0)); |
---|
| 71 | G4ThreeVector vyz(0,1/std::sqrt(2.0),1/std::sqrt(2.0)); |
---|
| 72 | |
---|
| 73 | G4double Dist, dist, vol, volCheck ; |
---|
| 74 | G4ThreeVector *pNorm,norm; |
---|
| 75 | G4bool *pgoodNorm,goodNorm,calcNorm=true; |
---|
| 76 | |
---|
| 77 | pNorm=&norm; |
---|
| 78 | pgoodNorm=&goodNorm; |
---|
| 79 | |
---|
| 80 | G4ThreeVector trapvert[8] = { G4ThreeVector(-10.0,-20.0,-40.0), |
---|
| 81 | G4ThreeVector(+10.0,-20.0,-40.0), |
---|
| 82 | G4ThreeVector(-10.0,+20.0,-40.0), |
---|
| 83 | G4ThreeVector(+10.0,+20.0,-40.0), |
---|
| 84 | G4ThreeVector(-30.0,-40.0,+40.0), |
---|
| 85 | G4ThreeVector(+30.0,-40.0,+40.0), |
---|
| 86 | G4ThreeVector(-30.0,+40.0,+40.0), |
---|
| 87 | G4ThreeVector(+30.0,+40.0,+40.0) } ; |
---|
| 88 | |
---|
| 89 | G4Trap trap1("Test Boxlike #1",40,0,0,30,20,20,0,30,20,20,0); // box:20,30,40 |
---|
| 90 | |
---|
| 91 | // G4Trap trap2("Test Trdlike #2",40,0,0,20,10,10,0,40,30,30,0); |
---|
| 92 | |
---|
| 93 | G4Trap trap2("Test Trdlike #2",trapvert); |
---|
| 94 | |
---|
| 95 | G4Trap trap3("trap3",50,0,0,50,50,50,pi/4,50,50,50,pi/4) ; |
---|
| 96 | G4Trap trap4("trap4",50,0,0,50,50,50,-pi/4,50,50,50,-pi/4) ; |
---|
| 97 | |
---|
| 98 | G4ThreeVector Corners[8]; |
---|
| 99 | |
---|
| 100 | Corners[0].setX(-3.); |
---|
| 101 | Corners[0].setY(-3.); |
---|
| 102 | Corners[0].setZ(-3.); |
---|
| 103 | |
---|
| 104 | Corners[1].setX( 3.); |
---|
| 105 | Corners[1].setY(-3.); |
---|
| 106 | Corners[1].setZ(-3.); |
---|
| 107 | |
---|
| 108 | Corners[2].setX(-3.); |
---|
| 109 | Corners[2].setY( 3.); |
---|
| 110 | Corners[2].setZ(-3.); |
---|
| 111 | |
---|
| 112 | Corners[3].setX( 3.); |
---|
| 113 | Corners[3].setY( 3.); |
---|
| 114 | Corners[3].setZ(-3.); |
---|
| 115 | |
---|
| 116 | Corners[4].setX(-3.); |
---|
| 117 | Corners[4].setY(-3.); |
---|
| 118 | Corners[4].setZ( 3.); |
---|
| 119 | |
---|
| 120 | // Corners[5].setX( 1); |
---|
| 121 | Corners[5].setX( 3.); |
---|
| 122 | Corners[5].setY(-3.); |
---|
| 123 | Corners[5].setZ( 3.); |
---|
| 124 | |
---|
| 125 | Corners[6].setX(-3.); |
---|
| 126 | Corners[6].setY( 3.); |
---|
| 127 | Corners[6].setZ( 3.); |
---|
| 128 | |
---|
| 129 | // Corners[7].setX( 1); |
---|
| 130 | Corners[7].setX( 3); |
---|
| 131 | Corners[7].setY( 3); |
---|
| 132 | Corners[7].setZ( 3); |
---|
| 133 | |
---|
| 134 | G4Trap tempTrap("temp trap", Corners); |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | // Check name |
---|
| 138 | |
---|
| 139 | assert(trap1.GetName()=="Test Boxlike #1"); |
---|
| 140 | assert(trap2.GetName()=="Test Trdlike #2"); |
---|
| 141 | |
---|
| 142 | // Check cubic volume |
---|
| 143 | |
---|
| 144 | vol = trap1.GetCubicVolume(); |
---|
| 145 | volCheck = 8*20*30*40; |
---|
| 146 | assert(ApproxEqual(vol,volCheck)); |
---|
| 147 | |
---|
| 148 | vol = trap4.GetCubicVolume(); |
---|
| 149 | volCheck = 8*50*50*50; |
---|
| 150 | assert(ApproxEqual(vol,volCheck)); |
---|
| 151 | |
---|
| 152 | vol = trap3.GetCubicVolume(); |
---|
| 153 | volCheck = 8*50*50*50; |
---|
| 154 | assert(ApproxEqual(vol,volCheck)); |
---|
| 155 | |
---|
| 156 | vol = trap2.GetCubicVolume(); |
---|
| 157 | volCheck = 2*40.*( (20.+40.)*(10.+30.) + (30.-10.)*(40.-20.)/3. ); |
---|
| 158 | assert(ApproxEqual(vol,volCheck)); |
---|
| 159 | |
---|
| 160 | |
---|
| 161 | // Check Inside |
---|
| 162 | |
---|
| 163 | assert(trap1.Inside(pzero)==kInside); |
---|
| 164 | assert(trap1.Inside(pbigz)==kOutside); |
---|
| 165 | assert(trap1.Inside(ponxside)==kSurface); |
---|
| 166 | assert(trap1.Inside(ponyside)==kSurface); |
---|
| 167 | assert(trap1.Inside(ponzside)==kSurface); |
---|
| 168 | |
---|
| 169 | assert(trap2.Inside(pzero)==kInside); |
---|
| 170 | assert(trap2.Inside(pbigz)==kOutside); |
---|
| 171 | assert(trap2.Inside(ponxside)==kSurface); |
---|
| 172 | assert(trap2.Inside(ponyside)==kSurface); |
---|
| 173 | assert(trap2.Inside(ponzside)==kSurface); |
---|
| 174 | |
---|
| 175 | // Check Surface Normal |
---|
| 176 | |
---|
| 177 | G4ThreeVector normal; |
---|
| 178 | |
---|
| 179 | normal=trap1.SurfaceNormal(ponxside); |
---|
| 180 | assert(ApproxEqual(normal,G4ThreeVector(1.,0.,0.))); |
---|
| 181 | normal=trap1.SurfaceNormal(ponmxside); |
---|
| 182 | assert(ApproxEqual(normal,G4ThreeVector(-1.,0.,0.))); |
---|
| 183 | normal=trap1.SurfaceNormal(ponyside); |
---|
| 184 | assert(ApproxEqual(normal,G4ThreeVector(0.,1.,0.))); |
---|
| 185 | normal=trap1.SurfaceNormal(ponmyside); |
---|
| 186 | assert(ApproxEqual(normal,G4ThreeVector(0.,-1.,0.))); |
---|
| 187 | normal=trap1.SurfaceNormal(ponzside); |
---|
| 188 | assert(ApproxEqual(normal,G4ThreeVector(0.,0.,1.))); |
---|
| 189 | normal=trap1.SurfaceNormal(ponmzside); |
---|
| 190 | assert(ApproxEqual(normal,G4ThreeVector(0.,0.,-1.))); |
---|
| 191 | normal=trap1.SurfaceNormal(ponzsidey); |
---|
| 192 | assert(ApproxEqual(normal,G4ThreeVector(0.,0.,1.))); |
---|
| 193 | normal=trap1.SurfaceNormal(ponmzsidey); |
---|
| 194 | assert(ApproxEqual(normal,G4ThreeVector(0.,0.,-1.))); |
---|
| 195 | |
---|
| 196 | // Normals on Edges |
---|
| 197 | |
---|
| 198 | G4ThreeVector edgeXY( 20.0, 30., 0.0); |
---|
| 199 | G4ThreeVector edgemXmY( -20.0, -30., 0.0); |
---|
| 200 | G4ThreeVector edgeXmY( 20.0, -30., 0.0); |
---|
| 201 | G4ThreeVector edgemXY( -20.0, 30., 0.0); |
---|
| 202 | G4ThreeVector edgeXZ( 20.0, 0.0, 40.0); |
---|
| 203 | G4ThreeVector edgemXmZ( -20.0, 0.0, -40.0); |
---|
| 204 | G4ThreeVector edgeXmZ( 20.0, 0.0, -40.0); |
---|
| 205 | G4ThreeVector edgemXZ( -20.0, 0.0, 40.0); |
---|
| 206 | G4ThreeVector edgeYZ( 0.0, 30.0, 40.0); |
---|
| 207 | G4ThreeVector edgemYmZ( 0.0, -30.0, -40.0); |
---|
| 208 | G4ThreeVector edgeYmZ( 0.0, 30.0, -40.0); |
---|
| 209 | G4ThreeVector edgemYZ( 0.0, -30.0, 40.0); |
---|
| 210 | |
---|
| 211 | G4double invSqrt2 = 1.0 / std::sqrt( 2.0); |
---|
| 212 | G4double invSqrt3 = 1.0 / std::sqrt( 3.0); |
---|
| 213 | |
---|
| 214 | normal= trap1.SurfaceNormal( edgeXY ); |
---|
| 215 | assert(ApproxEqual( normal, G4ThreeVector( invSqrt2, invSqrt2, 0.0) )); |
---|
| 216 | |
---|
| 217 | // G4cout << " Normal at " << edgeXY << " is " << normal |
---|
| 218 | // << " Expected is " << G4ThreeVector( invSqrt2, invSqrt2, 0.0) << G4endl; |
---|
| 219 | |
---|
| 220 | normal= trap1.SurfaceNormal( edgemXmY ); |
---|
| 221 | assert(ApproxEqual( normal, G4ThreeVector( -invSqrt2, -invSqrt2, 0.0) )); |
---|
| 222 | normal= trap1.SurfaceNormal( edgeXmY ); |
---|
| 223 | assert(ApproxEqual( normal, G4ThreeVector( invSqrt2, -invSqrt2, 0.0) )); |
---|
| 224 | normal= trap1.SurfaceNormal( edgemXY ); |
---|
| 225 | assert(ApproxEqual( normal, G4ThreeVector( -invSqrt2, invSqrt2, 0.0) )); |
---|
| 226 | |
---|
| 227 | normal= trap1.SurfaceNormal( edgeXZ ); |
---|
| 228 | assert(ApproxEqual( normal, G4ThreeVector( invSqrt2, 0.0, invSqrt2) )); |
---|
| 229 | normal= trap1.SurfaceNormal( edgemXmZ ); |
---|
| 230 | assert(ApproxEqual( normal, G4ThreeVector( -invSqrt2, 0.0, -invSqrt2) )); |
---|
| 231 | normal= trap1.SurfaceNormal( edgeXmZ ); |
---|
| 232 | assert(ApproxEqual( normal, G4ThreeVector( invSqrt2, 0.0, -invSqrt2) )); |
---|
| 233 | normal= trap1.SurfaceNormal( edgemXZ ); |
---|
| 234 | assert(ApproxEqual( normal, G4ThreeVector( -invSqrt2, 0.0, invSqrt2) )); |
---|
| 235 | |
---|
| 236 | normal= trap1.SurfaceNormal( edgeYZ ); |
---|
| 237 | assert(ApproxEqual( normal, G4ThreeVector( 0.0, invSqrt2, invSqrt2) )); |
---|
| 238 | normal= trap1.SurfaceNormal( edgemYmZ ); |
---|
| 239 | assert(ApproxEqual( normal, G4ThreeVector( 0.0, -invSqrt2, -invSqrt2) )); |
---|
| 240 | normal= trap1.SurfaceNormal( edgeYmZ ); |
---|
| 241 | assert(ApproxEqual( normal, G4ThreeVector( 0.0, invSqrt2, -invSqrt2) )); |
---|
| 242 | normal= trap1.SurfaceNormal( edgemYZ ); |
---|
| 243 | assert(ApproxEqual( normal, G4ThreeVector( 0.0, -invSqrt2, invSqrt2) )); |
---|
| 244 | |
---|
| 245 | // Normals on corners |
---|
| 246 | |
---|
| 247 | G4ThreeVector cornerXYZ( 20.0, 30., 40.0); |
---|
| 248 | G4ThreeVector cornermXYZ( -20.0, 30., 40.0); |
---|
| 249 | G4ThreeVector cornerXmYZ( 20.0, -30., 40.0); |
---|
| 250 | G4ThreeVector cornermXmYZ( -20.0, -30., 40.0); |
---|
| 251 | G4ThreeVector cornerXYmZ( 20.0, 30., -40.0); |
---|
| 252 | G4ThreeVector cornermXYmZ( -20.0, 30., -40.0); |
---|
| 253 | G4ThreeVector cornerXmYmZ( 20.0, -30., -40.0); |
---|
| 254 | G4ThreeVector cornermXmYmZ( -20.0, -30., -40.0); |
---|
| 255 | |
---|
| 256 | normal= trap1.SurfaceNormal( cornerXYZ ); |
---|
| 257 | assert(ApproxEqual( normal, G4ThreeVector( invSqrt3, invSqrt3, invSqrt3) )); |
---|
| 258 | normal= trap1.SurfaceNormal( cornermXYZ ); |
---|
| 259 | assert(ApproxEqual( normal, G4ThreeVector( -invSqrt3, invSqrt3, invSqrt3) )); |
---|
| 260 | normal= trap1.SurfaceNormal( cornerXmYZ ); |
---|
| 261 | assert(ApproxEqual( normal, G4ThreeVector( invSqrt3, -invSqrt3, invSqrt3) )); |
---|
| 262 | normal= trap1.SurfaceNormal( cornermXmYZ ); |
---|
| 263 | assert(ApproxEqual( normal, G4ThreeVector( -invSqrt3, -invSqrt3, invSqrt3) )); |
---|
| 264 | normal= trap1.SurfaceNormal( cornerXYmZ ); |
---|
| 265 | assert(ApproxEqual( normal, G4ThreeVector( invSqrt3, invSqrt3, -invSqrt3) )); |
---|
| 266 | normal= trap1.SurfaceNormal( cornermXYmZ ); |
---|
| 267 | assert(ApproxEqual( normal, G4ThreeVector( -invSqrt3, invSqrt3, -invSqrt3) )); |
---|
| 268 | normal= trap1.SurfaceNormal( cornerXmYmZ ); |
---|
| 269 | assert(ApproxEqual( normal, G4ThreeVector( invSqrt3, -invSqrt3, -invSqrt3) )); |
---|
| 270 | normal= trap1.SurfaceNormal( cornermXmYmZ ); |
---|
| 271 | assert(ApproxEqual( normal, G4ThreeVector( -invSqrt3, -invSqrt3, -invSqrt3) )); |
---|
| 272 | |
---|
| 273 | |
---|
| 274 | |
---|
| 275 | |
---|
| 276 | |
---|
| 277 | |
---|
| 278 | |
---|
| 279 | |
---|
| 280 | double cosa = 4/std::sqrt(17.), sina = 1/std::sqrt(17.), tanga = 1.0/4.0 ; |
---|
| 281 | |
---|
| 282 | normal=trap2.SurfaceNormal(ponxside); |
---|
| 283 | assert(ApproxEqual(normal,G4ThreeVector(cosa,0,-sina))); |
---|
| 284 | normal=trap2.SurfaceNormal(ponmxside); |
---|
| 285 | assert(ApproxEqual(normal,G4ThreeVector(-cosa,0,-sina))); |
---|
| 286 | normal=trap2.SurfaceNormal(ponyside); |
---|
| 287 | assert(ApproxEqual(normal,G4ThreeVector(0,cosa,-sina))); |
---|
| 288 | normal=trap2.SurfaceNormal(ponmyside); |
---|
| 289 | assert(ApproxEqual(normal,G4ThreeVector(0,-cosa,-sina))); |
---|
| 290 | normal=trap2.SurfaceNormal(ponzside); |
---|
| 291 | assert(ApproxEqual(normal,G4ThreeVector(0,0,1))); |
---|
| 292 | normal=trap2.SurfaceNormal(ponmzside); |
---|
| 293 | assert(ApproxEqual(normal,G4ThreeVector(0,0,-1))); |
---|
| 294 | normal=trap2.SurfaceNormal(ponzsidey); |
---|
| 295 | assert(ApproxEqual(normal,G4ThreeVector(0,0,1))); |
---|
| 296 | normal=trap2.SurfaceNormal(ponmzsidey); |
---|
| 297 | assert(ApproxEqual(normal,G4ThreeVector(0,0,-1))); // (0,cosa,-sina) ? |
---|
| 298 | |
---|
| 299 | // DistanceToOut(P) |
---|
| 300 | |
---|
| 301 | Dist=trap1.DistanceToOut(pzero); |
---|
| 302 | assert(ApproxEqual(Dist,20)); |
---|
| 303 | Dist=trap1.DistanceToOut(vx); |
---|
| 304 | assert(ApproxEqual(Dist,19)); |
---|
| 305 | Dist=trap1.DistanceToOut(vy); |
---|
| 306 | assert(ApproxEqual(Dist,20)); |
---|
| 307 | Dist=trap1.DistanceToOut(vz); |
---|
| 308 | assert(ApproxEqual(Dist,20)); |
---|
| 309 | |
---|
| 310 | Dist=trap2.DistanceToOut(pzero); |
---|
| 311 | assert(ApproxEqual(Dist,20*cosa)); |
---|
| 312 | Dist=trap2.DistanceToOut(vx); |
---|
| 313 | assert(ApproxEqual(Dist,19*cosa)); |
---|
| 314 | Dist=trap2.DistanceToOut(vy); |
---|
| 315 | assert(ApproxEqual(Dist,20*cosa)); |
---|
| 316 | Dist=trap2.DistanceToOut(vz); |
---|
| 317 | assert(ApproxEqual(Dist,20*cosa+sina)); |
---|
| 318 | |
---|
| 319 | |
---|
| 320 | // DistanceToOut(P,V) |
---|
| 321 | |
---|
| 322 | Dist=trap1.DistanceToOut(pzero,vx,calcNorm,pgoodNorm,pNorm); |
---|
| 323 | assert(ApproxEqual(Dist,20)&&ApproxEqual(*pNorm,vx)&&*pgoodNorm); |
---|
| 324 | Dist=trap1.DistanceToOut(pzero,vmx,calcNorm,pgoodNorm,pNorm); |
---|
| 325 | assert(ApproxEqual(Dist,20)&&ApproxEqual(norm,vmx)&&*pgoodNorm); |
---|
| 326 | Dist=trap1.DistanceToOut(pzero,vy,calcNorm,pgoodNorm,pNorm); |
---|
| 327 | assert(ApproxEqual(Dist,30)&&ApproxEqual(norm,vy)&&*pgoodNorm); |
---|
| 328 | Dist=trap1.DistanceToOut(pzero,vmy,calcNorm,pgoodNorm,pNorm); |
---|
| 329 | assert(ApproxEqual(Dist,30)&&ApproxEqual(norm,vmy)&&*pgoodNorm); |
---|
| 330 | Dist=trap1.DistanceToOut(pzero,vz,calcNorm,pgoodNorm,pNorm); |
---|
| 331 | assert(ApproxEqual(Dist,40)&&ApproxEqual(norm,vz)&&*pgoodNorm); |
---|
| 332 | Dist=trap1.DistanceToOut(pzero,vmz,calcNorm,pgoodNorm,pNorm); |
---|
| 333 | assert(ApproxEqual(Dist,40)&&ApproxEqual(norm,vmz)&&*pgoodNorm); |
---|
| 334 | Dist=trap1.DistanceToOut(pzero,vxy,calcNorm,pgoodNorm,pNorm); |
---|
| 335 | assert(ApproxEqual(Dist,std::sqrt(800.))&&*pgoodNorm); |
---|
| 336 | |
---|
| 337 | Dist=trap1.DistanceToOut(ponxside,vx,calcNorm,pgoodNorm,pNorm); |
---|
| 338 | assert(ApproxEqual(Dist,0)&&ApproxEqual(*pNorm,vx)&&*pgoodNorm); |
---|
| 339 | Dist=trap1.DistanceToOut(ponmxside,vmx,calcNorm,pgoodNorm,pNorm); |
---|
| 340 | assert(ApproxEqual(Dist,0)&&ApproxEqual(norm,vmx)&&*pgoodNorm); |
---|
| 341 | Dist=trap1.DistanceToOut(ponyside,vy,calcNorm,pgoodNorm,pNorm); |
---|
| 342 | assert(ApproxEqual(Dist,0)&&ApproxEqual(norm,vy)&&*pgoodNorm); |
---|
| 343 | Dist=trap1.DistanceToOut(ponmyside,vmy,calcNorm,pgoodNorm,pNorm); |
---|
| 344 | assert(ApproxEqual(Dist,0)&&ApproxEqual(norm,vmy)&&*pgoodNorm); |
---|
| 345 | Dist=trap1.DistanceToOut(ponzside,vz,calcNorm,pgoodNorm,pNorm); |
---|
| 346 | assert(ApproxEqual(Dist,0)&&ApproxEqual(norm,vz)&&*pgoodNorm); |
---|
| 347 | Dist=trap1.DistanceToOut(ponmzside,vmz,calcNorm,pgoodNorm,pNorm); |
---|
| 348 | assert(ApproxEqual(Dist,0)&&ApproxEqual(norm,vmz)&&*pgoodNorm); |
---|
| 349 | |
---|
| 350 | Dist=trap2.DistanceToOut(pzero,vx,calcNorm,pgoodNorm,pNorm); |
---|
| 351 | assert(ApproxEqual(Dist,20)&&ApproxEqual(*pNorm,G4ThreeVector(cosa,0,-sina))&&*pgoodNorm); |
---|
| 352 | Dist=trap2.DistanceToOut(pzero,vmx,calcNorm,pgoodNorm,pNorm); |
---|
| 353 | assert(ApproxEqual(Dist,20)&&ApproxEqual(norm,G4ThreeVector(-cosa,0,-sina))&&*pgoodNorm); |
---|
| 354 | Dist=trap2.DistanceToOut(pzero,vy,calcNorm,pgoodNorm,pNorm); |
---|
| 355 | assert(ApproxEqual(Dist,30)&&ApproxEqual(norm,G4ThreeVector(0,cosa,-sina))&&*pgoodNorm); |
---|
| 356 | Dist=trap2.DistanceToOut(pzero,vmy,calcNorm,pgoodNorm,pNorm); |
---|
| 357 | assert(ApproxEqual(Dist,30)&&ApproxEqual(norm,G4ThreeVector(0,-cosa,-sina))&&*pgoodNorm); |
---|
| 358 | Dist=trap2.DistanceToOut(pzero,vz,calcNorm,pgoodNorm,pNorm); |
---|
| 359 | assert(ApproxEqual(Dist,40)&&ApproxEqual(norm,vz)&&*pgoodNorm); |
---|
| 360 | Dist=trap2.DistanceToOut(pzero,vmz,calcNorm,pgoodNorm,pNorm); |
---|
| 361 | assert(ApproxEqual(Dist,40)&&ApproxEqual(norm,vmz)&&*pgoodNorm); |
---|
| 362 | Dist=trap2.DistanceToOut(pzero,vxy,calcNorm,pgoodNorm,pNorm); |
---|
| 363 | assert(ApproxEqual(Dist,std::sqrt(800.))&&*pgoodNorm); |
---|
| 364 | |
---|
| 365 | Dist=trap2.DistanceToOut(ponxside,vx,calcNorm,pgoodNorm,pNorm); |
---|
| 366 | assert(ApproxEqual(Dist,0)&&ApproxEqual(*pNorm,G4ThreeVector(cosa,0,-sina))&&*pgoodNorm); |
---|
| 367 | Dist=trap2.DistanceToOut(ponmxside,vmx,calcNorm,pgoodNorm,pNorm); |
---|
| 368 | assert(ApproxEqual(Dist,0)&&ApproxEqual(norm,G4ThreeVector(-cosa,0,-sina))&&*pgoodNorm); |
---|
| 369 | Dist=trap2.DistanceToOut(ponyside,vy,calcNorm,pgoodNorm,pNorm); |
---|
| 370 | assert(ApproxEqual(Dist,0)&&ApproxEqual(norm,G4ThreeVector(0,cosa,-sina))&&*pgoodNorm); |
---|
| 371 | Dist=trap2.DistanceToOut(ponmyside,vmy,calcNorm,pgoodNorm,pNorm); |
---|
| 372 | assert(ApproxEqual(Dist,0)&&ApproxEqual(norm,G4ThreeVector(0,-cosa,-sina))&&*pgoodNorm); |
---|
| 373 | Dist=trap2.DistanceToOut(ponzside,vz,calcNorm,pgoodNorm,pNorm); |
---|
| 374 | assert(ApproxEqual(Dist,0)&&ApproxEqual(norm,vz)&&*pgoodNorm); |
---|
| 375 | Dist=trap2.DistanceToOut(ponmzside,vmz,calcNorm,pgoodNorm,pNorm); |
---|
| 376 | assert(ApproxEqual(Dist,0)&&ApproxEqual(norm,vmz)&&*pgoodNorm); |
---|
| 377 | |
---|
| 378 | |
---|
| 379 | //DistanceToIn(P) |
---|
| 380 | |
---|
| 381 | Dist=trap1.DistanceToIn(pbig); |
---|
| 382 | // G4cout<<"trap1.DistanceToIn(pbig) = "<<Dist<<G4endl; |
---|
| 383 | assert(ApproxEqual(Dist,80)); |
---|
| 384 | |
---|
| 385 | Dist=trap1.DistanceToIn(pbigx); |
---|
| 386 | assert(ApproxEqual(Dist,80)); |
---|
| 387 | |
---|
| 388 | Dist=trap1.DistanceToIn(pbigmx); |
---|
| 389 | assert(ApproxEqual(Dist,80)); |
---|
| 390 | |
---|
| 391 | Dist=trap1.DistanceToIn(pbigy); |
---|
| 392 | assert(ApproxEqual(Dist,70)); |
---|
| 393 | |
---|
| 394 | Dist=trap1.DistanceToIn(pbigmy); |
---|
| 395 | assert(ApproxEqual(Dist,70)); |
---|
| 396 | |
---|
| 397 | Dist=trap1.DistanceToIn(pbigz); |
---|
| 398 | assert(ApproxEqual(Dist,60)); |
---|
| 399 | |
---|
| 400 | Dist=trap1.DistanceToIn(pbigmz); |
---|
| 401 | assert(ApproxEqual(Dist,60)); |
---|
| 402 | |
---|
| 403 | Dist=trap2.DistanceToIn(pbigx); |
---|
| 404 | assert(ApproxEqual(Dist,80*cosa)); |
---|
| 405 | Dist=trap2.DistanceToIn(pbigmx); |
---|
| 406 | assert(ApproxEqual(Dist,80*cosa)); |
---|
| 407 | Dist=trap2.DistanceToIn(pbigy); |
---|
| 408 | assert(ApproxEqual(Dist,70*cosa)); |
---|
| 409 | Dist=trap2.DistanceToIn(pbigmy); |
---|
| 410 | assert(ApproxEqual(Dist,70*cosa)); |
---|
| 411 | Dist=trap2.DistanceToIn(pbigz); |
---|
| 412 | assert(ApproxEqual(Dist,60)); |
---|
| 413 | Dist=trap2.DistanceToIn(pbigmz); |
---|
| 414 | assert(ApproxEqual(Dist,60)); |
---|
| 415 | |
---|
| 416 | |
---|
| 417 | // DistanceToIn(P,V) |
---|
| 418 | |
---|
| 419 | Dist=trap1.DistanceToIn(pbigx,vmx); |
---|
| 420 | assert(ApproxEqual(Dist,80)); |
---|
| 421 | Dist=trap1.DistanceToIn(pbigmx,vx); |
---|
| 422 | assert(ApproxEqual(Dist,80)); |
---|
| 423 | Dist=trap1.DistanceToIn(pbigy,vmy); |
---|
| 424 | assert(ApproxEqual(Dist,70)); |
---|
| 425 | Dist=trap1.DistanceToIn(pbigmy,vy); |
---|
| 426 | assert(ApproxEqual(Dist,70)); |
---|
| 427 | Dist=trap1.DistanceToIn(pbigz,vmz); |
---|
| 428 | assert(ApproxEqual(Dist,60)); |
---|
| 429 | Dist=trap1.DistanceToIn(pbigmz,vz); |
---|
| 430 | assert(ApproxEqual(Dist,60)); |
---|
| 431 | Dist=trap1.DistanceToIn(pbigx,vxy); |
---|
| 432 | assert(ApproxEqual(Dist,kInfinity)); |
---|
| 433 | Dist=trap1.DistanceToIn(pbigmx,vxy); |
---|
| 434 | assert(ApproxEqual(Dist,kInfinity)); |
---|
| 435 | |
---|
| 436 | Dist=trap2.DistanceToIn(pbigx,vmx); |
---|
| 437 | assert(ApproxEqual(Dist,80)); |
---|
| 438 | Dist=trap2.DistanceToIn(pbigmx,vx); |
---|
| 439 | assert(ApproxEqual(Dist,80)); |
---|
| 440 | Dist=trap2.DistanceToIn(pbigy,vmy); |
---|
| 441 | assert(ApproxEqual(Dist,70)); |
---|
| 442 | Dist=trap2.DistanceToIn(pbigmy,vy); |
---|
| 443 | assert(ApproxEqual(Dist,70)); |
---|
| 444 | Dist=trap2.DistanceToIn(pbigz,vmz); |
---|
| 445 | assert(ApproxEqual(Dist,60)); |
---|
| 446 | Dist=trap2.DistanceToIn(pbigmz,vz); |
---|
| 447 | assert(ApproxEqual(Dist,60)); |
---|
| 448 | Dist=trap2.DistanceToIn(pbigx,vxy); |
---|
| 449 | assert(ApproxEqual(Dist,kInfinity)); |
---|
| 450 | Dist=trap2.DistanceToIn(pbigmx,vxy); |
---|
| 451 | assert(ApproxEqual(Dist,kInfinity)); |
---|
| 452 | |
---|
| 453 | dist=trap3.DistanceToIn(G4ThreeVector(50,-50,0),vy); |
---|
| 454 | // G4cout<<"trap3.DistanceToIn(G4ThreeVector(50,-50,0),vy) = "<<dist<<G4endl ; |
---|
| 455 | assert(ApproxEqual(dist,50)); |
---|
| 456 | |
---|
| 457 | dist=trap3.DistanceToIn(G4ThreeVector(50,-50,0),vmy); |
---|
| 458 | // G4cout<<"trap3.DistanceToIn(G4ThreeVector(50,-50,0),vmy) = "<<dist<<G4endl ; |
---|
| 459 | assert(ApproxEqual(dist,kInfinity)); |
---|
| 460 | |
---|
| 461 | dist=trap4.DistanceToIn(G4ThreeVector(50,50,0),vy); |
---|
| 462 | // G4cout<<"trap4.DistanceToIn(G4ThreeVector(50,50,0),vy) = "<<dist<<G4endl ; |
---|
| 463 | assert(ApproxEqual(dist,kInfinity)); |
---|
| 464 | |
---|
| 465 | dist=trap4.DistanceToIn(G4ThreeVector(50,50,0),vmy); |
---|
| 466 | // G4cout<<"trap4.DistanceToIn(G4ThreeVector(50,50,0),vmy) = "<<dist<<G4endl ; |
---|
| 467 | assert(ApproxEqual(dist,50)); |
---|
| 468 | |
---|
| 469 | dist=trap1.DistanceToIn(G4ThreeVector(0,60,0),vxmy); |
---|
| 470 | // G4cout<<"trap1.DistanceToIn(G4ThreeVector(0,60,0),vxmy) = "<<dist<<G4endl ; |
---|
| 471 | assert(ApproxEqual(dist,kInfinity)); |
---|
| 472 | |
---|
| 473 | dist=trap1.DistanceToIn(G4ThreeVector(0,50,0),vxmy); |
---|
| 474 | // G4cout<<"trap1.DistanceToIn(G4ThreeVector(0,50,0),vxmy) = "<<dist<<G4endl ; |
---|
| 475 | assert(ApproxEqual(dist,kInfinity)); |
---|
| 476 | |
---|
| 477 | dist=trap1.DistanceToIn(G4ThreeVector(0,40,0),vxmy); |
---|
| 478 | // G4cout<<"trap1.DistanceToIn(G4ThreeVector(0,40,0),vxmy) = "<<dist<<G4endl ; |
---|
| 479 | assert(ApproxEqual(dist,10.0*std::sqrt(2.0))); |
---|
| 480 | |
---|
| 481 | dist=trap1.DistanceToIn(G4ThreeVector(0,40,50),vxmy); |
---|
| 482 | // G4cout<<"trap1.DistanceToIn(G4ThreeVector(0,40,50),vxmy) = "<<dist<<G4endl ; |
---|
| 483 | assert(ApproxEqual(dist,kInfinity)); |
---|
| 484 | |
---|
| 485 | // Parallel to side planes |
---|
| 486 | |
---|
| 487 | dist=trap1.DistanceToIn(G4ThreeVector(40,60,0),vmx); |
---|
| 488 | // G4cout<<"trap1.DistanceToIn(G4ThreeVector(40,60,0),vmx) = "<<dist<<G4endl ; |
---|
| 489 | assert(ApproxEqual(dist,kInfinity)); |
---|
| 490 | |
---|
| 491 | dist=trap1.DistanceToIn(G4ThreeVector(40,60,0),vmy); |
---|
| 492 | // G4cout<<"trap1.DistanceToIn(G4ThreeVector(40,60,0),vmy) = "<<dist<<G4endl ; |
---|
| 493 | assert(ApproxEqual(dist,kInfinity)); |
---|
| 494 | |
---|
| 495 | dist=trap1.DistanceToIn(G4ThreeVector(40,60,50),vmz); |
---|
| 496 | // G4cout<<"trap1.DistanceToIn(G4ThreeVector(40,60,50),vmz) = "<<dist<<G4endl ; |
---|
| 497 | assert(ApproxEqual(dist,kInfinity)); |
---|
| 498 | |
---|
| 499 | dist=trap1.DistanceToIn(G4ThreeVector(0,0,50),vymz); |
---|
| 500 | // G4cout<<"trap1.DistanceToIn(G4ThreeVector(0,0,50),vymz) = "<<dist<<G4endl ; |
---|
| 501 | assert(ApproxEqual(dist,10.0*std::sqrt(2.0))); |
---|
| 502 | |
---|
| 503 | dist=trap1.DistanceToIn(G4ThreeVector(0,0,80),vymz); |
---|
| 504 | // G4cout<<"trap1.DistanceToIn(G4ThreeVector(0,0,80),vymz) = "<<dist<<G4endl ; |
---|
| 505 | assert(ApproxEqual(dist,kInfinity)); |
---|
| 506 | |
---|
| 507 | dist=trap1.DistanceToIn(G4ThreeVector(0,0,70),vymz); |
---|
| 508 | // G4cout<<"trap1.DistanceToIn(G4ThreeVector(0,0,70),vymz) = "<<dist<<G4endl ; |
---|
| 509 | assert(ApproxEqual(dist,kInfinity)); |
---|
| 510 | |
---|
| 511 | // CalculateExtent |
---|
| 512 | |
---|
| 513 | G4VoxelLimits limit; // Unlimited |
---|
| 514 | G4AffineTransform origin(pzero); |
---|
| 515 | G4double min,max; |
---|
| 516 | |
---|
| 517 | assert(trap1.CalculateExtent(kXAxis,limit,origin,min,max)); |
---|
| 518 | assert(ApproxEqual(min,-20)&&ApproxEqual(max,20)); |
---|
| 519 | assert(trap1.CalculateExtent(kYAxis,limit,origin,min,max)); |
---|
| 520 | assert(ApproxEqual(min,-30)&&ApproxEqual(max,30)); |
---|
| 521 | assert(trap1.CalculateExtent(kZAxis,limit,origin,min,max)); |
---|
| 522 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 523 | |
---|
| 524 | assert(trap2.CalculateExtent(kXAxis,limit,origin,min,max)); |
---|
| 525 | assert(ApproxEqual(min,-30)&&ApproxEqual(max,30)); |
---|
| 526 | assert(trap2.CalculateExtent(kYAxis,limit,origin,min,max)); |
---|
| 527 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 528 | assert(trap2.CalculateExtent(kZAxis,limit,origin,min,max)); |
---|
| 529 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 530 | |
---|
| 531 | |
---|
| 532 | G4ThreeVector pmxmymz(-100,-110,-120); |
---|
| 533 | G4AffineTransform tPosOnly(pmxmymz); |
---|
| 534 | |
---|
| 535 | assert(trap1.CalculateExtent(kXAxis,limit,tPosOnly,min,max)); |
---|
| 536 | assert(ApproxEqual(min,-120)&&ApproxEqual(max,-80)); |
---|
| 537 | assert(trap1.CalculateExtent(kYAxis,limit,tPosOnly,min,max)); |
---|
| 538 | assert(ApproxEqual(min,-140)&&ApproxEqual(max,-80)); |
---|
| 539 | assert(trap1.CalculateExtent(kZAxis,limit,tPosOnly,min,max)); |
---|
| 540 | assert(ApproxEqual(min,-160)&&ApproxEqual(max,-80)); |
---|
| 541 | |
---|
| 542 | assert(trap2.CalculateExtent(kXAxis,limit,tPosOnly,min,max)); |
---|
| 543 | assert(ApproxEqual(min,-130)&&ApproxEqual(max,-70)); |
---|
| 544 | assert(trap2.CalculateExtent(kYAxis,limit,tPosOnly,min,max)); |
---|
| 545 | assert(ApproxEqual(min,-150)&&ApproxEqual(max,-70)); |
---|
| 546 | assert(trap2.CalculateExtent(kZAxis,limit,tPosOnly,min,max)); |
---|
| 547 | assert(ApproxEqual(min,-160)&&ApproxEqual(max,-80)); |
---|
| 548 | |
---|
| 549 | |
---|
| 550 | G4RotationMatrix r90Z; |
---|
| 551 | r90Z.rotateZ(halfpi); |
---|
| 552 | G4AffineTransform tRotZ(r90Z,pzero); |
---|
| 553 | |
---|
| 554 | assert(trap1.CalculateExtent(kXAxis,limit,tRotZ,min,max)); |
---|
| 555 | assert(ApproxEqual(min,-30)&&ApproxEqual(max,30)); |
---|
| 556 | assert(trap1.CalculateExtent(kYAxis,limit,tRotZ,min,max)); |
---|
| 557 | assert(ApproxEqual(min,-20)&&ApproxEqual(max,20)); |
---|
| 558 | assert(trap1.CalculateExtent(kZAxis,limit,tRotZ,min,max)); |
---|
| 559 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 560 | |
---|
| 561 | assert(trap2.CalculateExtent(kXAxis,limit,tRotZ,min,max)); |
---|
| 562 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 563 | assert(trap2.CalculateExtent(kYAxis,limit,tRotZ,min,max)); |
---|
| 564 | assert(ApproxEqual(min,-30)&&ApproxEqual(max,30)); |
---|
| 565 | assert(trap2.CalculateExtent(kZAxis,limit,tRotZ,min,max)); |
---|
| 566 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 567 | |
---|
| 568 | |
---|
| 569 | // Check that clipped away |
---|
| 570 | |
---|
| 571 | G4VoxelLimits xClip; |
---|
| 572 | xClip.AddLimit(kXAxis,-100,-50); |
---|
| 573 | |
---|
| 574 | assert(!trap1.CalculateExtent(kXAxis,xClip,origin,min,max)); |
---|
| 575 | |
---|
| 576 | assert(!trap2.CalculateExtent(kXAxis,xClip,origin,min,max)); |
---|
| 577 | |
---|
| 578 | |
---|
| 579 | // Assert clipped to volume |
---|
| 580 | |
---|
| 581 | G4VoxelLimits allClip; |
---|
| 582 | allClip.AddLimit(kXAxis,-5,+5); |
---|
| 583 | allClip.AddLimit(kYAxis,-5,+5); |
---|
| 584 | allClip.AddLimit(kZAxis,-5,+5); |
---|
| 585 | |
---|
| 586 | G4RotationMatrix genRot; |
---|
| 587 | genRot.rotateX(pi/6); |
---|
| 588 | genRot.rotateY(pi/6); |
---|
| 589 | genRot.rotateZ(pi/6); |
---|
| 590 | |
---|
| 591 | G4AffineTransform tGen(genRot,vx); |
---|
| 592 | |
---|
| 593 | assert(trap1.CalculateExtent(kXAxis,allClip,tGen,min,max)); |
---|
| 594 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
| 595 | assert(trap1.CalculateExtent(kYAxis,allClip,tGen,min,max)); |
---|
| 596 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
| 597 | assert(trap1.CalculateExtent(kZAxis,allClip,tGen,min,max)); |
---|
| 598 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
| 599 | |
---|
| 600 | assert(trap2.CalculateExtent(kXAxis,allClip,tGen,min,max)); |
---|
| 601 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
| 602 | assert(trap2.CalculateExtent(kYAxis,allClip,tGen,min,max)); |
---|
| 603 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
| 604 | assert(trap2.CalculateExtent(kZAxis,allClip,tGen,min,max)); |
---|
| 605 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
| 606 | |
---|
| 607 | |
---|
| 608 | G4VoxelLimits buggyClip2; |
---|
| 609 | buggyClip2.AddLimit(kXAxis,5,15); |
---|
| 610 | |
---|
| 611 | assert(trap1.CalculateExtent(kXAxis,buggyClip2,origin,min,max)); |
---|
| 612 | assert(ApproxEqual(min,5)&&ApproxEqual(max,15)); |
---|
| 613 | assert(trap1.CalculateExtent(kYAxis,buggyClip2,origin,min,max)); |
---|
| 614 | assert(ApproxEqual(min,-30)&&ApproxEqual(max,30)); |
---|
| 615 | assert(trap1.CalculateExtent(kZAxis,buggyClip2,origin,min,max)); |
---|
| 616 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 617 | |
---|
| 618 | assert(trap2.CalculateExtent(kXAxis,buggyClip2,origin,min,max)); |
---|
| 619 | assert(ApproxEqual(min,5)&&ApproxEqual(max,15)); |
---|
| 620 | assert(trap2.CalculateExtent(kYAxis,buggyClip2,origin,min,max)); |
---|
| 621 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 622 | assert(trap2.CalculateExtent(kZAxis,buggyClip2,origin,min,max)); |
---|
| 623 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 624 | |
---|
| 625 | |
---|
| 626 | buggyClip2.AddLimit(kYAxis,5,15); |
---|
| 627 | |
---|
| 628 | assert(trap1.CalculateExtent(kXAxis,buggyClip2,origin,min,max)); |
---|
| 629 | assert(ApproxEqual(min,5)&&ApproxEqual(max,15)); |
---|
| 630 | assert(trap1.CalculateExtent(kYAxis,buggyClip2,origin,min,max)); |
---|
| 631 | assert(ApproxEqual(min,5)&&ApproxEqual(max,15)); |
---|
| 632 | assert(trap1.CalculateExtent(kZAxis,buggyClip2,origin,min,max)); |
---|
| 633 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 634 | |
---|
| 635 | assert(trap2.CalculateExtent(kXAxis,buggyClip2,origin,min,max)); |
---|
| 636 | assert(ApproxEqual(min,5)&&ApproxEqual(max,15)); |
---|
| 637 | assert(trap2.CalculateExtent(kYAxis,buggyClip2,origin,min,max)); |
---|
| 638 | assert(ApproxEqual(min,5)&&ApproxEqual(max,15)); |
---|
| 639 | assert(trap2.CalculateExtent(kZAxis,buggyClip2,origin,min,max)); |
---|
| 640 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 641 | |
---|
| 642 | |
---|
| 643 | G4VoxelLimits buggyClip1; |
---|
| 644 | buggyClip1.AddLimit(kXAxis,-5,+5); |
---|
| 645 | |
---|
| 646 | assert(trap1.CalculateExtent(kXAxis,buggyClip1,origin,min,max)); |
---|
| 647 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
| 648 | assert(trap1.CalculateExtent(kYAxis,buggyClip1,origin,min,max)); |
---|
| 649 | assert(ApproxEqual(min,-30)&&ApproxEqual(max,30)); |
---|
| 650 | assert(trap1.CalculateExtent(kZAxis,buggyClip1,origin,min,max)); |
---|
| 651 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 652 | |
---|
| 653 | assert(trap2.CalculateExtent(kXAxis,buggyClip1,origin,min,max)); |
---|
| 654 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
| 655 | assert(trap2.CalculateExtent(kYAxis,buggyClip1,origin,min,max)); |
---|
| 656 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 657 | assert(trap2.CalculateExtent(kZAxis,buggyClip1,origin,min,max)); |
---|
| 658 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 659 | |
---|
| 660 | |
---|
| 661 | buggyClip1.AddLimit(kYAxis,-5,+5); |
---|
| 662 | |
---|
| 663 | assert(trap1.CalculateExtent(kXAxis,buggyClip1,origin,min,max)); |
---|
| 664 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
| 665 | assert(trap1.CalculateExtent(kYAxis,buggyClip1,origin,min,max)); |
---|
| 666 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
| 667 | assert(trap1.CalculateExtent(kZAxis,buggyClip1,origin,min,max)); |
---|
| 668 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 669 | |
---|
| 670 | assert(trap2.CalculateExtent(kXAxis,buggyClip1,origin,min,max)); |
---|
| 671 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
| 672 | assert(trap2.CalculateExtent(kYAxis,buggyClip1,origin,min,max)); |
---|
| 673 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
| 674 | assert(trap2.CalculateExtent(kZAxis,buggyClip1,origin,min,max)); |
---|
| 675 | assert(ApproxEqual(min,-40)&&ApproxEqual(max,40)); |
---|
| 676 | |
---|
| 677 | |
---|
| 678 | G4VoxelLimits newvoxlim; |
---|
| 679 | newvoxlim.AddLimit(kZAxis,-5,+5); |
---|
| 680 | |
---|
| 681 | assert(trap1.CalculateExtent(kXAxis,newvoxlim,origin,min,max)); |
---|
| 682 | assert(ApproxEqual(min,-20)&&ApproxEqual(max,20)); |
---|
| 683 | assert(trap1.CalculateExtent(kYAxis,newvoxlim,origin,min,max)); |
---|
| 684 | assert(ApproxEqual(min,-30)&&ApproxEqual(max,30)); |
---|
| 685 | assert(trap1.CalculateExtent(kZAxis,newvoxlim,origin,min,max)); |
---|
| 686 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
| 687 | |
---|
| 688 | assert(trap2.CalculateExtent(kXAxis,newvoxlim,origin,min,max)); |
---|
| 689 | assert(ApproxEqual(min,-(20+5*tanga))&&ApproxEqual(max,20+5*tanga)); |
---|
| 690 | assert(trap2.CalculateExtent(kYAxis,newvoxlim,origin,min,max)); |
---|
| 691 | assert(ApproxEqual(min,-(30+5*tanga))&&ApproxEqual(max,30+5*tanga)); |
---|
| 692 | assert(trap2.CalculateExtent(kZAxis,newvoxlim,origin,min,max)); |
---|
| 693 | assert(ApproxEqual(min,-5)&&ApproxEqual(max,5)); |
---|
| 694 | |
---|
| 695 | G4VoxelLimits nonsymvox; |
---|
| 696 | nonsymvox.AddLimit(kZAxis,5,15); |
---|
| 697 | |
---|
| 698 | assert(trap2.CalculateExtent(kXAxis,nonsymvox,origin,min,max)); |
---|
| 699 | assert(ApproxEqual(min,-(20+15*tanga))&&ApproxEqual(max,20+15*tanga)); |
---|
| 700 | assert(trap2.CalculateExtent(kYAxis,nonsymvox,origin,min,max)); |
---|
| 701 | assert(ApproxEqual(min,-(30+15*tanga))&&ApproxEqual(max,30+15*tanga)); |
---|
| 702 | assert(trap2.CalculateExtent(kZAxis,nonsymvox,origin,min,max)); |
---|
| 703 | assert(ApproxEqual(min,5)&&ApproxEqual(max,15)); |
---|
| 704 | |
---|
| 705 | return true; |
---|
| 706 | } |
---|
| 707 | |
---|
| 708 | int main() |
---|
| 709 | { |
---|
| 710 | #ifdef NDEBUG |
---|
| 711 | G4Exception("FAIL: *** Assertions must be compiled in! ***"); |
---|
| 712 | #endif |
---|
| 713 | assert(testG4Trap()); |
---|
| 714 | return 0; |
---|
| 715 | } |
---|
| 716 | |
---|
| 717 | |
---|
| 718 | |
---|
| 719 | |
---|
| 720 | |
---|