source: trunk/source/geometry/solids/BREPS/test/G4BREPSolidBoxTest.cc@ 1349

Last change on this file since 1349 was 1347, checked in by garnier, 15 years ago

geant4 tag 9.4

File size: 4.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: G4BREPSolidBoxTest.cc,v 1.9 2006/06/29 18:43:07 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-ref-00 $
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 "G4Timer.hh"
38#include "globals.hh"
39#include "G4BREPSolid.hh"
40#include "G4BREPSolidBox.hh"
41
42
43int main()
44{
45 G4ThreeVector tStart(19000,0,10.1);
46 G4ThreeVector tDir(-1,0,0);
47 G4ThreeVector tStart2(0,0,10);
48 G4ThreeVector pt(0,0,50);
49 G4ThreeVector pt2(100000,0,50);
50
51G4cout << "\n ============ Box test ================";
52
53 G4BREPSolidBox *myCalBox = new G4BREPSolidBox
54 ( "MyBox",
55 G4Point3D(-1500, -1500, -1000),
56 G4Point3D(-1500, -1500, 1000),
57 G4Point3D(-1500, 1500, 1000),
58 G4Point3D(-1500, 1500, -1000),
59 G4Point3D( 1500, -1500, -1000),
60 G4Point3D( 1500, -1500, 1000),
61 G4Point3D( 1500, 1500, 1000),
62 G4Point3D( 1500, 1500, -1000) );
63
64 G4cout << "\n\nBox created ! ";
65
66 // -> Check methods :
67 // - Inside
68 // - DistanceToIn
69 // - DistanceToOut
70
71 G4ThreeVector Pt[4];
72 Pt[0] = G4ThreeVector( 1, 1, 100);
73 Pt[1] = G4ThreeVector( 1000, 1000, 5000);
74 Pt[2] = G4ThreeVector(-1000,-1000,-5000);
75 Pt[3] = G4ThreeVector( 0, 0, -100);
76
77 G4ThreeVector Dir[4];
78 Dir[0] = G4ThreeVector( 1, 0, 0);
79 Dir[1] = G4ThreeVector( 0, 1, 0);
80 Dir[2] = G4ThreeVector( 0, 0, 1);
81 Dir[3] = G4ThreeVector( 1, 1, -1);
82
83 EInside in[4];
84 G4double dist[4][3];
85
86 G4cout<<"\n\n";
87
88 for (G4int a = 0; a<4; a++)
89 {
90 in[a] = myCalBox->Inside(Pt[a]);
91
92 G4cout<<"----------------------------\n\n";
93
94 G4cout<<"x="<<Pt[a].x()
95 <<" y="<<Pt[a].y()<<" z="<<Pt[a].z();
96
97 if( in[a] == kInside )
98 {
99 G4cout <<" is inside"<<G4endl;
100
101 dist[a][1] = myCalBox->DistanceToOut(Pt[a]);
102 G4cout<<"\nDistance to out is :"<<dist[a][1]<<G4endl;
103
104 G4cout << "\nDir : x=" << Dir[a].x()
105 << " y=" << Dir[a].y()
106 << " z=" << Dir[a].z()<<G4endl;
107 dist[a][2] = myCalBox->DistanceToOut(Pt[a], Dir[a]);
108 G4cout<<"Distance to out is :"<<dist[a][2]<<G4endl;
109
110 }
111 else
112 {
113 G4cout <<" is outside"<<G4endl;
114
115 dist[a][1] = myCalBox->DistanceToIn(Pt[a]);
116 G4cout<<"\nDistance to in is :"<<dist[a][1]<<G4endl;
117
118 G4cout << "\nDir : x=" << Dir[a].x()
119 << " y=" << Dir[a].y()
120 << " z=" << Dir[a].z()<<G4endl;
121 dist[a][2] = myCalBox->DistanceToIn(Pt[a], Dir[a]);
122 G4cout<<"Distance to in is :"<<dist[a][2];
123 }
124 G4cout<<G4endl;
125 }
126
127 return EXIT_SUCCESS;
128}
129
Note: See TracBrowser for help on using the repository browser.