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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/solids/CSG/include/G4Sphere.icc (Version 11.3.0) and /geometry/solids/CSG/include/G4Sphere.icc (Version 8.2.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 //
                                                   >>  27 // $Id: G4Sphere.icc,v 1.7 2006/10/19 15:33:37 gcosmo Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-08-02-patch-01-ref $
                                                   >>  29 //
                                                   >>  30 // --------------------------------------------------------------------
                                                   >>  31 // GEANT 4 inline definitions file
                                                   >>  32 //
                                                   >>  33 // G4Sphere.icc
                                                   >>  34 //
 26 // Implementation of inline methods of G4Spher     35 // Implementation of inline methods of G4Sphere
 27 // -------------------------------------------     36 // --------------------------------------------------------------------
 28                                                    37 
 29 inline                                             38 inline
 30 G4double G4Sphere::GetInnerRadius() const      <<  39 G4double G4Sphere::GetInsideRadius() const
 31 {                                                  40 {
 32   return fRmin;                                    41   return fRmin;
 33 }                                                  42 }
 34                                                    43 
 35 inline                                             44 inline
 36 G4double G4Sphere::GetOuterRadius() const          45 G4double G4Sphere::GetOuterRadius() const
 37 {                                                  46 {
 38   return fRmax;                                    47   return fRmax;
 39 }                                                  48 }
 40                                                    49 
 41 inline                                             50 inline
 42 G4double G4Sphere::GetStartPhiAngle() const        51 G4double G4Sphere::GetStartPhiAngle() const
 43 {                                                  52 {
 44   return fSPhi;                                    53   return fSPhi;
 45 }                                                  54 }
 46                                                    55 
 47 inline                                             56 inline
 48 G4double G4Sphere::GetDeltaPhiAngle() const        57 G4double G4Sphere::GetDeltaPhiAngle() const
 49 {                                                  58 {
 50   return fDPhi;                                    59   return fDPhi;
 51 }                                                  60 }
 52                                                    61 
 53 inline                                             62 inline
 54 G4double G4Sphere::GetStartThetaAngle() const      63 G4double G4Sphere::GetStartThetaAngle() const
 55 {                                                  64 {
 56   return fSTheta;                                  65   return fSTheta;
 57 }                                                  66 }
 58                                                    67 
 59 G4double G4Sphere::GetDeltaThetaAngle() const      68 G4double G4Sphere::GetDeltaThetaAngle() const
 60 {                                                  69 {
 61   return fDTheta;                                  70   return fDTheta;
 62 }                                                  71 }
 63                                                    72 
 64 inline                                             73 inline
 65 G4double G4Sphere::GetSinStartPhi () const     <<  74 void G4Sphere::SetInsideRadius(G4double newRmin)
 66 {                                                  75 {
 67   return sinSPhi;                              <<  76   fRmin= newRmin;
                                                   >>  77   fCubicVolume= 0.;
                                                   >>  78   fSurfaceArea= 0.;
                                                   >>  79   fpPolyhedron = 0;
 68 }                                                  80 }
 69                                                    81 
 70 inline                                             82 inline
 71 G4double G4Sphere::GetCosStartPhi () const     <<  83 void G4Sphere::SetOuterRadius(G4double newRmax)
 72 {                                                  84 {
 73   return cosSPhi;                              <<  85   fRmax= newRmax;
                                                   >>  86   fCubicVolume= 0.;
                                                   >>  87   fSurfaceArea= 0.;
                                                   >>  88   fpPolyhedron = 0;
 74 }                                                  89 }
 75                                                    90 
 76 inline                                             91 inline
 77 G4double G4Sphere::GetSinEndPhi () const       <<  92 void G4Sphere::SetStartPhiAngle(G4double newSphi)
 78 {                                                  93 {
 79   return sinEPhi;                              <<  94   fSPhi= newSphi;
                                                   >>  95   fCubicVolume= 0.;
                                                   >>  96   fSurfaceArea= 0.;
                                                   >>  97   fpPolyhedron = 0;
 80 }                                                  98 }
 81                                                    99 
 82 inline                                            100 inline
 83 G4double G4Sphere::GetCosEndPhi () const       << 101 void G4Sphere::SetDeltaPhiAngle(G4double newDphi)
 84 {                                                 102 {
 85   return cosEPhi;                              << 103   fDPhi= newDphi;
                                                   >> 104   fCubicVolume= 0.;
                                                   >> 105   fSurfaceArea= 0.;
                                                   >> 106   fpPolyhedron = 0;
 86 }                                                 107 }
 87                                                   108 
 88 inline                                            109 inline
 89 G4double G4Sphere::GetSinStartTheta () const   << 110 void G4Sphere::SetStartThetaAngle(G4double newSTheta)
 90 {                                                 111 {
 91   return sinSTheta;                            << 112   fSTheta=newSTheta;
                                                   >> 113   fCubicVolume= 0.;
                                                   >> 114   fSurfaceArea= 0.;
                                                   >> 115   fpPolyhedron = 0;
 92 }                                                 116 }
 93                                                   117 
 94 inline                                            118 inline
 95 G4double G4Sphere::GetCosStartTheta () const   << 119 void G4Sphere::SetDeltaThetaAngle(G4double newDTheta)
 96 {                                                 120 {
 97   return cosSTheta;                            << 121   fDTheta=newDTheta;
                                                   >> 122   fCubicVolume= 0.;
                                                   >> 123   fSurfaceArea= 0.;
                                                   >> 124   fpPolyhedron = 0;
 98 }                                                 125 }
 99                                                   126 
                                                   >> 127 // Old access functions
                                                   >> 128 
100 inline                                            129 inline
101 G4double G4Sphere::GetSinEndTheta () const     << 130 G4double G4Sphere::GetRmin() const 
102 {                                                 131 {
103   return sinETheta;                            << 132   return GetInsideRadius();
104 }                                                 133 }
105                                                   134 
106 inline                                            135 inline
107 G4double G4Sphere::GetCosEndTheta () const     << 136 G4double G4Sphere::GetRmax() const
108 {                                                 137 {
109   return cosETheta;                            << 138   return GetOuterRadius();
110 }                                                 139 }
111                                                   140 
112 inline                                            141 inline
113 void G4Sphere::Initialize()                    << 142 G4double G4Sphere::GetSPhi() const
114 {                                                 143 {
115   fCubicVolume = 0.;                           << 144   return GetStartPhiAngle();
116   fSurfaceArea = 0.;                           << 
117   fRebuildPolyhedron = true;                   << 
118 }                                                 145 }
119                                                   146 
120 inline                                            147 inline
121 void G4Sphere::InitializePhiTrigonometry()     << 148 G4double G4Sphere::GetDPhi() const
122 {                                                 149 {
123   hDPhi = 0.5*fDPhi;                       //  << 150   return GetDeltaPhiAngle();
124   cPhi  = fSPhi + hDPhi;                       << 
125   ePhi  = fSPhi + fDPhi;                       << 
126                                                << 
127   sinCPhi    = std::sin(cPhi);                 << 
128   cosCPhi    = std::cos(cPhi);                 << 
129   cosHDPhi   = std::cos(hDPhi);                << 
130   cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolera << 
131   cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolera << 
132   sinSPhi = std::sin(fSPhi);                   << 
133   cosSPhi = std::cos(fSPhi);                   << 
134   sinEPhi = std::sin(ePhi);                    << 
135   cosEPhi = std::cos(ePhi);                    << 
136 }                                                 151 }
137                                                   152 
138 inline                                            153 inline
139 void G4Sphere::InitializeThetaTrigonometry()   << 154 G4double G4Sphere::GetSTheta() const
140 {                                                 155 {
141   eTheta  = fSTheta + fDTheta;                 << 156   return GetStartThetaAngle();
142                                                << 
143   sinSTheta = std::sin(fSTheta);               << 
144   cosSTheta = std::cos(fSTheta);               << 
145   sinETheta = std::sin(eTheta);                << 
146   cosETheta = std::cos(eTheta);                << 
147                                                << 
148   tanSTheta  = sinSTheta/cosSTheta;            << 
149   tanSTheta2 = tanSTheta*tanSTheta;            << 
150   tanETheta  = sinETheta/cosETheta;            << 
151   tanETheta2 = tanETheta*tanETheta;            << 
152 }                                                 157 }
153                                                   158 
154 inline                                            159 inline
155 void G4Sphere::CheckThetaAngles(G4double sThet << 160 G4double G4Sphere::GetDTheta() const
156 {                                                 161 {
157   if ( (sTheta<0) || (sTheta>CLHEP::pi) )      << 162   return GetDeltaThetaAngle();
158   {                                            << 
159     std::ostringstream message;                << 
160     message << "sTheta outside 0-PI range." << << 
161             << "Invalid starting Theta angle f << 
162     G4Exception("G4Sphere::CheckThetaAngles()" << 
163                 FatalException, message);      << 
164   }                                            << 
165   else                                         << 
166   {                                            << 
167     fSTheta=sTheta;                            << 
168   }                                            << 
169   if ( dTheta+sTheta >= CLHEP::pi )            << 
170   {                                            << 
171     fDTheta=CLHEP::pi-sTheta;                  << 
172   }                                            << 
173   else if ( dTheta > 0 )                       << 
174   {                                            << 
175     fDTheta=dTheta;                            << 
176   }                                            << 
177   else                                         << 
178   {                                            << 
179     std::ostringstream message;                << 
180     message << "Invalid dTheta." << G4endl     << 
181             << "Negative delta-Theta (" << dTh << 
182             << GetName();                      << 
183     G4Exception("G4Sphere::CheckThetaAngles()" << 
184                 FatalException, message);      << 
185   }                                            << 
186   fFullThetaSphere = fDTheta-fSTheta >= CLHEP: << 
187   fFullSphere = fFullPhiSphere && fFullThetaSp << 
188                                                << 
189   InitializeThetaTrigonometry();               << 
190 }                                                 163 }
191                                                   164 
192 inline                                            165 inline
193 void G4Sphere::CheckSPhiAngle(G4double sPhi)   << 166 G4double G4Sphere::GetCubicVolume()
194 {                                                 167 {
195   // Ensure fSphi in 0-2PI or -2PI-0 range if  << 168   if(fCubicVolume != 0.) {;}
196                                                << 169   else   fCubicVolume = fDPhi*(std::cos(fSTheta)-std::cos(fSTheta+fDTheta))*
197   if ( sPhi < 0 )                              << 170                               (fRmax*fRmax*fRmax-fRmin*fRmin*fRmin)/3.; 
198   {                                            << 171   return fCubicVolume;
199     fSPhi = CLHEP::twopi - std::fmod(std::fabs << 
200   }                                            << 
201   else                                         << 
202   {                                            << 
203     fSPhi = std::fmod(sPhi,CLHEP::twopi) ;     << 
204   }                                            << 
205   if ( fSPhi+fDPhi > CLHEP::twopi )            << 
206   {                                            << 
207     fSPhi -= CLHEP::twopi ;                    << 
208   }                                            << 
209 }                                                 172 }
210                                                   173 
                                                   >> 174 
211 inline                                            175 inline
212 void G4Sphere::CheckDPhiAngle(G4double dPhi)   << 176 G4double G4Sphere::GetSurfaceArea()
213 {                                                 177 {
214   fFullPhiSphere = true;                       << 178   if(fSurfaceArea != 0.) {;}
215   if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5  << 
216   {                                            << 
217     fDPhi=CLHEP::twopi;                        << 
218   }                                            << 
219   else                                            179   else
220   {                                            << 180   {   
221     fFullPhiSphere = false;                    << 181     G4double Rsq=fRmax*fRmax;
222     if ( dPhi > 0 )                            << 182     G4double rsq=fRmin*fRmin;
                                                   >> 183          
                                                   >> 184     fSurfaceArea = fDPhi*(rsq+Rsq)*(std::cos(fSTheta)
                                                   >> 185                  - std::cos(fSTheta+fDTheta));
                                                   >> 186     if(fDPhi < twopi)
                                                   >> 187     {
                                                   >> 188       fSurfaceArea = fSurfaceArea + fDTheta*(Rsq-rsq);
                                                   >> 189     }
                                                   >> 190     if(fSTheta >0)
223     {                                             191     {
224       fDPhi = dPhi;                            << 192       G4double acos1=std::acos( std::pow(std::sin(fSTheta),2)
                                                   >> 193                                *std::cos(fDPhi)
                                                   >> 194                                +std::pow(std::cos(fSTheta),2));
                                                   >> 195       if(fDPhi>pi)
                                                   >> 196       { 
                                                   >> 197         fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*(twopi-acos1);
                                                   >> 198       }
                                                   >> 199       else
                                                   >> 200       {
                                                   >> 201         fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*acos1;
                                                   >> 202       }
225     }                                             203     }
226     else                                       << 204     if(fDTheta+fSTheta < pi)
227     {                                             205     {
228       std::ostringstream message;              << 206       G4double acos2=std::acos( std::pow(std::sin(fSTheta+fDTheta),2)
229       message << "Invalid dphi." << G4endl     << 207                                *std::cos(fDPhi)
230               << "Negative delta-Phi (" << dPh << 208                                +std::pow(std::cos(fSTheta+fDTheta),2));
231               << GetName();                    << 209       if(fDPhi>pi)
232       G4Exception("G4Sphere::CheckDPhiAngle()" << 210       { 
233                   FatalException, message);    << 211         fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*(twopi-acos2);
                                                   >> 212       }
                                                   >> 213       else
                                                   >> 214       {
                                                   >> 215         fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*acos2;
                                                   >> 216       }
234     }                                             217     }
235   }                                               218   }
236 }                                              << 219   return fSurfaceArea;
237                                                << 
238 inline                                         << 
239 void G4Sphere::CheckPhiAngles(G4double sPhi, G << 
240 {                                              << 
241   CheckDPhiAngle(dPhi);                        << 
242   if (!fFullPhiSphere && (sPhi != 0.0)) { Chec << 
243   fFullSphere = fFullPhiSphere && fFullThetaSp << 
244                                                << 
245   InitializePhiTrigonometry();                 << 
246 }                                              << 
247                                                << 
248 inline                                         << 
249 void G4Sphere::SetInnerRadius(G4double newRmin << 
250 {                                              << 
251   fRmin= newRmin;                              << 
252   fRminTolerance = (fRmin) != 0.0 ? std::max(  << 
253   Initialize();                                << 
254 }                                              << 
255                                                << 
256 inline                                         << 
257 void G4Sphere::SetOuterRadius(G4double newRmax << 
258 {                                              << 
259   fRmax= newRmax;                              << 
260   fRmaxTolerance = std::max( kRadTolerance, fE << 
261   Initialize();                                << 
262 }                                              << 
263                                                << 
264 inline                                         << 
265 void G4Sphere::SetStartPhiAngle(G4double newSP << 
266 {                                              << 
267   // Flag 'compute' can be used to explicitely << 
268   // trigonometry in case SetDeltaPhiAngle() i << 
269                                                << 
270   CheckSPhiAngle(newSPhi);                     << 
271   fFullPhiSphere = false;                      << 
272   if (compute)  { InitializePhiTrigonometry(); << 
273   Initialize();                                << 
274 }                                              << 
275                                                << 
276 inline                                         << 
277 void G4Sphere::SetDeltaPhiAngle(G4double newDP << 
278 {                                              << 
279   CheckPhiAngles(fSPhi, newDPhi);              << 
280   Initialize();                                << 
281 }                                              << 
282                                                << 
283 inline                                         << 
284 void G4Sphere::SetStartThetaAngle(G4double new << 
285 {                                              << 
286   CheckThetaAngles(newSTheta, fDTheta);        << 
287   Initialize();                                << 
288 }                                              << 
289                                                << 
290 inline                                         << 
291 void G4Sphere::SetDeltaThetaAngle(G4double new << 
292 {                                              << 
293   CheckThetaAngles(fSTheta, newDTheta);        << 
294   Initialize();                                << 
295 }                                                 220 }
296                                                   221