[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: testG4BREPSolidOpenPCone.cc,v 1.7 2006/06/29 18:43:25 gunter Exp $ |
---|
[1347] | 28 | // GEANT4 tag $Name: geant4-09-04-ref-00 $ |
---|
[1316] | 29 | ////////////////////////////////////////////////////////////////////////// |
---|
| 30 | // |
---|
| 31 | // |
---|
| 32 | // BREP solid test, create by L. Broglia, 20/10/98 |
---|
| 33 | // modification of old G4Gerep test |
---|
| 34 | // |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | #include <cmath> |
---|
| 38 | #include <fstream> |
---|
| 39 | #include "G4ios.hh" |
---|
| 40 | #include "G4BREPSolid.hh" |
---|
| 41 | #include "G4BREPSolidOpenPCone.hh" |
---|
| 42 | #include "G4Timer.hh" |
---|
| 43 | |
---|
| 44 | #include <iomanip> |
---|
| 45 | |
---|
| 46 | G4int main(G4int argc, char **argv) |
---|
| 47 | { |
---|
| 48 | G4Timer timer; |
---|
| 49 | const G4int noZplanes= 8; |
---|
| 50 | |
---|
| 51 | double RMINVec[noZplanes]; |
---|
| 52 | RMINVec[0] = 30; |
---|
| 53 | RMINVec[1] = 30; |
---|
| 54 | RMINVec[2] = 0; |
---|
| 55 | RMINVec[3] = 0; |
---|
| 56 | RMINVec[4] = 0; |
---|
| 57 | RMINVec[5] = 0; |
---|
| 58 | RMINVec[6] = 40; |
---|
| 59 | RMINVec[7] = 40; |
---|
| 60 | |
---|
| 61 | double RMAXVec[noZplanes]; |
---|
| 62 | RMAXVec[0] = 70; |
---|
| 63 | RMAXVec[1] = 70; |
---|
| 64 | RMAXVec[2] = 70; |
---|
| 65 | RMAXVec[3] = 40; |
---|
| 66 | RMAXVec[4] = 40; |
---|
| 67 | RMAXVec[5] = 80; |
---|
| 68 | RMAXVec[6] = 80; |
---|
| 69 | RMAXVec[7] = 60; |
---|
| 70 | |
---|
| 71 | double Z_Values[noZplanes]; |
---|
| 72 | Z_Values[0] =-20; |
---|
| 73 | Z_Values[1] =-10; |
---|
| 74 | Z_Values[2] =-10; |
---|
| 75 | Z_Values[3] = 0; |
---|
| 76 | Z_Values[4] = 10; |
---|
| 77 | Z_Values[5] = 20; |
---|
| 78 | Z_Values[6] = 30; |
---|
| 79 | Z_Values[7] = 40; |
---|
| 80 | |
---|
| 81 | G4double start_angle= 0.0; |
---|
| 82 | G4double opening_angle= pi; |
---|
| 83 | |
---|
| 84 | G4double zstart= Z_Values[0]; |
---|
| 85 | |
---|
| 86 | G4cout << "\n======= PCon test ========"; |
---|
| 87 | |
---|
| 88 | G4BREPSolidOpenPCone *MyPCone = new G4BREPSolidOpenPCone ("MyPCone", |
---|
| 89 | start_angle, |
---|
| 90 | opening_angle, |
---|
| 91 | noZplanes, |
---|
| 92 | zstart, |
---|
| 93 | Z_Values, |
---|
| 94 | RMINVec, |
---|
| 95 | RMAXVec ); |
---|
| 96 | |
---|
| 97 | G4cout << "\n\nOpen PCone created ! "<<G4endl; |
---|
| 98 | G4cout << "Variety is G4BREPSolidOpenPolycone"<<G4endl; |
---|
| 99 | |
---|
| 100 | G4cout << "Its parameters are: "<<G4endl; |
---|
| 101 | |
---|
| 102 | /////////////////////////////////////////////////// |
---|
| 103 | // Temporary |
---|
| 104 | for (G4int x = 0; x < noZplanes; x++) |
---|
| 105 | { |
---|
| 106 | G4cout << " Z[" << x << "]=" << std::setw(5) << Z_Values[x]; |
---|
| 107 | G4cout << " Rmin[" << x << "]=" << std::setw(5) << RMINVec[x]; |
---|
| 108 | G4cout << " Rmax[" << x << "]=" << std::setw(5) << RMAXVec[x]<<G4endl; |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | G4cout<<" start angle ="<<start_angle<<G4endl; |
---|
| 112 | G4cout<<" opening angle ="<<opening_angle<<G4endl; |
---|
| 113 | G4cout<<" zstart =" << zstart << G4endl; |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | // -> Check methods : |
---|
| 117 | // - Inside |
---|
| 118 | // - DistanceToIn |
---|
| 119 | // - DistanceToOut |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | EInside in; |
---|
| 123 | |
---|
| 124 | G4cout<<"\n\n=================================================="; |
---|
| 125 | G4Point3D pt(0, -100, 24); |
---|
| 126 | G4double y; |
---|
| 127 | for (y = -100; y<=100; y+=10) |
---|
| 128 | { |
---|
| 129 | pt.setY(y); |
---|
| 130 | in = MyPCone->Inside(pt); |
---|
| 131 | |
---|
| 132 | G4cout << "\nx=" << pt.x() << " y=" << pt.y() << " z=" << pt.z(); |
---|
| 133 | |
---|
| 134 | if( in == kInside ) |
---|
| 135 | G4cout <<" is inside"; |
---|
| 136 | else |
---|
| 137 | if( in == kOutside ) |
---|
| 138 | G4cout <<" is outside"; |
---|
| 139 | else |
---|
| 140 | G4cout <<" is on the surface"; |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | G4cout<<"\n\n=================================================="; |
---|
| 144 | G4Point3D start( 0, 0, -30); |
---|
| 145 | G4Vector3D dir(1, 1, 0); |
---|
| 146 | G4double d; |
---|
| 147 | |
---|
| 148 | G4cout<<"\nPdep is (0, 0, z)"; |
---|
| 149 | G4cout<<"\nDir is (1, 1, 0)\n"; |
---|
| 150 | |
---|
| 151 | G4double z; |
---|
| 152 | for(z=-30; z<=50; z+=5) |
---|
| 153 | { |
---|
| 154 | start.setZ(z); |
---|
| 155 | |
---|
| 156 | in = MyPCone->Inside(start); |
---|
| 157 | G4cout<< "x=" << start.x() << " y=" << start.y() << " z=" << start.z(); |
---|
| 158 | |
---|
| 159 | if( in == kInside ) |
---|
| 160 | { |
---|
| 161 | G4cout <<" is inside"; |
---|
| 162 | |
---|
| 163 | d = MyPCone->DistanceToOut(start, dir); |
---|
| 164 | G4cout<<" distance to out="<<d; |
---|
| 165 | d = MyPCone->DistanceToOut(start); |
---|
| 166 | G4cout<<" closest distance to out="<<d<<G4endl; |
---|
| 167 | } |
---|
| 168 | else if( in == kOutside ) |
---|
| 169 | { |
---|
| 170 | G4cout <<" is outside"; |
---|
| 171 | |
---|
| 172 | d = MyPCone->DistanceToIn(start, dir); |
---|
| 173 | G4cout<<" distance to in="<<d; |
---|
| 174 | d = MyPCone->DistanceToIn(start); |
---|
| 175 | G4cout<<" closest distance to in="<<d<<G4endl; |
---|
| 176 | } |
---|
| 177 | else |
---|
| 178 | G4cout <<" is on the surface"<<G4endl; |
---|
| 179 | |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | G4cout<<"\n\n=================================================="; |
---|
| 183 | G4Point3D start2( 0, -100, -30); |
---|
| 184 | G4Vector3D dir2(0, 1, 0); |
---|
| 185 | G4double d2; |
---|
| 186 | |
---|
| 187 | G4cout<<"\nPdep is (0, -100, z)"; |
---|
| 188 | G4cout<<"\nDir is (0, 1, 0)\n"; |
---|
| 189 | |
---|
| 190 | for(z=-30; z<=50; z+=5) |
---|
| 191 | { |
---|
| 192 | G4cout<<" z="<<z; |
---|
| 193 | start2.setZ(z); |
---|
| 194 | d2 = MyPCone->DistanceToIn(start2, dir2); |
---|
| 195 | G4cout<<" distance to in="<<d2; |
---|
| 196 | d2 = MyPCone->DistanceToIn(start2); |
---|
| 197 | G4cout<<" closest distance to in="<<d2<<G4endl; |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | G4cout<<"\n\n=================================================="; |
---|
| 201 | G4Point3D start3( 0, 0, -50); |
---|
| 202 | G4Vector3D dir3(0, 0, 1); |
---|
| 203 | G4double d3; |
---|
| 204 | |
---|
| 205 | G4cout<<"\nPdep is (0, y, -50)"; |
---|
| 206 | G4cout<<"\nDir is (0, 0, 1)\n"; |
---|
| 207 | |
---|
| 208 | for(y=-0; y<=90; y+=5) |
---|
| 209 | { |
---|
| 210 | G4cout<<" y="<<y; |
---|
| 211 | start3.setY(y); |
---|
| 212 | d3 = MyPCone->DistanceToIn(start3, dir3); |
---|
| 213 | G4cout<<" distance to in="<<d3<<G4endl; |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | |
---|
| 217 | return EXIT_SUCCESS; |
---|
| 218 | } |
---|