// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // // $Id: testG4Cons1.cc,v 1.8 2007/04/23 13:58:39 grichine Exp $ // GEANT4 tag $Name: geant4-09-04-ref-00 $ // // testG4Cons // // Test file for class G4Cons [NOT thorough] // // Ensure asserts are compiled in #include #include #include "G4ios.hh" #include "globals.hh" #include "geomdefs.hh" #include "ApproxEqual.hh" #include "G4ThreeVector.hh" #include "G4Cons.hh" #include "G4RotationMatrix.hh" #include "G4AffineTransform.hh" #include "G4VoxelLimits.hh" G4bool testG4Cons() { G4ThreeVector pzero(0,0,0); G4ThreeVector pbigx(100,0,0),pbigy(0,100,0),pbigz(0,0,100); G4ThreeVector pbigmx(-100,0,0),pbigmy(0,-100,0),pbigmz(0,0,-100); G4ThreeVector ponxside(50,0,0); G4ThreeVector vx(1,0,0),vy(0,1,0),vz(0,0,1); G4ThreeVector vmx(-1,0,0),vmy(0,-1,0),vmz(0,0,-1); G4ThreeVector vxy(1/std::sqrt(2.0),1/std::sqrt(2.0),0); G4ThreeVector vmxy(-1/std::sqrt(2.0),1/std::sqrt(2.0),0); G4ThreeVector vmxmy(-1/std::sqrt(2.0),-1/std::sqrt(2.0),0); G4ThreeVector vxmy(1/std::sqrt(2.0),-1/std::sqrt(2.0),0); G4double Dist; G4ThreeVector *pNorm,norm; G4bool *pgoodNorm,goodNorm,calcNorm=true; pNorm=&norm; pgoodNorm=&goodNorm; G4Cons t1("Solid TubeLike #1",0,50,0,50,50,0,360); G4Cons test10("test10",20.0, 80.0, 60.0, 140.0, 100.0, 0.17453292519943, 5.235987755983); G4Cons test10a( "aCone", 2*cm, 6*cm, 8*cm, 14*cm, 10*cm, 10*deg, 300*deg ); // Check name assert(t1.GetName()=="Solid TubeLike #1"); // Check Inside assert(t1.Inside(pzero)==kInside); assert(t1.Inside(pbigx)==kOutside); // Check Surface Normal G4ThreeVector normal; normal=t1.SurfaceNormal(ponxside); assert(ApproxEqual(normal,vx)); // DistanceToOut(P) Dist=t1.DistanceToOut(pzero); assert(ApproxEqual(Dist,50)); // DistanceToOut(P,V) Dist=t1.DistanceToOut(pzero,vx,calcNorm,pgoodNorm,pNorm); assert(ApproxEqual(Dist,50)&&ApproxEqual(pNorm->unit(),vx)&&*pgoodNorm); Dist=t1.DistanceToOut(pzero,vmx,calcNorm,pgoodNorm,pNorm); assert(ApproxEqual(Dist,50)&&ApproxEqual(pNorm->unit(),vmx)&&*pgoodNorm); Dist=t1.DistanceToOut(pzero,vy,calcNorm,pgoodNorm,pNorm); assert(ApproxEqual(Dist,50)&&ApproxEqual(pNorm->unit(),vy)&&*pgoodNorm); Dist=t1.DistanceToOut(pzero,vmy,calcNorm,pgoodNorm,pNorm); assert(ApproxEqual(Dist,50)&&ApproxEqual(pNorm->unit(),vmy)&&*pgoodNorm); Dist=t1.DistanceToOut(pzero,vz,calcNorm,pgoodNorm,pNorm); assert(ApproxEqual(Dist,50)&&ApproxEqual(pNorm->unit(),vz)&&*pgoodNorm); Dist=t1.DistanceToOut(pzero,vmz,calcNorm,pgoodNorm,pNorm); assert(ApproxEqual(Dist,50)&&ApproxEqual(pNorm->unit(),vmz)&&*pgoodNorm); Dist=t1.DistanceToOut(pzero,vxy,calcNorm,pgoodNorm,pNorm); assert(ApproxEqual(Dist,50)&&ApproxEqual(pNorm->unit(),vxy)&&*pgoodNorm); //DistanceToIn(P) Dist=t1.DistanceToIn(pbigx); assert(ApproxEqual(Dist,50)); Dist=t1.DistanceToIn(pbigmx); assert(ApproxEqual(Dist,50)); Dist=t1.DistanceToIn(pbigy); assert(ApproxEqual(Dist,50)); Dist=t1.DistanceToIn(pbigmy); assert(ApproxEqual(Dist,50)); Dist=t1.DistanceToIn(pbigz); assert(ApproxEqual(Dist,50)); Dist=t1.DistanceToIn(pbigmz); assert(ApproxEqual(Dist,50)); // DistanceToIn(P,V) Dist=t1.DistanceToIn(pbigx,vmx); assert(ApproxEqual(Dist,50)); Dist=t1.DistanceToIn(pbigmx,vx); assert(ApproxEqual(Dist,50)); Dist=t1.DistanceToIn(pbigy,vmy); assert(ApproxEqual(Dist,50)); Dist=t1.DistanceToIn(pbigmy,vy); assert(ApproxEqual(Dist,50)); Dist=t1.DistanceToIn(pbigz,vmz); assert(ApproxEqual(Dist,50)); Dist=t1.DistanceToIn(pbigmz,vz); assert(ApproxEqual(Dist,50)); Dist=t1.DistanceToIn(pbigx,vxy); assert(ApproxEqual(Dist,kInfinity)); Dist=test10.DistanceToIn(G4ThreeVector(19.218716967888,5.5354239324172,-100.0), G4ThreeVector(-0.25644483536346,-0.073799216676426,0.96373737191901)); G4cout<<"test10::DistToIn ="<