source: trunk/source/geometry/solids/CSG/include/G4Cons.icc @ 1119

Last change on this file since 1119 was 1058, checked in by garnier, 15 years ago

file release beta

File size: 5.7 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: G4Cons.icc,v 1.8 2008/11/06 10:55:40 gcosmo Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
29//
30// --------------------------------------------------------------------
31// GEANT 4 inline definitions file
32//
33// G4Cons.icc
34//
35// Implementation of inline methods of G4Cons
36// --------------------------------------------------------------------
37
38inline
39void G4Cons::Initialise()
40{
41  fCubicVolume= 0.;
42  fSurfaceArea= 0.;
43  fpPolyhedron = 0;
44}
45
46inline
47void G4Cons::InitializeTrigonometry()
48{
49  G4double hDPhi = 0.5*fDPhi;                       // half delta phi
50  G4double cPhi  = fSPhi + hDPhi;
51  G4double ePhi  = fSPhi + fDPhi;
52
53  sinCPhi    = std::sin(cPhi);
54  cosCPhi    = std::cos(cPhi);
55  cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance); // inner/outer tol half dphi
56  cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance);
57  sinSPhi = std::sin(fSPhi);
58  cosSPhi = std::cos(fSPhi);
59  sinEPhi = std::sin(ePhi);
60  cosEPhi = std::cos(ePhi);
61}
62
63inline
64G4double G4Cons::GetInnerRadiusMinusZ() const
65{
66  return fRmin1 ;
67}
68
69inline
70G4double G4Cons::GetOuterRadiusMinusZ() const
71{
72  return fRmax1 ;
73}
74
75inline
76G4double G4Cons::GetInnerRadiusPlusZ() const
77{
78  return fRmin2 ;
79}
80
81inline
82G4double G4Cons::GetOuterRadiusPlusZ() const
83{
84  return fRmax2 ;
85}
86
87inline
88G4double G4Cons::GetZHalfLength() const
89{
90  return fDz ;
91}
92
93inline 
94G4double G4Cons::GetStartPhiAngle() const
95{
96  return fSPhi ;
97}
98
99inline
100G4double G4Cons::GetDeltaPhiAngle() const
101{
102  return fDPhi;
103}
104
105inline
106void G4Cons::SetInnerRadiusMinusZ( G4double Rmin1 )
107{
108  fRmin1= Rmin1 ;
109  Initialise();
110}
111
112inline
113void G4Cons::SetOuterRadiusMinusZ( G4double Rmax1 )
114{
115  fRmax1= Rmax1 ;
116  Initialise();
117}
118
119inline
120void G4Cons::SetInnerRadiusPlusZ ( G4double Rmin2 )
121{
122  fRmin2= Rmin2 ;
123  Initialise();
124}
125
126inline
127void G4Cons::SetOuterRadiusPlusZ ( G4double Rmax2 )
128{
129  fRmax2= Rmax2 ;
130  Initialise();
131}
132
133inline
134void G4Cons::SetZHalfLength ( G4double newDz )
135{
136  fDz= newDz ;
137  Initialise();
138}
139
140inline
141void G4Cons::SetStartPhiAngle ( G4double newSPhi )
142{
143  fSPhi= newSPhi;
144  Initialise();
145  InitializeTrigonometry();
146}
147
148void G4Cons::SetDeltaPhiAngle ( G4double newDPhi )
149{
150  if ( newDPhi >= twopi-kAngTolerance*0.5 )
151  {
152    fPhiFullCone = true;
153  }
154  else if ( newDPhi > 0 )
155  {
156    fPhiFullCone = false;
157  }
158  else
159  {
160     G4cerr << "ERROR - G4Cons()::SetDeltaPhiAngle() : " << GetName() << G4endl
161            << "        Negative delta-Phi ! - " << newDPhi << G4endl;
162     G4Exception("G4Cons::SetDeltaPhiAngle()", "InvalidSetup",
163                  FatalException, "Invalid dphi.");
164  }
165  fDPhi=  newDPhi;
166  Initialise();
167  InitializeTrigonometry();
168}
169
170// Old access methods ...
171
172inline
173G4double G4Cons::GetRmin1() const
174{
175  return GetInnerRadiusMinusZ();
176}
177
178inline
179G4double G4Cons::GetRmax1() const
180{
181  return GetOuterRadiusMinusZ();
182}
183
184inline
185G4double G4Cons::GetRmin2() const
186{
187  return GetInnerRadiusPlusZ();
188}
189
190inline
191G4double G4Cons::GetRmax2() const
192{
193  return GetOuterRadiusPlusZ();
194}
195
196inline 
197G4double G4Cons::GetDz() const
198{
199  return GetZHalfLength();
200}
201
202inline
203G4double G4Cons::GetSPhi() const
204{
205  return GetStartPhiAngle();
206}
207
208inline
209G4double G4Cons::GetDPhi() const
210{
211  return GetDeltaPhiAngle();
212}
213
214inline
215G4double G4Cons::GetCubicVolume()
216{
217  if(fCubicVolume != 0.) {;}
218  else   
219  {
220    G4double Rmean, rMean, deltaR, deltar;
221
222    Rmean  = 0.5*(fRmax1+fRmax2);
223    deltaR = fRmax1-fRmax2;
224
225    rMean  = 0.5*(fRmin1+fRmin2);
226    deltar = fRmin1-fRmin2;
227    fCubicVolume = fDPhi*fDz*(Rmean*Rmean-rMean*rMean
228                            +(deltaR*deltaR-deltar*deltar)/12);
229  }
230  return fCubicVolume;
231}
232
233inline
234G4double G4Cons::GetSurfaceArea()
235{
236  if(fSurfaceArea != 0.) {;}
237  else   
238  {
239    G4double mmin, mmax, dmin, dmax;
240
241    mmin= (fRmin1+fRmin2)*0.5;
242    mmax= (fRmax1+fRmax2)*0.5;
243    dmin= (fRmin2-fRmin1);
244    dmax= (fRmax2-fRmax1);
245   
246    fSurfaceArea = fDPhi*( mmin * std::sqrt(dmin*dmin+4*fDz*fDz)
247                         + mmax * std::sqrt(dmax*dmax+4*fDz*fDz)
248                         + 0.5*(fRmax1*fRmax1-fRmin1*fRmin1
249                               +fRmax2*fRmax2-fRmin2*fRmin2 ));
250    if(!fPhiFullCone)
251    {
252      fSurfaceArea = fSurfaceArea+4*fDz*(mmax-mmin);
253    }
254  }
255  return fSurfaceArea;
256}
Note: See TracBrowser for help on using the repository browser.