source: trunk/source/geometry/solids/CSG/include/G4Tubs.icc@ 1350

Last change on this file since 1350 was 1337, checked in by garnier, 15 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 5.4 KB
RevLine 
[831]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//
[1228]27// $Id: G4Tubs.icc,v 1.14 2009/06/09 16:08:23 gcosmo Exp $
[1337]28// GEANT4 tag $Name: geant4-09-04-beta-01 $
[831]29//
30// --------------------------------------------------------------------
31// GEANT 4 inline definitions file
32//
33// G4Tubs.icc
34//
35// Implementation of inline methods of G4Tubs
36// --------------------------------------------------------------------
37
38inline
39G4double G4Tubs::GetInnerRadius () const
40{
41 return fRMin;
42}
43
44inline
45G4double G4Tubs::GetOuterRadius () const
46{
47 return fRMax;
48}
49
50inline
51G4double G4Tubs::GetZHalfLength () const
52{
53 return fDz;
54}
55
56inline
57G4double G4Tubs::GetStartPhiAngle () const
58{
59 return fSPhi;
60}
61
62inline
63G4double G4Tubs::GetDeltaPhiAngle () const
64{
65 return fDPhi;
66}
67
[921]68inline
69void G4Tubs::Initialize()
70{
71 fCubicVolume = 0.;
72 fSurfaceArea = 0.;
73 fpPolyhedron = 0;
74}
75
76inline
77void G4Tubs::InitializeTrigonometry()
78{
79 G4double hDPhi = 0.5*fDPhi; // half delta phi
80 G4double cPhi = fSPhi + hDPhi;
81 G4double ePhi = fSPhi + fDPhi;
82
83 sinCPhi = std::sin(cPhi);
84 cosCPhi = std::cos(cPhi);
85 cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance); // inner/outer tol half dphi
86 cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance);
87 sinSPhi = std::sin(fSPhi);
88 cosSPhi = std::cos(fSPhi);
89 sinEPhi = std::sin(ePhi);
90 cosEPhi = std::cos(ePhi);
91}
92
[1228]93inline void G4Tubs::CheckSPhiAngle(G4double sPhi)
94{
95 // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0
96
97 if ( sPhi < 0 )
98 {
99 fSPhi = twopi - std::fmod(std::fabs(sPhi),twopi);
100 }
101 else
102 {
103 fSPhi = std::fmod(sPhi,twopi) ;
104 }
105 if ( fSPhi+fDPhi > twopi )
106 {
107 fSPhi -= twopi ;
108 }
109}
110
111inline void G4Tubs::CheckDPhiAngle(G4double dPhi)
112{
113 fPhiFullTube = true;
114 if ( dPhi >= twopi-kAngTolerance*0.5 )
115 {
116 fDPhi=twopi;
117 fSPhi=0;
118 }
119 else
120 {
121 fPhiFullTube = false;
122 if ( dPhi > 0 )
123 {
124 fDPhi = dPhi;
125 }
126 else
127 {
128 G4cerr << "ERROR - G4Tubs()::CheckDPhiAngle()" << G4endl
129 << " Negative or zero delta-Phi (" << dPhi << ") in solid: "
130 << GetName() << G4endl;
131 G4Exception("G4Tubs::CheckDPhiAngle()", "InvalidSetup",
132 FatalException, "Invalid dphi.");
133 }
134 }
135}
136
137inline void G4Tubs::CheckPhiAngles(G4double sPhi, G4double dPhi)
138{
139 CheckDPhiAngle(dPhi);
140 if ( (fDPhi<twopi) && (sPhi) ) { CheckSPhiAngle(sPhi); }
141 InitializeTrigonometry();
142}
143
[831]144inline
145void G4Tubs::SetInnerRadius (G4double newRMin)
146{
147 fRMin= newRMin;
[921]148 Initialize();
[831]149}
150
151inline
152void G4Tubs::SetOuterRadius (G4double newRMax)
153{
154 fRMax= newRMax;
[921]155 Initialize();
[831]156}
157
158inline
159void G4Tubs::SetZHalfLength (G4double newDz)
160{
161 fDz= newDz;
[921]162 Initialize();
[831]163}
164
165inline
[1228]166void G4Tubs::SetStartPhiAngle (G4double newSPhi, G4bool compute)
[831]167{
[1228]168 // Flag 'compute' can be used to explicitely avoid recomputation of
169 // trigonometry in case SetDeltaPhiAngle() is invoked afterwards
170
171 CheckSPhiAngle(newSPhi);
172 fPhiFullTube = false;
173 if (compute) { InitializeTrigonometry(); }
[921]174 Initialize();
[831]175}
176
177inline
178void G4Tubs::SetDeltaPhiAngle (G4double newDPhi)
179{
[1228]180 CheckPhiAngles(fSPhi, newDPhi);
[921]181 Initialize();
[831]182}
183
184// Older names for access functions
185
186inline
187G4double G4Tubs::GetRMin () const
188{
189 return GetInnerRadius();
190}
191
192inline
193G4double G4Tubs::GetRMax () const
194{
195 return GetOuterRadius();
196}
197
198inline
199G4double G4Tubs::GetDz () const
200{
201 return GetZHalfLength() ;
202}
203
204inline
205G4double G4Tubs::GetSPhi () const
206{
207 return GetStartPhiAngle();
208}
209
210inline
211G4double G4Tubs::GetDPhi () const
212{
213 return GetDeltaPhiAngle();
214}
215
216inline
217G4double G4Tubs::GetCubicVolume()
218{
219 if(fCubicVolume != 0.) {;}
220 else { fCubicVolume = fDPhi*fDz*(fRMax*fRMax-fRMin*fRMin); }
221 return fCubicVolume;
222}
223
224inline
225G4double G4Tubs::GetSurfaceArea()
226{
227 if(fSurfaceArea != 0.) {;}
228 else
229 {
230 fSurfaceArea = fDPhi*(fRMin+fRMax)*(2*fDz+fRMax-fRMin);
[921]231 if (!fPhiFullTube)
[831]232 {
233 fSurfaceArea = fSurfaceArea + 4*fDz*(fRMax-fRMin);
234 }
235 }
236 return fSurfaceArea;
237}
Note: See TracBrowser for help on using the repository browser.