[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: testG4Torus.cc,v 1.16 2007/05/18 10:24:32 gcosmo Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ |
---|
| 29 | // |
---|
| 30 | |
---|
| 31 | // testG4Torus |
---|
| 32 | // |
---|
| 33 | // Test file for class G4Torus [NOT thorough] |
---|
| 34 | // |
---|
| 35 | // History |
---|
| 36 | // 30.10.96 V.Grichine First version for first G4Torus implementation |
---|
| 37 | |
---|
| 38 | #include "G4ios.hh" |
---|
| 39 | #include <assert.h> |
---|
| 40 | #include <cmath> |
---|
| 41 | |
---|
| 42 | #include "globals.hh" |
---|
| 43 | #include "geomdefs.hh" |
---|
| 44 | #include "G4GeometryTolerance.hh" |
---|
| 45 | |
---|
| 46 | #include "ApproxEqual.hh" |
---|
| 47 | |
---|
| 48 | #include "G4ThreeVector.hh" |
---|
| 49 | #include "G4Torus.hh" |
---|
| 50 | #include "G4RotationMatrix.hh" |
---|
| 51 | #include "G4AffineTransform.hh" |
---|
| 52 | #include "G4VoxelLimits.hh" |
---|
| 53 | |
---|
| 54 | /////////////////////////////////////////////////////////////////// |
---|
| 55 | // |
---|
| 56 | // Dave's auxiliary function |
---|
| 57 | |
---|
| 58 | const G4String OutputInside(const EInside a) |
---|
| 59 | { |
---|
| 60 | switch(a) |
---|
| 61 | { |
---|
| 62 | case kInside: return "Inside"; |
---|
| 63 | case kOutside: return "Outside"; |
---|
| 64 | case kSurface: return "Surface"; |
---|
| 65 | } |
---|
| 66 | return "????"; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | G4bool testG4Torus() |
---|
| 71 | { |
---|
| 72 | G4int i ; |
---|
| 73 | G4double Rtor = 100 ; |
---|
| 74 | G4double Rmax = Rtor*0.9 ; |
---|
| 75 | G4double Rmin = Rtor*0.1 ; |
---|
| 76 | |
---|
| 77 | //G4double z = atof ( argv[2] ); |
---|
| 78 | G4double x; |
---|
| 79 | G4double z; |
---|
| 80 | |
---|
| 81 | G4double Dist, dist, vol, volCheck; |
---|
| 82 | EInside side; |
---|
| 83 | G4ThreeVector *pNorm,norm; |
---|
| 84 | G4bool *pgoodNorm,goodNorm,calcNorm=true; |
---|
| 85 | |
---|
| 86 | G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance(); |
---|
| 87 | |
---|
| 88 | pNorm=&norm; |
---|
| 89 | pgoodNorm=&goodNorm; |
---|
| 90 | |
---|
| 91 | G4ThreeVector pzero(0,0,0); |
---|
| 92 | |
---|
| 93 | G4ThreeVector pbigx(240,0,0),pbigy(0,240,0),pbigz(0,0,240); |
---|
| 94 | G4ThreeVector pbigmx(-240,0,0),pbigmy(0,-240,0),pbigmz(0,0,-240); |
---|
| 95 | |
---|
| 96 | G4ThreeVector ponrmax(190,0,0); |
---|
| 97 | G4ThreeVector ponrmin(0,110,0); |
---|
| 98 | G4ThreeVector ponrtor(0,100,0); |
---|
| 99 | G4ThreeVector ponphi1(100/std::sqrt(2.),100/std::sqrt(2.),0) ; |
---|
| 100 | G4ThreeVector ponphi2(-100/std::sqrt(2.),100/std::sqrt(2.),0) ; |
---|
| 101 | G4ThreeVector ponphi12(120/std::sqrt(2.),120/std::sqrt(2.),0) ; |
---|
| 102 | G4ThreeVector ponphi22(-120/std::sqrt(2.),120/std::sqrt(2.),0) ; |
---|
| 103 | G4ThreeVector ponphi23(-120/std::sqrt(2.)+0.5,120/std::sqrt(2.),0) ; |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | G4ThreeVector vx(1,0,0),vy(0,1,0),vz(0,0,1); |
---|
| 107 | G4ThreeVector vmx(-1,0,0),vmy(0,-1,0),vmz(0,0,-1); |
---|
| 108 | G4ThreeVector vxy(1/std::sqrt(2.0),1/std::sqrt(2.0),0); |
---|
| 109 | G4ThreeVector vmxy(-1/std::sqrt(2.0),1/std::sqrt(2.0),0); |
---|
| 110 | G4ThreeVector vmxmy(-1/std::sqrt(2.0),-1/std::sqrt(2.0),0); |
---|
| 111 | G4ThreeVector vxmy(1/std::sqrt(2.0),-1/std::sqrt(2.0),0); |
---|
| 112 | |
---|
| 113 | G4ThreeVector pstart((Rtor+Rmax)/std::sqrt(2.0),(Rtor+Rmax)/std::sqrt(2.0),0) ; |
---|
| 114 | G4ThreeVector vdirect(1/std::sqrt(2.0),-1/std::sqrt(2.0),0) ; |
---|
| 115 | |
---|
| 116 | G4ThreeVector pother(110,0,0); |
---|
| 117 | vdirect = vdirect.unit() ; |
---|
| 118 | G4ThreeVector p1; |
---|
| 119 | G4ThreeVector v1(1,0,0); |
---|
| 120 | v1 = v1.unit(); |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | // Check torus roots |
---|
| 124 | |
---|
| 125 | G4Torus t1("Solid Torus #1",0,Rmax,Rtor,0,twopi); |
---|
| 126 | G4Torus t2("Hole cutted Torus #2",Rmin,Rmax,Rtor,pi/4,halfpi); |
---|
| 127 | G4Torus tn2("tn2",Rmin,Rmax,Rtor,halfpi,halfpi); |
---|
| 128 | G4Torus tn3("tn3",Rmin,Rmax,Rtor,halfpi,3*halfpi); |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | G4Torus t3("Hole cutted Torus #3",4*Rmin,Rmax,Rtor,halfpi-pi/24,pi/12); |
---|
| 133 | G4Torus t4("Solid Torus #4",0,Rtor - 2.e3*kCarTolerance,Rtor,0,twopi); |
---|
| 134 | G4Torus t5("Solid cutted Torus #5",0,Rtor - 2.e3*kCarTolerance,Rtor,pi/4,halfpi); |
---|
| 135 | |
---|
| 136 | G4Torus * aTub = new G4Torus("Ring1", 0*cm, 10*cm, |
---|
| 137 | 1*m, 0*deg, 360*deg ); |
---|
| 138 | G4Torus t6("t6",100*mm, 150*mm, 200*mm,0*degree, |
---|
| 139 | 59.99999999999999*degree); |
---|
| 140 | |
---|
| 141 | G4Torus* clad = |
---|
| 142 | new G4Torus("clad",0.,1.*cm,10.*cm,0.*deg,180.*deg); // external |
---|
| 143 | |
---|
| 144 | G4Torus* core = |
---|
| 145 | new G4Torus("core",0.,0.5*cm,10.*cm,0.*deg,180.*deg); // internal |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | G4cout.precision(20); |
---|
| 149 | |
---|
| 150 | G4ThreeVector p1t6( 60.73813233071262, |
---|
| 151 | -27.28494547459707, |
---|
| 152 | 37.47827539879173); |
---|
| 153 | |
---|
| 154 | G4ThreeVector vt6( 0.3059312222729116, |
---|
| 155 | 0.8329513862588347, |
---|
| 156 | -0.461083588265824); |
---|
| 157 | |
---|
| 158 | G4ThreeVector p2t6(70.75950555416668, |
---|
| 159 | -3.552713678800501e-15, |
---|
| 160 | 22.37458414788935 ); |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | // num = t1.TorusRoots(Ri,pstart,vdirect) ; |
---|
| 164 | // num = t1.TorusRoots(Ri,pother,vx) ; |
---|
| 165 | // G4Torus t2("Hole Torus #2",45,50,50,0,360); |
---|
| 166 | // Check name |
---|
| 167 | // assert(t1.GetName()=="Solid Torus #1"); |
---|
| 168 | |
---|
| 169 | // check cubic volume |
---|
| 170 | |
---|
| 171 | vol = t1.GetCubicVolume(); |
---|
| 172 | volCheck = twopi*pi*Rtor*(Rmax*Rmax); |
---|
| 173 | assert(ApproxEqual(vol,volCheck)); |
---|
| 174 | |
---|
| 175 | vol = t2.GetCubicVolume(); |
---|
| 176 | volCheck = halfpi*pi*Rtor*(Rmax*Rmax-Rmin*Rmin); |
---|
| 177 | assert(ApproxEqual(vol,volCheck)); |
---|
| 178 | |
---|
| 179 | // Check Inside |
---|
| 180 | assert(t1.Inside(pzero)==kOutside); |
---|
| 181 | assert(t1.Inside(pbigx)==kOutside); |
---|
| 182 | assert(t1.Inside(ponrmax)==kSurface); |
---|
| 183 | assert(t2.Inside(ponrmin)==kSurface); |
---|
| 184 | assert(t2.Inside(pbigx)==kOutside); |
---|
| 185 | assert(t2.Inside(pbigy)==kOutside); |
---|
| 186 | |
---|
| 187 | assert(t2.Inside(ponphi1)==kOutside); |
---|
| 188 | assert(t2.Inside(ponphi2)==kOutside); |
---|
| 189 | assert(t2.Inside(ponphi12)==kSurface); |
---|
| 190 | assert(t2.Inside(ponphi22)==kSurface); |
---|
| 191 | |
---|
| 192 | side=t6.Inside(p1t6); |
---|
| 193 | // G4cout<<"t6.Inside(p1t6) = "<<OutputInside(side)<<G4endl; |
---|
| 194 | side=t6.Inside(p2t6); |
---|
| 195 | // G4cout<<"t6.Inside(p2t6) = "<<OutputInside(side)<<G4endl; |
---|
| 196 | |
---|
| 197 | // Check Surface Normal |
---|
| 198 | G4ThreeVector normal; |
---|
| 199 | G4double p2=1./std::sqrt(2.); // ,p3=1./std::sqrt(3.); |
---|
| 200 | |
---|
| 201 | |
---|
| 202 | normal=t1.SurfaceNormal(ponrmax); |
---|
| 203 | assert(ApproxEqual(normal,vx)); |
---|
| 204 | normal=t1.SurfaceNormal(G4ThreeVector(0.,190.,0.)); |
---|
| 205 | assert(ApproxEqual(normal,vy)); |
---|
| 206 | normal=tn2.SurfaceNormal(G4ThreeVector(0.,Rtor+Rmax,0.)); |
---|
| 207 | assert(ApproxEqual(normal,G4ThreeVector(p2,p2,0.))); |
---|
| 208 | normal=tn2.SurfaceNormal(G4ThreeVector(0.,Rtor+Rmin,0.)); |
---|
| 209 | assert(ApproxEqual(normal,G4ThreeVector(p2,-p2,0.))); |
---|
| 210 | normal=tn2.SurfaceNormal(G4ThreeVector(0.,Rtor-Rmin,0.)); |
---|
| 211 | assert(ApproxEqual(normal,G4ThreeVector(p2,p2,0.))); |
---|
| 212 | normal=tn2.SurfaceNormal(G4ThreeVector(0.,Rtor-Rmax,0.)); |
---|
| 213 | assert(ApproxEqual(normal,G4ThreeVector(p2,-p2,0.))); |
---|
| 214 | normal=tn3.SurfaceNormal(G4ThreeVector(Rtor,0.,Rmax)); |
---|
| 215 | assert(ApproxEqual(normal,G4ThreeVector(0.,p2,p2))); |
---|
| 216 | normal=tn3.SurfaceNormal(G4ThreeVector(0.,Rtor,Rmax)); |
---|
| 217 | assert(ApproxEqual(normal,G4ThreeVector(p2,0.,p2))); |
---|
| 218 | |
---|
| 219 | normal=t2.SurfaceNormal(ponrmin); |
---|
| 220 | assert(ApproxEqual(normal,vmy)); |
---|
| 221 | normal=t2.SurfaceNormal(ponphi1); |
---|
| 222 | assert(ApproxEqual(normal,vxmy)); |
---|
| 223 | normal=t2.SurfaceNormal(ponphi2); |
---|
| 224 | assert(ApproxEqual(normal,vmxmy)); |
---|
| 225 | |
---|
| 226 | // DistanceToOut(P) |
---|
| 227 | Dist=t1.DistanceToOut(ponrmin); |
---|
| 228 | assert(ApproxEqual(Dist,80)); |
---|
| 229 | Dist=t1.DistanceToOut(ponrmax); |
---|
| 230 | assert(ApproxEqual(Dist,0)); |
---|
| 231 | /* // later: why it was introduced, while they are outside (see above) |
---|
| 232 | Dist=t2.DistanceToOut(ponphi1); |
---|
| 233 | assert(ApproxEqual(Dist,0)); |
---|
| 234 | Dist=t2.DistanceToOut(ponphi2); |
---|
| 235 | assert(ApproxEqual(Dist,0)); |
---|
| 236 | */ |
---|
| 237 | // DistanceToOut(P,V) |
---|
| 238 | Dist=t1.DistanceToOut(ponrmax,vx,calcNorm,pgoodNorm,pNorm); |
---|
| 239 | assert(ApproxEqual(Dist,0)&&*pgoodNorm&&ApproxEqual(pNorm->unit(),vx)); |
---|
| 240 | Dist=t1.DistanceToOut(ponphi1,vz,calcNorm,pgoodNorm,pNorm); |
---|
| 241 | // G4cout<<"t1.DistanceToOut(ponphi1,vz,...) = "<<Dist<<G4endl ; |
---|
| 242 | assert(ApproxEqual(Dist,90)&&*pgoodNorm&&ApproxEqual(pNorm->unit(),vz)); |
---|
| 243 | |
---|
| 244 | Dist=t1.DistanceToOut(ponrmin,vy,calcNorm,pgoodNorm,pNorm); |
---|
| 245 | assert(ApproxEqual(Dist,80)&&*pgoodNorm&&ApproxEqual(pNorm->unit(),vy)); |
---|
| 246 | Dist=t1.DistanceToOut(ponrmin,vmy,calcNorm,pgoodNorm,pNorm); |
---|
| 247 | assert(ApproxEqual(Dist,100) && !*pgoodNorm); |
---|
| 248 | // Dist=t1.DistanceToOut(pzero,vz,calcNorm,pgoodNorm,pNorm); |
---|
| 249 | // assert(ApproxEqual(Dist,50)&&ApproxEqual(pNorm->unit(),vz)&&*pgoodNorm); |
---|
| 250 | // Dist=t1.DistanceToOut(pzero,vmz,calcNorm,pgoodNorm,pNorm); |
---|
| 251 | // assert(ApproxEqual(Dist,50)&&ApproxEqual(pNorm->unit(),vmz)&&*pgoodNorm); |
---|
| 252 | // Dist=t1.DistanceToOut(pzero,vxy,calcNorm,pgoodNorm,pNorm); |
---|
| 253 | // assert(ApproxEqual(Dist,50)&&ApproxEqual(pNorm->unit(),vxy)&&*pgoodNorm); |
---|
| 254 | |
---|
| 255 | |
---|
| 256 | Dist=t2.DistanceToOut(ponphi12,vxmy,calcNorm,pgoodNorm,pNorm); |
---|
| 257 | // G4cout<<"Dist=t2.DistanceToOut(ponphi12,vxmy) = "<<Dist<<G4endl; |
---|
| 258 | assert(ApproxEqual(Dist,0)&&*pgoodNorm&&ApproxEqual(pNorm->unit(),vxmy)); |
---|
| 259 | Dist=t2.DistanceToOut(ponphi22,vmxmy,calcNorm,pgoodNorm,pNorm); |
---|
| 260 | // G4cout<<"Dist=t2.DistanceToOut(ponphi22,vmxmy) = "<<Dist<<G4endl; |
---|
| 261 | assert(ApproxEqual(Dist,0)&&*pgoodNorm&&ApproxEqual(pNorm->unit(),vmxmy)); |
---|
| 262 | Dist=t2.DistanceToOut(ponphi23,vmxmy,calcNorm,pgoodNorm,pNorm); |
---|
| 263 | // G4cout<<"Dist=t2.DistanceToOut(ponphi23,vmxmy) = "<<Dist<<G4endl; |
---|
| 264 | assert(ApproxEqual(Dist,0.353553)&&*pgoodNorm&&ApproxEqual(pNorm->unit(),vmxmy)); |
---|
| 265 | |
---|
| 266 | |
---|
| 267 | // Check for Distance to Out ( start from an internal point ) |
---|
| 268 | |
---|
| 269 | for ( i=0; i<12; i++ ) |
---|
| 270 | { |
---|
| 271 | x = -1050; |
---|
| 272 | z = G4double(i)/10; |
---|
| 273 | p1 = G4ThreeVector(x,0,z); |
---|
| 274 | // G4cout << p1 << " - " << v1 << G4endl; |
---|
| 275 | |
---|
| 276 | Dist = aTub->DistanceToIn (p1,v1); |
---|
| 277 | // G4cout << "Distance to in dir: " << Dist ; |
---|
| 278 | |
---|
| 279 | Dist = aTub->DistanceToOut (p1,v1) ; |
---|
| 280 | // G4cout << " Distance to out dir: " << Dist << G4endl ; |
---|
| 281 | |
---|
| 282 | // G4cout << "Distance to in : " << aTub->DistanceToIn (p1); |
---|
| 283 | // G4cout << " Distance to out : " << aTub->DistanceToOut (p1) |
---|
| 284 | // << G4endl; |
---|
| 285 | // G4cout << " Inside : " << aTub->Inside (p1); |
---|
| 286 | // G4cout << G4endl; |
---|
| 287 | } |
---|
| 288 | |
---|
| 289 | |
---|
| 290 | |
---|
| 291 | //DistanceToIn(P) |
---|
| 292 | Dist=t1.DistanceToIn(pbigx); |
---|
| 293 | assert(ApproxEqual(Dist,50)); |
---|
| 294 | Dist=t1.DistanceToIn(pbigmx); |
---|
| 295 | assert(ApproxEqual(Dist,50)); |
---|
| 296 | Dist=t1.DistanceToIn(pbigy); |
---|
| 297 | assert(ApproxEqual(Dist,50)); |
---|
| 298 | Dist=t1.DistanceToIn(pbigmy); |
---|
| 299 | assert(ApproxEqual(Dist,50)); |
---|
| 300 | Dist=t1.DistanceToIn(pbigz); |
---|
| 301 | // G4cout<<"Dist=t1.DistanceToIn(pbigz) = "<<Dist<<G4endl; |
---|
| 302 | // assert(ApproxEqual(Dist,50)); |
---|
| 303 | Dist=t1.DistanceToIn(pbigmz); |
---|
| 304 | // G4cout<<"Dist=t1.DistanceToIn(pbigmz) = "<<Dist<<G4endl; |
---|
| 305 | // assert(ApproxEqual(Dist,50)); |
---|
| 306 | |
---|
| 307 | // DistanceToIn(P,V) |
---|
| 308 | Dist=t1.DistanceToIn(pbigx,vmx); |
---|
| 309 | assert(ApproxEqual(Dist,50)); |
---|
| 310 | Dist=t1.DistanceToIn(pbigmx,vx); |
---|
| 311 | assert(ApproxEqual(Dist,50)); |
---|
| 312 | Dist=t1.DistanceToIn(pbigy,vmy); |
---|
| 313 | assert(ApproxEqual(Dist,50)); |
---|
| 314 | Dist=t1.DistanceToIn(pbigmy,vy); |
---|
| 315 | assert(ApproxEqual(Dist,50)); |
---|
| 316 | Dist=t1.DistanceToIn(pbigz,vmz); |
---|
| 317 | assert(ApproxEqual(Dist,kInfinity)); |
---|
| 318 | Dist=t1.DistanceToIn(pbigmz,vz); |
---|
| 319 | assert(ApproxEqual(Dist,kInfinity)); |
---|
| 320 | Dist=t1.DistanceToIn(pbigx,vxy); |
---|
| 321 | assert(ApproxEqual(Dist,kInfinity)); |
---|
| 322 | Dist=t1.DistanceToIn(ponrmax,vx); |
---|
| 323 | assert(ApproxEqual(Dist,kInfinity)); |
---|
| 324 | Dist=t1.DistanceToIn(ponrmax,vmx); |
---|
| 325 | assert(ApproxEqual(Dist,0)); |
---|
| 326 | |
---|
| 327 | G4ThreeVector vnew(1,0,0) ; |
---|
| 328 | vnew.rotateZ(pi/4-5*1e-9) ; // old test: check pzero with vxy |
---|
| 329 | Dist=t2.DistanceToIn(pzero,vnew); |
---|
| 330 | assert(ApproxEqual(Dist,kInfinity)); |
---|
| 331 | Dist=t2.DistanceToIn(pzero,vy); |
---|
| 332 | assert(ApproxEqual(Dist,10)); |
---|
| 333 | Dist=t2.DistanceToIn(ponphi12,vy); |
---|
| 334 | assert(ApproxEqual(Dist,0)); |
---|
| 335 | Dist=t2.DistanceToIn(ponphi12,vmy); |
---|
| 336 | assert(ApproxEqual(Dist,kInfinity)); |
---|
| 337 | Dist=t2.DistanceToIn(ponphi1,vy); |
---|
| 338 | // G4cout<<"Dist=t2.DistanceToIn(ponphi1,vy) = "<<Dist<<G4endl; // about 13 |
---|
| 339 | Dist=t2.DistanceToIn(ponrmin,vy); |
---|
| 340 | assert(ApproxEqual(Dist,0)); |
---|
| 341 | Dist=t2.DistanceToIn(ponrmin,vmy); |
---|
| 342 | assert(ApproxEqual(Dist,20)); |
---|
| 343 | |
---|
| 344 | Dist=t3.DistanceToIn(ponrtor,vy); |
---|
| 345 | assert(ApproxEqual(Dist,40)); |
---|
| 346 | Dist=t3.DistanceToIn(ponrtor,vmy); |
---|
| 347 | assert(ApproxEqual(Dist,40)); |
---|
| 348 | Dist=t3.DistanceToIn(ponrtor,vz); |
---|
| 349 | assert(ApproxEqual(Dist,40)); |
---|
| 350 | Dist=t3.DistanceToIn(ponrtor,vmz); |
---|
| 351 | assert(ApproxEqual(Dist,40)); |
---|
| 352 | Dist=t3.DistanceToIn(ponrtor,vx); |
---|
| 353 | assert(ApproxEqual(Dist,kInfinity)); |
---|
| 354 | Dist=t3.DistanceToIn(ponrtor,vmx); |
---|
| 355 | assert(ApproxEqual(Dist,kInfinity)); |
---|
| 356 | |
---|
| 357 | Dist=t6.DistanceToIn(p1t6,vt6); |
---|
| 358 | // G4cout<<"t6.DistanceToIn(p1t6,vt6) = "<<Dist<<G4endl; |
---|
| 359 | |
---|
| 360 | // Bug 810 |
---|
| 361 | |
---|
| 362 | G4ThreeVector pTmp(0.,0.,0.); |
---|
| 363 | |
---|
| 364 | dist = clad->DistanceToIn(pTmp,vy); |
---|
| 365 | pTmp += dist*vy; |
---|
| 366 | G4cout<<"pTmpX = "<<pTmp.x()<<"; pTmpY = "<<pTmp.y()<<"; pTmpZ = "<<pTmp.z()<<G4endl; |
---|
| 367 | side=core->Inside(pTmp); |
---|
| 368 | G4cout<<"core->Inside(pTmp) = "<<OutputInside(side)<<G4endl; |
---|
| 369 | side=clad->Inside(pTmp); |
---|
| 370 | G4cout<<"clad->Inside(pTmp) = "<<OutputInside(side)<<G4endl; |
---|
| 371 | |
---|
| 372 | dist = core->DistanceToIn(pTmp,vy); |
---|
| 373 | pTmp += dist*vy; |
---|
| 374 | G4cout<<"pTmpX = "<<pTmp.x()<<"; pTmpY = "<<pTmp.y()<<"; pTmpZ = "<<pTmp.z()<<G4endl; |
---|
| 375 | side=core->Inside(pTmp); |
---|
| 376 | G4cout<<"core->Inside(pTmp) = "<<OutputInside(side)<<G4endl; |
---|
| 377 | side=clad->Inside(pTmp); |
---|
| 378 | G4cout<<"clad->Inside(pTmp) = "<<OutputInside(side)<<G4endl; |
---|
| 379 | |
---|
| 380 | dist = core->DistanceToOut(pTmp,vy,calcNorm,pgoodNorm,pNorm); |
---|
| 381 | pTmp += dist*vy; |
---|
| 382 | G4cout<<"pTmpX = "<<pTmp.x()<<"; pTmpY = "<<pTmp.y()<<"; pTmpZ = "<<pTmp.z()<<G4endl; |
---|
| 383 | side=core->Inside(pTmp); |
---|
| 384 | G4cout<<"core->Inside(pTmp) = "<<OutputInside(side)<<G4endl; |
---|
| 385 | side=clad->Inside(pTmp); |
---|
| 386 | G4cout<<"clad->Inside(pTmp) = "<<OutputInside(side)<<G4endl; |
---|
| 387 | |
---|
| 388 | dist = clad->DistanceToOut(pTmp,vy,calcNorm,pgoodNorm,pNorm); |
---|
| 389 | pTmp += dist*vy; |
---|
| 390 | G4cout<<"pTmpX = "<<pTmp.x()<<"; pTmpY = "<<pTmp.y()<<"; pTmpZ = "<<pTmp.z()<<G4endl; |
---|
| 391 | side=core->Inside(pTmp); |
---|
| 392 | G4cout<<"core->Inside(pTmp) = "<<OutputInside(side)<<G4endl; |
---|
| 393 | side=clad->Inside(pTmp); |
---|
| 394 | G4cout<<"clad->Inside(pTmp) = "<<OutputInside(side)<<G4endl; |
---|
| 395 | |
---|
| 396 | // Check for Distance to In ( start from an external point ) |
---|
| 397 | |
---|
| 398 | for ( i=0; i<12; i++ ) |
---|
| 399 | { |
---|
| 400 | x = -1200; |
---|
| 401 | z = G4double(i)/10; |
---|
| 402 | p1 = G4ThreeVector(x,0,z); |
---|
| 403 | // G4cout << p1 << " - " << v1 << G4endl; |
---|
| 404 | |
---|
| 405 | Dist = aTub->DistanceToIn (p1,v1) ; |
---|
| 406 | // G4cout << "Distance to in dir: " << Dist ; |
---|
| 407 | |
---|
| 408 | Dist = aTub->DistanceToOut (p1,v1) ; |
---|
| 409 | // G4cout << " Distance to out dir: " << Dist << G4endl ; |
---|
| 410 | |
---|
| 411 | // G4cout << "Distance to in : " << aTub->DistanceToIn (p1); |
---|
| 412 | // G4cout << " Distance to out : " << aTub->DistanceToOut (p1) |
---|
| 413 | // << G4endl; |
---|
| 414 | // G4cout << " Inside : " << aTub->Inside (p1); |
---|
| 415 | // G4cout << G4endl; |
---|
| 416 | } |
---|
| 417 | |
---|
| 418 | |
---|
| 419 | // CalculateExtent |
---|
| 420 | |
---|
| 421 | G4VoxelLimits limit; // Unlimited |
---|
| 422 | G4RotationMatrix noRot; |
---|
| 423 | G4AffineTransform origin; |
---|
| 424 | G4double min,max; |
---|
| 425 | assert(t1.CalculateExtent(kXAxis,limit,origin,min,max)); |
---|
| 426 | assert(min<=-190&&max>=190); |
---|
| 427 | assert(t1.CalculateExtent(kYAxis,limit,origin,min,max)); |
---|
| 428 | assert(min<=-190&&max>=190); |
---|
| 429 | assert(t1.CalculateExtent(kZAxis,limit,origin,min,max)); |
---|
| 430 | assert(min<=-90&&max>=90); |
---|
| 431 | |
---|
| 432 | G4ThreeVector pmxmymz(-100,-110,-120); |
---|
| 433 | G4AffineTransform tPosOnly(pmxmymz); |
---|
| 434 | assert(t1.CalculateExtent(kXAxis,limit,tPosOnly,min,max)); |
---|
| 435 | assert(min<=-290&&max>=-90); |
---|
| 436 | assert(t1.CalculateExtent(kYAxis,limit,tPosOnly,min,max)); |
---|
| 437 | assert(min<=-300&&max>=-100); |
---|
| 438 | assert(t1.CalculateExtent(kZAxis,limit,tPosOnly,min,max)); |
---|
| 439 | assert(min<=-210&&max>=-30); |
---|
| 440 | |
---|
| 441 | G4RotationMatrix r90Z; |
---|
| 442 | r90Z.rotateZ(halfpi); |
---|
| 443 | G4AffineTransform tRotZ(r90Z,pzero); |
---|
| 444 | assert(t1.CalculateExtent(kXAxis,limit,tRotZ,min,max)); |
---|
| 445 | assert(min<=-50&&max>=50); |
---|
| 446 | assert(t1.CalculateExtent(kYAxis,limit,tRotZ,min,max)); |
---|
| 447 | assert(min<=-50&&max>=50); |
---|
| 448 | assert(t1.CalculateExtent(kZAxis,limit,tRotZ,min,max)); |
---|
| 449 | assert(min<=-50&&max>=50); |
---|
| 450 | |
---|
| 451 | // Check that clipped away |
---|
| 452 | G4VoxelLimits xClip; |
---|
| 453 | xClip.AddLimit(kXAxis,-300,-200); |
---|
| 454 | assert(!t1.CalculateExtent(kXAxis,xClip,origin,min,max)); |
---|
| 455 | |
---|
| 456 | // Assert clipped to volume |
---|
| 457 | G4VoxelLimits allClip; |
---|
| 458 | allClip.AddLimit(kXAxis,-5,+5); |
---|
| 459 | allClip.AddLimit(kYAxis,-5,+5); |
---|
| 460 | allClip.AddLimit(kZAxis,-5,+5); |
---|
| 461 | G4RotationMatrix genRot; |
---|
| 462 | genRot.rotateX(pi/6); |
---|
| 463 | genRot.rotateY(pi/6); |
---|
| 464 | genRot.rotateZ(pi/6); |
---|
| 465 | G4AffineTransform tGen(genRot,vx); |
---|
| 466 | assert(t4.CalculateExtent(kXAxis,allClip,tGen,min,max)); |
---|
| 467 | // G4cout<<"min = "<<min<<" max = "<<max<<G4endl; |
---|
| 468 | assert(min<=-5&&max>=5); |
---|
| 469 | assert(t4.CalculateExtent(kYAxis,allClip,tGen,min,max)); |
---|
| 470 | assert(min<=-5&&max>=5); |
---|
| 471 | assert(t4.CalculateExtent(kZAxis,allClip,tGen,min,max)); |
---|
| 472 | assert(min<=-5&&max>=5); |
---|
| 473 | |
---|
| 474 | assert(t5.CalculateExtent(kXAxis,allClip,tGen,min,max)); |
---|
| 475 | // G4cout<<"min = "<<min<<" max = "<<max<<G4endl; |
---|
| 476 | assert(t5.CalculateExtent(kYAxis,allClip,tGen,min,max)); |
---|
| 477 | // G4cout<<"min = "<<min<<" max = "<<max<<G4endl; |
---|
| 478 | assert(t5.CalculateExtent(kZAxis,allClip,tGen,min,max)); |
---|
| 479 | // G4cout<<"min = "<<min<<" max = "<<max<<G4endl; |
---|
| 480 | |
---|
| 481 | t1.CalculateExtent(kZAxis,allClip,tGen,min,max); |
---|
| 482 | // G4cout<<"min = "<<min<<" max = "<<max<<G4endl; |
---|
| 483 | |
---|
| 484 | // Test z clipping ok |
---|
| 485 | for (G4double zTest=-200;zTest<200;zTest+=9) |
---|
| 486 | { |
---|
| 487 | G4VoxelLimits zTestClip; |
---|
| 488 | zTestClip.AddLimit(kZAxis,-kInfinity,zTest); |
---|
| 489 | if (zTest<-100) |
---|
| 490 | { |
---|
| 491 | assert(!t4.CalculateExtent(kZAxis,zTestClip,origin,min,max)); |
---|
| 492 | } |
---|
| 493 | else |
---|
| 494 | { |
---|
| 495 | assert(t4.CalculateExtent(kZAxis,zTestClip,origin,min,max)); |
---|
| 496 | G4double testMin=-100+2e3*kCarTolerance; |
---|
| 497 | G4double testMax=(zTest<100-2e3*kCarTolerance) ? zTest : 100-2e3*kCarTolerance; |
---|
| 498 | assert (ApproxEqual(min,testMin) |
---|
| 499 | &&ApproxEqual(max,testMax)); |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | |
---|
| 504 | return true; |
---|
| 505 | } |
---|
| 506 | |
---|
| 507 | int main() |
---|
| 508 | { |
---|
| 509 | #ifdef NDEBUG |
---|
| 510 | G4Exception("FAIL: *** Assertions must be compiled in! ***"); |
---|
| 511 | #endif |
---|
| 512 | assert(testG4Torus()); |
---|
| 513 | return 0; |
---|
| 514 | } |
---|
| 515 | |
---|