Geant4  10.02.p02
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) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
37 
38 #include "G4VPVParameterisation.hh"
39 
41 //
42 // Constructors
43 //
44 G4UTrap::G4UTrap( const G4String& pName,
45  G4double pdz,
46  G4double pTheta, G4double pPhi,
47  G4double pdy1, G4double pdx1, G4double pdx2,
48  G4double pAlp1,
49  G4double pdy2, G4double pdx3, G4double pdx4,
50  G4double pAlp2 )
51  : G4USolid(pName, new UTrap(pName, pdz, pTheta, pPhi,
52  pdy1, pdx1, pdx2, pAlp1, pdy2, pdx3, pdx4, pAlp2))
53 {
54 }
55 
56 G4UTrap::G4UTrap( const G4String& pName,
57  const G4ThreeVector pt[8] )
58  : G4USolid(pName, new UTrap(pName))
59 {
60  SetPlanes(pt);
61 }
62 
63 G4UTrap::G4UTrap( const G4String& pName,
64  G4double pZ,
65  G4double pY,
66  G4double pX, G4double pLTX )
67  : G4USolid(pName, new UTrap(pName, pZ, pY, pX, pLTX))
68 {
69 }
70 
71 G4UTrap::G4UTrap( const G4String& pName,
72  G4double pdx1, G4double pdx2,
73  G4double pdy1, G4double pdy2,
74  G4double pdz )
75  : G4USolid(pName, new UTrap(pName, pdx1, pdx2, pdy1, pdy2, pdz))
76 {
77 }
78 
79 G4UTrap::G4UTrap(const G4String& pName,
80  G4double pdx, G4double pdy, G4double pdz,
81  G4double pAlpha, G4double pTheta, G4double pPhi )
82  : G4USolid(pName, new UTrap(pName, pdx, pdy, pdz, pAlpha, pTheta, pPhi))
83 {
84 }
85 
86 G4UTrap::G4UTrap( const G4String& pName )
87  : G4USolid(pName, new UTrap(pName))
88 {
89 }
90 
92 //
93 // Fake default constructor - sets only member data and allocates memory
94 // for usage restricted to object persistency.
95 //
96 G4UTrap::G4UTrap( __void__& a )
97  : G4USolid(a)
98 {
99 }
100 
102 //
103 // Destructor
104 //
105 G4UTrap::~G4UTrap()
106 {
107 }
108 
110 //
111 // Copy constructor
112 //
113 G4UTrap::G4UTrap(const G4UTrap& rhs)
114  : G4USolid(rhs)
115 {
116 }
117 
119 //
120 // Assignment operator
121 //
122 G4UTrap& G4UTrap::operator = (const G4UTrap& rhs)
123 {
124  // Check assignment to self
125  //
126  if (this == &rhs) { return *this; }
127 
128  // Copy base class data
129  //
130  G4USolid::operator=(rhs);
131 
132  return *this;
133 }
134 
136 //
137 // Accessors & modifiers
138 
139 G4double G4UTrap::GetZHalfLength() const
140 {
141  return GetShape()->GetZHalfLength();
142 }
143 G4double G4UTrap::GetYHalfLength1() const
144 {
145  return GetShape()->GetYHalfLength1();
146 }
147 G4double G4UTrap::GetXHalfLength1() const
148 {
149  return GetShape()->GetXHalfLength1();
150 }
151 G4double G4UTrap::GetXHalfLength2() const
152 {
153  return GetShape()->GetXHalfLength2();
154 }
155 G4double G4UTrap::GetTanAlpha1() const
156 {
157  return GetShape()->GetTanAlpha1();
158 }
159 G4double G4UTrap::GetYHalfLength2() const
160 {
161  return GetShape()->GetYHalfLength2();
162 }
163 G4double G4UTrap::GetXHalfLength3() const
164 {
165  return GetShape()->GetXHalfLength3();
166 }
167 G4double G4UTrap::GetXHalfLength4() const
168 {
169  return GetShape()->GetXHalfLength4();
170 }
171 G4double G4UTrap::GetTanAlpha2() const
172 {
173  return GetShape()->GetTanAlpha2();
174 }
175 TrapSidePlane G4UTrap::GetSidePlane(G4int n) const
176 {
177  UTrapSidePlane iplane = GetShape()->GetSidePlane(n);
178  TrapSidePlane oplane = {iplane.a, iplane.b, iplane.c, iplane.d };
179  return oplane;
180 }
181 G4ThreeVector G4UTrap::GetSymAxis() const
182 {
183  UVector3 axis = GetShape()->GetSymAxis();
184  return G4ThreeVector(axis.x(), axis.y(), axis.z());
185 }
186 
187 void G4UTrap::SetAllParameters(G4double pDz, G4double pTheta, G4double pPhi,
188  G4double pDy1, G4double pDx1, G4double pDx2,
189  G4double pAlp1,
190  G4double pDy2, G4double pDx3, G4double pDx4,
191  G4double pAlp2)
192 {
193  GetShape()->SetAllParameters(pDz, pTheta, pPhi,
194  pDy1, pDx1, pDx2, pAlp1,
195  pDy2, pDx3, pDx4, pAlp2);
196  fRebuildPolyhedron = true;
197 }
198 
199 void G4UTrap::SetPlanes(const G4ThreeVector pt[8])
200 {
201  UVector3 upt[8];
202  for (unsigned int i=0; i<8; ++i)
203  {
204  upt[i] = UVector3(pt[i].x(), pt[i].y(), pt[i].z());
205  }
206  GetShape()->SetPlanes(upt);
207  fRebuildPolyhedron = true;
208 }
209 
211 //
212 // Dispatch to parameterisation for replication mechanism dimension
213 // computation & modification.
214 //
215 void G4UTrap::ComputeDimensions( G4VPVParameterisation* p,
216  const G4int n,
217  const G4VPhysicalVolume* pRep)
218 {
219  p->ComputeDimensions(*(G4Trap*)this,n,pRep);
220 }
221 
223 //
224 // Make a clone of the object
225 //
226 G4VSolid* G4UTrap::Clone() const
227 {
228  return new G4UTrap(*this);
229 }
230 
232 //
233 // Create polyhedron for visualization
234 //
235 G4Polyhedron* G4UTrap::CreatePolyhedron() const
236 {
237  G4double fTthetaSphi = GetShape()->GetThetaSphi();
238  G4double fTthetaCphi = GetShape()->GetThetaCphi();
239  G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
240  G4double alpha1 = std::atan(GetTanAlpha1());
241  G4double alpha2 = std::atan(GetTanAlpha2());
242  G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi+fTthetaSphi*fTthetaSphi));
243 
244  return new G4PolyhedronTrap(GetZHalfLength(), theta, phi,
245  GetYHalfLength1(),
246  GetXHalfLength1(), GetXHalfLength2(), alpha1,
247  GetYHalfLength2(),
248  GetXHalfLength3(), GetXHalfLength4(), alpha2);
249 }
250 
251 #endif // G4GEOM_USE_USOLIDS
CLHEP::Hep3Vector G4ThreeVector
G4double z
Definition: TRTMaterials.hh:39
G4double a
Definition: TRTMaterials.hh:39
int G4int
Definition: G4Types.hh:78
G4double a
Definition: G4Trap.hh:103
const G4int n
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
const G4double x[NPOINTSGL]
double G4double
Definition: G4Types.hh:76