source: trunk/source/geometry/solids/specific/test/testG4TwistedTrap.cc@ 1337

Last change on this file since 1337 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.7 KB
RevLine 
[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: testG4TwistedTrap.cc,v 1.10 2006/06/29 18:49:53 gunter Exp $
28// GEANT4 tag $Name:
29//
30
31// testG4TwistedTrap
32//
33// Test file for class G4TwistedTrap
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 "G4ThreeVector.hh"
44#include "G4TwistedTrd.hh"
45#include "G4TwistedTrap.hh"
46#include "G4RotationMatrix.hh"
47#include "G4AffineTransform.hh"
48#include "G4VoxelLimits.hh"
49
50const G4String OutputInside(const EInside a)
51{
52 switch(a)
53 {
54 case kInside: return "Inside";
55 case kOutside: return "Outside";
56 case kSurface: return "Surface";
57 }
58 return "????";
59}
60
61
62G4bool testG4TwistedTrap()
63{
64 G4ThreeVector pzero(0,0,0);
65 G4ThreeVector pout(100*cm,100*cm,100*cm) ;
66 G4ThreeVector dir1 = pzero-pout ;
67
68 dir1 *= 1./dir1.mag();
69
70 G4TwistedTrd t1("Solid Twisted Trd #1",
71 10*cm,
72 15*cm,
73 20*cm,
74 20*cm,
75 80*cm,
76 60*deg);
77
78
79 G4TwistedTrap t2("Solid Twisted Regular Trap",
80 60*deg,
81 10*cm,
82 15*cm,
83 20*cm,
84 80*cm) ;
85
86 G4TwistedTrap t3("Solid General Twisted Trap",
87 60*deg,
88 80*cm,
89 10*deg,
90 40*deg,
91 16*cm,
92 24*cm,
93 14*cm,
94 8*cm,
95 16*cm,
96 11*cm,
97 50*deg) ;
98
99 G4double dist = t1.DistanceToIn(pout,dir1) ;
100 G4cout << "distance to = " << t1.GetName() << " = " << dist/cm << " cm" << G4endl ;
101
102 dist = t2.DistanceToIn(pout,dir1) ;
103 G4cout << "distance to = " << t2.GetName() << " = " << dist/cm << " cm" << G4endl ;
104
105 dist = t3.DistanceToIn(pout,dir1) ;
106 G4cout << "distance to = " << t3.GetName() << " = " << dist/cm << " cm" << G4endl ;
107
108// Check Inside
109
110 G4cout << "Test " << t1.GetName() << " Inside(pzero) is " << t1.Inside(pzero) << G4endl ;
111 G4cout << "Test " << t1.GetName() << " Inside(pout) is " << t1.Inside(pout) << G4endl ;
112 G4cout << "Test " << t2.GetName() << " Inside(pzero) is " << t2.Inside(pzero) << G4endl ;
113 G4cout << "Test " << t2.GetName() << " Inside(pout) is " << t2.Inside(pout) << G4endl ;
114
115 G4cout << "Test " << t3.GetName() << " Inside(pzero) is " << t3.Inside(pzero) << G4endl ;
116 G4cout << "Test " << t3.GetName() << " Inside(pout) is " << t3.Inside(pout) << G4endl ;
117 //assert(t1.Inside(pzero)==kInside) ;
118
119 // test GetPointOnSurface
120
121 G4ThreeVector Spoint ;
122 G4ThreeVector Opoint ;
123 G4ThreeVector dir ;
124
125 EInside side ;
126 for ( int i = 0 ; i < 10 ; i++ ) {
127 // G4cout << "Event " << i << G4endl << G4endl ;
128 Spoint = t3.GetPointOnSurface() ;
129 Opoint = t3.GetPointInSolid(Spoint.z()) ;
130 dir = Opoint - Spoint ;
131
132 side = t3.Inside(Spoint) ;
133 // G4cout << "SInside = " << OutputInside(side) << G4endl ;
134 dist = t3.DistanceToIn(Spoint,dir/dir.mag()) ;
135 G4cout << "Spoint " << Spoint << " " << dist << " " << side << G4endl ;
136 }
137
138 // t3.CreatePolyhedron() ;
139
140 return true;
141}
142
143int main()
144{
145#ifdef NDEBUG
146 G4Exception("FAIL: *** Assertions must be compiled in! ***");
147#endif
148 assert(testG4TwistedTrap());
149 return 0;
150}
151
152
Note: See TracBrowser for help on using the repository browser.