source: trunk/source/geometry/solids/BREPS/test/G4BREPSolidPolyhedraTest.cc@ 1330

Last change on this file since 1330 was 1316, checked in by garnier, 15 years ago

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File size: 5.3 KB
Line 
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: G4BREPSolidPolyhedraTest.cc,v 1.12 2006/06/29 18:43:17 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
29//////////////////////////////////////////////////////////////////////////
30//
31//
32// BREP solid test, create by L. Broglia, 20/10/98
33// modification of old G4Gerep test
34//
35
36#include "G4Timer.hh"
37#include <cmath>
38#include <fstream>
39#include "G4ios.hh"
40#include "G4Axis2Placement3D.hh"
41#include "G4BREPSolid.hh"
42#include "G4BREPSolidPolyhedra.hh"
43
44
45int main()
46{
47
48 G4double RMINVec[5];
49 RMINVec[0] = 10;
50 RMINVec[1] = 10;
51 RMINVec[2] = 60;
52 RMINVec[3] = 30;
53 RMINVec[4] = 30;
54
55 G4double RMAXVec[5];
56 RMAXVec[0] = 50;
57 RMAXVec[1] = 50;
58 RMAXVec[2] = 100;
59 RMAXVec[3] = 100;
60 RMAXVec[4] = 80;
61
62 G4double Z_Values[5];
63 Z_Values[0] = 0;
64 Z_Values[1] = 10;
65 Z_Values[2] = 20;
66 Z_Values[3] = 30;
67 Z_Values[4] = 40;
68
69
70 G4cout << "\n======= PolyGon test ========"<<G4endl;
71
72 G4BREPSolidPolyhedra *MyPGone = new G4BREPSolidPolyhedra ("MyPolyhedra",
73 0 ,
74 2*pi ,
75 4 ,
76 5 ,
77 0 ,
78 Z_Values ,
79 RMINVec ,
80 RMAXVec );
81 G4cout << "\n\nPgon (G4BREPSolid-Polyhedra) created ! "<<G4endl;
82 // -> Check methods :
83 // - Inside
84 // - DistanceToIn
85 // - DistanceToOut
86
87
88 EInside in;
89
90 G4cout<<"\n\n==================================================";
91 G4ThreeVector pt(0, -110, 20);
92 for (G4int y = -110; y<=110; y+=10)
93 {
94 pt.setY(y);
95 in = MyPGone->Inside(pt);
96
97 G4cout << "\nx=" << pt.x() << " y=" << pt.y() << " z=" << pt.z();
98
99 if( in == kInside )
100 G4cout <<" is inside";
101 else
102 if( in == kOutside )
103 G4cout <<" is outside";
104 else
105 G4cout <<" is on the surface";
106 }
107
108 G4cout<<"\n\n==================================================";
109 G4ThreeVector start( 0, 0, -5);
110 G4ThreeVector dir1(1, 0, 0);
111 G4ThreeVector dir2(1, 1, 0);
112 G4double d1, d2;
113 G4double z;
114
115 G4cout<<"\nPdep is (0, 0, z)";
116 G4cout<<"\nDir1 is (1, 0, 0)\n";
117 G4cout<<"\nDir2 is (1, 1, 0)\n";
118
119 for(z=-5; z<=45; z+=5)
120 {
121 start.setZ(z);
122
123 in = MyPGone->Inside(start);
124 G4cout<< "x=" << start.x() << " y=" << start.y() << " z=" << start.z();
125
126 if( in == kInside )
127 {
128 G4cout <<" is inside";
129
130 d1 = MyPGone->DistanceToOut(start, dir1);
131 G4cout<<" distance to out1 ="<<d1;
132 d2 = MyPGone->DistanceToOut(start, dir2);
133 G4cout<<" distance to out2 ="<<d2<<G4endl;
134 }
135 else if( in == kOutside )
136 {
137 G4cout <<" is outside";
138
139 d1 = MyPGone->DistanceToIn(start, dir1);
140 G4cout<<" distance to in1 ="<<d1;
141 d2 = MyPGone->DistanceToIn(start, dir2);
142 G4cout<<" distance to in2 ="<<d2<<G4endl;
143 }
144 else
145 G4cout <<" is on the surface"<< G4endl;
146 }
147
148 G4cout<<"\n\n==================================================";
149 G4ThreeVector start3( -110, -110, -5);
150 G4ThreeVector dir3( 1, 1, 0);
151 G4double d3;
152
153 G4cout<<"\nPdep is (-110, -110, z)";
154 G4cout<<"\nDir is (1, 1, 0)\n";
155
156 for(z=-5; z<=45; z+=5)
157 {
158 start3.setZ(z);
159
160 in = MyPGone->Inside(start3);
161 G4cout<<"x=" << start3.x() << " y=" << start3.y() << " z=" << start3.z();
162
163 if( in == kInside )
164 {
165 G4cout <<" is inside";
166
167 d3 = MyPGone->DistanceToOut(start3, dir3);
168 G4cout<<" distance to out ="<<d3<<G4endl;
169 }
170 else if( in == kOutside )
171 {
172 G4cout <<" is outside";
173
174 d3= MyPGone->DistanceToIn(start3, dir3);
175 G4cout<<" distance to in ="<<d3<<G4endl;
176 }
177 else
178 G4cout <<" is on the surface"<< G4endl;
179 }
180
181 G4cout << G4endl << G4endl;
182}
183
Note: See TracBrowser for help on using the repository browser.