source: trunk/source/geometry/solids/BREPS/test/G4BREPSolidCylinderTest.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: 4.0 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: G4BREPSolidCylinderTest.cc,v 1.11 2006/06/29 18:43:11 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 "G4BREPSolid.hh"
41#include "G4BREPSolidCylinder.hh"
42
43
44int main()
45{
46
47 G4cout << "\n ============ Cylinder test ================";
48
49 G4BREPSolidCylinder *myCyl= new G4BREPSolidCylinder("MyCylBox",
50 G4ThreeVector(0,0,0),
51 G4ThreeVector(0,0,1),
52 G4ThreeVector(1,0,0),
53 100.0 ,
54 1000.0 );
55
56 G4cout << "\n\nCylinder created ! ";
57
58 // -> Check methods :
59 // - Inside
60 // - DistanceToIn
61 // - DistanceToOut
62
63 G4ThreeVector Pt[4];
64 Pt[0] = G4ThreeVector( 1, 1, 100);
65 Pt[1] = G4ThreeVector( 1000, 0, 5000);
66 Pt[2] = G4ThreeVector( -50, -50,-5000);
67 Pt[3] = G4ThreeVector( 0, 0, 200);
68
69 G4ThreeVector Dir[4];
70 Dir[0] = G4ThreeVector( 1, 0, 0);
71 Dir[1] = G4ThreeVector( 0, 1, 0);
72 Dir[2] = G4ThreeVector( 0, 0, 1);
73 Dir[3] = G4ThreeVector( 1, 1, -1);
74
75 EInside in[4];
76 G4double dist[4][3];
77
78 G4cout<<"\n\n";
79
80 for (G4int a = 0; a<4; a++)
81 {
82 in[a] = myCyl->Inside(Pt[a]);
83
84 G4cout<<"----------------------------\n\n";
85
86 G4cout<<"x="<<Pt[a].x()
87 <<" y="<<Pt[a].y()<<" z="<<Pt[a].z();
88
89 if( in[a] == kInside )
90 {
91 G4cout <<" is inside"<<G4endl;
92
93 dist[a][1] = myCyl->DistanceToOut(Pt[a]);
94 G4cout<<"\nDistance to out is :"<<dist[a][1]<<G4endl;
95
96 G4cout << "\nDir : x=" << Dir[a].x()
97 << " y=" << Dir[a].y()
98 << " z=" << Dir[a].z()<<G4endl;
99 dist[a][2] = myCyl->DistanceToOut(Pt[a], Dir[a]);
100 G4cout<<"Distance to out is :"<<dist[a][2]<<G4endl;
101
102 }
103 else
104 {
105 G4cout <<" is outside"<<G4endl;
106
107 dist[a][1] = myCyl->DistanceToIn(Pt[a]);
108 G4cout<<"\nDistance to in is :"<<dist[a][1]<<G4endl;
109
110 G4cout << "\nDir : x=" << Dir[a].x()
111 << " y=" << Dir[a].y()
112 << " z=" << Dir[a].z()<<G4endl;
113 dist[a][2] = myCyl->DistanceToIn(Pt[a], Dir[a]);
114 G4cout<<"Distance to in is :"<<dist[a][2];
115 }
116 G4cout<<G4endl;
117 }
118
119
120
121 return EXIT_SUCCESS;
122}
Note: See TracBrowser for help on using the repository browser.