Geant4  10.02.p01
G4UTrap.cc
Go to the documentation of this file.
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:$
28 //
29 //
30 // Implementation for G4UTrap wrapper class
31 // --------------------------------------------------------------------
32 
33 #include "G4Trap.hh"
34 #include "G4UTrap.hh"
35 
36 #if defined(G4GEOM_USE_USOLIDS)
37 
38 #include "G4VPVParameterisation.hh"
39 #include "G4Polyhedron.hh"
40 
42 //
43 // Constructors
44 //
45 G4UTrap::G4UTrap( const G4String& pName,
46  G4double pdz,
47  G4double pTheta, G4double pPhi,
48  G4double pdy1, G4double pdx1, G4double pdx2,
49  G4double pAlp1,
50  G4double pdy2, G4double pdx3, G4double pdx4,
51  G4double pAlp2 )
52  : G4USolid(pName, new UTrap(pName, pdz, pTheta, pPhi,
53  pdy1, pdx1, pdx2, pAlp1, pdy2, pdx3, pdx4, pAlp2))
54 {
55 }
56 
57 G4UTrap::G4UTrap( const G4String& pName,
58  const G4ThreeVector pt[8] )
59  : G4USolid(pName, new UTrap(pName))
60 {
61  SetPlanes(pt);
62 }
63 
64 G4UTrap::G4UTrap( const G4String& pName,
65  G4double pZ,
66  G4double pY,
67  G4double pX, G4double pLTX )
68  : G4USolid(pName, new UTrap(pName, pZ, pY, pX, pLTX))
69 {
70 }
71 
72 G4UTrap::G4UTrap( const G4String& pName,
73  G4double pdx1, G4double pdx2,
74  G4double pdy1, G4double pdy2,
75  G4double pdz )
76  : G4USolid(pName, new UTrap(pName, pdx1, pdx2, pdy1, pdy2, pdz))
77 {
78 }
79 
80 G4UTrap::G4UTrap(const G4String& pName,
81  G4double pdx, G4double pdy, G4double pdz,
82  G4double pAlpha, G4double pTheta, G4double pPhi )
83  : G4USolid(pName, new UTrap(pName, pdx, pdy, pdz, pAlpha, pTheta, pPhi))
84 {
85 }
86 
87 G4UTrap::G4UTrap( const G4String& pName )
88  : G4USolid(pName, new UTrap(pName))
89 {
90 }
91 
93 //
94 // Fake default constructor - sets only member data and allocates memory
95 // for usage restricted to object persistency.
96 //
97 G4UTrap::G4UTrap( __void__& a )
98  : G4USolid(a)
99 {
100 }
101 
103 //
104 // Destructor
105 //
106 G4UTrap::~G4UTrap()
107 {
108 }
109 
111 //
112 // Copy constructor
113 //
114 G4UTrap::G4UTrap(const G4UTrap& rhs)
115  : G4USolid(rhs)
116 {
117 }
118 
120 //
121 // Assignment operator
122 //
123 G4UTrap& G4UTrap::operator = (const G4UTrap& rhs)
124 {
125  // Check assignment to self
126  //
127  if (this == &rhs) { return *this; }
128 
129  // Copy base class data
130  //
131  G4USolid::operator=(rhs);
132 
133  return *this;
134 }
135 
137 //
138 // Dispatch to parameterisation for replication mechanism dimension
139 // computation & modification.
140 //
141 void G4UTrap::ComputeDimensions( G4VPVParameterisation* p,
142  const G4int n,
143  const G4VPhysicalVolume* pRep)
144 {
145  p->ComputeDimensions(*(G4Trap*)this,n,pRep);
146 }
147 
149 //
150 // Make a clone of the object
151 //
152 G4VSolid* G4UTrap::Clone() const
153 {
154  return new G4UTrap(*this);
155 }
156 
158 //
159 // CreatePolyhedron()
160 //
161 G4Polyhedron* G4UTrap::CreatePolyhedron() const
162 {
163  G4double fTthetaSphi = GetShape()->GetThetaSphi();
164  G4double fTthetaCphi = GetShape()->GetThetaCphi();
165  G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
166  G4double alpha1 = std::atan(GetTanAlpha1());
167  G4double alpha2 = std::atan(GetTanAlpha2());
168  G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi+fTthetaSphi*fTthetaSphi));
169 
170  return new G4PolyhedronTrap(GetZHalfLength(), theta, phi,
171  GetYHalfLength1(),
172  GetXHalfLength1(), GetXHalfLength2(), alpha1,
173  GetYHalfLength2(),
174  GetXHalfLength3(), GetXHalfLength4(), alpha2);
175 }
176 
177 #endif // G4GEOM_USE_USOLIDS
CLHEP::Hep3Vector G4ThreeVector
G4double a
Definition: TRTMaterials.hh:39
int G4int
Definition: G4Types.hh:78
const G4int n
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
double G4double
Definition: G4Types.hh:76