| [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: testG4Tet.cc,v 1.3 2006/06/29 18:49:49 gunter Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
|
|---|
| 29 | //
|
|---|
| 30 |
|
|---|
| 31 | // testG4Tet
|
|---|
| 32 | //
|
|---|
| 33 | // Test file for class G4Tet [NOT thorough]
|
|---|
| 34 | //
|
|---|
| 35 | // Ensure asserts are compiled in
|
|---|
| 36 |
|
|---|
| 37 | #include <assert.h>
|
|---|
| 38 | #include <cmath>
|
|---|
| 39 |
|
|---|
| 40 | #include "globals.hh"
|
|---|
| 41 | #include "geomdefs.hh"
|
|---|
| 42 |
|
|---|
| 43 | #include "ApproxEqual.hh"
|
|---|
| 44 |
|
|---|
| 45 | #include "G4ThreeVector.hh"
|
|---|
| 46 | #include "G4Tet.hh"
|
|---|
| 47 | #include "G4RotationMatrix.hh"
|
|---|
| 48 | #include "G4AffineTransform.hh"
|
|---|
| 49 | #include "G4VoxelLimits.hh"
|
|---|
| 50 |
|
|---|
| 51 | G4bool testG4Tet()
|
|---|
| 52 | {
|
|---|
| 53 | G4ThreeVector pzero(0,0,0);
|
|---|
| 54 | G4ThreeVector pnt1(10.,0.,0.),pnt2(5.0,10.,0), pnt3(5.,5.,10.);
|
|---|
| 55 |
|
|---|
| 56 | G4ThreeVector *pNorm,norm;
|
|---|
| 57 | G4bool *pgoodNorm,goodNorm;
|
|---|
| 58 |
|
|---|
| 59 | pNorm=&norm;
|
|---|
| 60 | pgoodNorm=&goodNorm;
|
|---|
| 61 |
|
|---|
| 62 | G4bool goodTet;
|
|---|
| 63 | G4Tet t1( "Solid Tet #1", pzero, pnt1, pnt2, pnt3, &goodTet);
|
|---|
| 64 |
|
|---|
| 65 | // Check name
|
|---|
| 66 | assert(t1.GetName()=="Solid Tet #1");
|
|---|
| 67 |
|
|---|
| 68 | G4ThreeVector pntA( 1.0 , 1.0 , 1.0 );
|
|---|
| 69 | G4ThreeVector pntB( 1.5 , 0.5 , 1.0 );
|
|---|
| 70 | // G4ThreeVector pntBbis= 0.1 * (pnt1-pzero) + 0.1 * (pnt3-pzero);
|
|---|
| 71 | G4ThreeVector pntBr023= (1.0/3.0) * (pzero + pnt2 + pnt3);
|
|---|
| 72 | G4ThreeVector pntC( 0.0, 5.0 , 1.5 );
|
|---|
| 73 |
|
|---|
| 74 | // Check Inside
|
|---|
| 75 | assert(t1.Inside(pntA)==kInside);
|
|---|
| 76 | assert(t1.Inside(pntB)==kSurface);
|
|---|
| 77 | assert(t1.Inside(pntBr023)==kSurface);
|
|---|
| 78 | assert(t1.Inside(pntC)==kOutside);
|
|---|
| 79 |
|
|---|
| 80 | // Check Surface Normal
|
|---|
| 81 | G4ThreeVector normal;
|
|---|
| 82 | G4ThreeVector pntOnBotSurf012( 5.0, 5.0, 0.0);
|
|---|
| 83 | G4ThreeVector vmz(0,0,-1.0);
|
|---|
| 84 |
|
|---|
| 85 | normal=t1.SurfaceNormal(pntOnBotSurf012);
|
|---|
| 86 | assert(ApproxEqual(normal,vmz));
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | return true;
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | int main()
|
|---|
| 93 | {
|
|---|
| 94 | #ifdef NDEBUG
|
|---|
| 95 | G4Exception("FAIL: *** Assertions must be compiled in! ***");
|
|---|
| 96 | #endif
|
|---|
| 97 | assert(testG4Tet());
|
|---|
| 98 | return 0;
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|