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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/G4Cons.icc (Version 11.3.0) and /geometry/solids/CSG/include/G4Cons.icc (Version 10.3)


  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: G4Cons.icc 100820 2016-11-02 15:18:48Z gcosmo $
                                                   >>  28 //
                                                   >>  29 // --------------------------------------------------------------------
                                                   >>  30 // GEANT 4 inline definitions file
                                                   >>  31 //
                                                   >>  32 // G4Cons.icc
                                                   >>  33 //
 26 // Implementation of inline methods of G4Cons      34 // Implementation of inline methods of G4Cons
 27 // -------------------------------------------     35 // --------------------------------------------------------------------
 28                                                    36 
 29 inline                                             37 inline
 30 G4double G4Cons::GetInnerRadiusMinusZ() const      38 G4double G4Cons::GetInnerRadiusMinusZ() const
 31 {                                                  39 {
 32   return fRmin1 ;                                  40   return fRmin1 ;
 33 }                                                  41 }
 34                                                    42 
 35 inline                                             43 inline
 36 G4double G4Cons::GetOuterRadiusMinusZ() const      44 G4double G4Cons::GetOuterRadiusMinusZ() const
 37 {                                                  45 {
 38   return fRmax1 ;                                  46   return fRmax1 ;
 39 }                                                  47 }
 40                                                    48 
 41 inline                                             49 inline
 42 G4double G4Cons::GetInnerRadiusPlusZ() const       50 G4double G4Cons::GetInnerRadiusPlusZ() const
 43 {                                                  51 {
 44   return fRmin2 ;                                  52   return fRmin2 ;
 45 }                                                  53 }
 46                                                    54 
 47 inline                                             55 inline
 48 G4double G4Cons::GetOuterRadiusPlusZ() const       56 G4double G4Cons::GetOuterRadiusPlusZ() const
 49 {                                                  57 {
 50   return fRmax2 ;                                  58   return fRmax2 ;
 51 }                                                  59 }
 52                                                    60 
 53 inline                                             61 inline
 54 G4double G4Cons::GetZHalfLength() const            62 G4double G4Cons::GetZHalfLength() const
 55 {                                                  63 {
 56   return fDz ;                                     64   return fDz ;
 57 }                                                  65 }
 58                                                    66 
 59 inline                                         <<  67 inline  
 60 G4double G4Cons::GetStartPhiAngle() const          68 G4double G4Cons::GetStartPhiAngle() const
 61 {                                                  69 {
 62   return fSPhi ;                                   70   return fSPhi ;
 63 }                                                  71 }
 64                                                    72 
 65 inline                                             73 inline
 66 G4double G4Cons::GetDeltaPhiAngle() const          74 G4double G4Cons::GetDeltaPhiAngle() const
 67 {                                                  75 {
 68   return fDPhi;                                    76   return fDPhi;
 69 }                                                  77 }
 70                                                    78 
 71 inline                                             79 inline
 72 G4double G4Cons::GetSinStartPhi() const            80 G4double G4Cons::GetSinStartPhi() const
 73 {                                                  81 {
 74   return sinSPhi;                                  82   return sinSPhi;
 75 }                                                  83 }
 76                                                    84 
 77 inline                                             85 inline
 78 G4double G4Cons::GetCosStartPhi() const            86 G4double G4Cons::GetCosStartPhi() const
 79 {                                                  87 {
 80   return cosSPhi;                                  88   return cosSPhi;
 81 }                                                  89 }
 82                                                    90 
 83 inline                                             91 inline
 84 G4double G4Cons::GetSinEndPhi() const              92 G4double G4Cons::GetSinEndPhi() const
 85 {                                                  93 {
 86   return sinEPhi;                                  94   return sinEPhi;
 87 }                                                  95 }
 88                                                    96 
 89 inline                                             97 inline
 90 G4double G4Cons::GetCosEndPhi() const              98 G4double G4Cons::GetCosEndPhi() const
 91 {                                                  99 {
 92   return cosEPhi;                                 100   return cosEPhi;
 93 }                                                 101 }
 94                                                   102 
 95 inline                                            103 inline
 96 void G4Cons::Initialize()                         104 void G4Cons::Initialize()
 97 {                                                 105 {
 98   fCubicVolume = 0.;                              106   fCubicVolume = 0.;
 99   fSurfaceArea = 0.;                              107   fSurfaceArea = 0.;
100   fRebuildPolyhedron = true;                      108   fRebuildPolyhedron = true;
101 }                                                 109 }
102                                                   110 
103 inline                                         << 111 inline 
104 void G4Cons::InitializeTrigonometry()             112 void G4Cons::InitializeTrigonometry()
105 {                                                 113 {
106   G4double hDPhi = 0.5*fDPhi;                     114   G4double hDPhi = 0.5*fDPhi;                       // half delta phi
107   G4double cPhi  = fSPhi + hDPhi;              << 115   G4double cPhi  = fSPhi + hDPhi; 
108   G4double ePhi  = fSPhi + fDPhi;                 116   G4double ePhi  = fSPhi + fDPhi;
109                                                   117 
110   sinCPhi    = std::sin(cPhi);                    118   sinCPhi    = std::sin(cPhi);
111   cosCPhi    = std::cos(cPhi);                    119   cosCPhi    = std::cos(cPhi);
112   cosHDPhi   = std::cos(hDPhi);                << 
113   cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolera    120   cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance); // inner/outer tol half dphi
114   cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolera    121   cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance);
115   sinSPhi = std::sin(fSPhi);                      122   sinSPhi = std::sin(fSPhi);
116   cosSPhi = std::cos(fSPhi);                      123   cosSPhi = std::cos(fSPhi);
117   sinEPhi = std::sin(ePhi);                       124   sinEPhi = std::sin(ePhi);
118   cosEPhi = std::cos(ePhi);                       125   cosEPhi = std::cos(ePhi);
119 }                                                 126 }
120                                                   127 
121 inline void G4Cons::CheckSPhiAngle(G4double sP    128 inline void G4Cons::CheckSPhiAngle(G4double sPhi)
122 {                                                 129 {
123   // Ensure fSphi in 0-2PI or -2PI-0 range if     130   // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0
124                                                   131 
125   if ( sPhi < 0 )                                 132   if ( sPhi < 0 )
126   {                                               133   {
127     fSPhi = CLHEP::twopi - std::fmod(std::fabs    134     fSPhi = CLHEP::twopi - std::fmod(std::fabs(sPhi),CLHEP::twopi);
128   }                                               135   }
129   else                                            136   else
130   {                                               137   {
131     fSPhi = std::fmod(sPhi,CLHEP::twopi) ;        138     fSPhi = std::fmod(sPhi,CLHEP::twopi) ;
132   }                                               139   }
133   if ( fSPhi+fDPhi > CLHEP::twopi )               140   if ( fSPhi+fDPhi > CLHEP::twopi )
134   {                                               141   {
135     fSPhi -= CLHEP::twopi ;                       142     fSPhi -= CLHEP::twopi ;
136   }                                               143   }
137 }                                                 144 }
138                                                   145 
139 inline void G4Cons::CheckDPhiAngle(G4double dP    146 inline void G4Cons::CheckDPhiAngle(G4double dPhi)
140 {                                                 147 {
141   fPhiFullCone = true;                            148   fPhiFullCone = true;
142   if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5     149   if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5 )
143   {                                               150   {
144     fDPhi=CLHEP::twopi;                           151     fDPhi=CLHEP::twopi;
145     fSPhi=0;                                      152     fSPhi=0;
146   }                                               153   }
147   else                                            154   else
148   {                                               155   {
149     fPhiFullCone = false;                         156     fPhiFullCone = false;
150     if ( dPhi > 0 )                               157     if ( dPhi > 0 )
151     {                                             158     {
152       fDPhi = dPhi;                               159       fDPhi = dPhi;
153     }                                             160     }
154     else                                          161     else
155     {                                             162     {
156       std::ostringstream message;                 163       std::ostringstream message;
157       message << "Invalid dphi." << G4endl        164       message << "Invalid dphi." << G4endl
158               << "Negative or zero delta-Phi (    165               << "Negative or zero delta-Phi (" << dPhi << ") in solid: "
159               << GetName();                       166               << GetName();
160       G4Exception("G4Cons::CheckDPhiAngle()",     167       G4Exception("G4Cons::CheckDPhiAngle()", "GeomSolids0002",
161                   FatalException, message);       168                   FatalException, message);
162     }                                             169     }
163   }                                               170   }
164 }                                                 171 }
165                                                   172 
166 inline void G4Cons::CheckPhiAngles(G4double sP    173 inline void G4Cons::CheckPhiAngles(G4double sPhi, G4double dPhi)
167 {                                                 174 {
168   CheckDPhiAngle(dPhi);                           175   CheckDPhiAngle(dPhi);
169   if ( (fDPhi<CLHEP::twopi) && ((sPhi) != 0.0) << 176   if ( (fDPhi<CLHEP::twopi) && (sPhi) ) { CheckSPhiAngle(sPhi); }
170   InitializeTrigonometry();                       177   InitializeTrigonometry();
171 }                                                 178 }
172                                                   179 
173 inline                                            180 inline
174 void G4Cons::SetInnerRadiusMinusZ( G4double Rm    181 void G4Cons::SetInnerRadiusMinusZ( G4double Rmin1 )
175 {                                                 182 {
176   fRmin1= Rmin1 ;                                 183   fRmin1= Rmin1 ;
177   Initialize();                                   184   Initialize();
178 }                                                 185 }
179                                                   186 
180 inline                                            187 inline
181 void G4Cons::SetOuterRadiusMinusZ( G4double Rm    188 void G4Cons::SetOuterRadiusMinusZ( G4double Rmax1 )
182 {                                                 189 {
183   fRmax1= Rmax1 ;                                 190   fRmax1= Rmax1 ;
184   Initialize();                                   191   Initialize();
185 }                                                 192 }
186                                                   193 
187 inline                                            194 inline
188 void G4Cons::SetInnerRadiusPlusZ ( G4double Rm    195 void G4Cons::SetInnerRadiusPlusZ ( G4double Rmin2 )
189 {                                                 196 {
190   fRmin2= Rmin2 ;                                 197   fRmin2= Rmin2 ;
191   Initialize();                                   198   Initialize();
192 }                                                 199 }
193                                                   200 
194 inline                                            201 inline
195 void G4Cons::SetOuterRadiusPlusZ ( G4double Rm    202 void G4Cons::SetOuterRadiusPlusZ ( G4double Rmax2 )
196 {                                                 203 {
197   fRmax2= Rmax2 ;                                 204   fRmax2= Rmax2 ;
198   Initialize();                                   205   Initialize();
199 }                                                 206 }
200                                                   207 
201 inline                                            208 inline
202 void G4Cons::SetZHalfLength ( G4double newDz )    209 void G4Cons::SetZHalfLength ( G4double newDz )
203 {                                                 210 {
204   fDz= newDz ;                                    211   fDz= newDz ;
205   Initialize();                                   212   Initialize();
206 }                                                 213 }
207                                                   214 
208 inline                                            215 inline
209 void G4Cons::SetStartPhiAngle ( G4double newSP    216 void G4Cons::SetStartPhiAngle ( G4double newSPhi, G4bool compute )
210 {                                                 217 {
211   // Flag 'compute' can be used to explicitely    218   // Flag 'compute' can be used to explicitely avoid recomputation of
212   // trigonometry in case SetDeltaPhiAngle() i    219   // trigonometry in case SetDeltaPhiAngle() is invoked afterwards
213                                                   220 
214   CheckSPhiAngle(newSPhi);                        221   CheckSPhiAngle(newSPhi);
215   fPhiFullCone = false;                           222   fPhiFullCone = false;
216   if (compute)  { InitializeTrigonometry(); }     223   if (compute)  { InitializeTrigonometry(); }
217   Initialize();                                   224   Initialize();
218 }                                                 225 }
219                                                   226 
220 void G4Cons::SetDeltaPhiAngle ( G4double newDP    227 void G4Cons::SetDeltaPhiAngle ( G4double newDPhi )
221 {                                                 228 {
222   CheckPhiAngles(fSPhi, newDPhi);                 229   CheckPhiAngles(fSPhi, newDPhi);
223   Initialize();                                   230   Initialize();
224 }                                                 231 }
225                                                   232 
                                                   >> 233 // Old access methods ...
                                                   >> 234 
                                                   >> 235 inline
                                                   >> 236 G4double G4Cons::GetRmin1() const
                                                   >> 237 {
                                                   >> 238   return GetInnerRadiusMinusZ();
                                                   >> 239 }
                                                   >> 240 
                                                   >> 241 inline
                                                   >> 242 G4double G4Cons::GetRmax1() const
                                                   >> 243 {
                                                   >> 244   return GetOuterRadiusMinusZ();
                                                   >> 245 }
                                                   >> 246 
                                                   >> 247 inline
                                                   >> 248 G4double G4Cons::GetRmin2() const
                                                   >> 249 {
                                                   >> 250   return GetInnerRadiusPlusZ();
                                                   >> 251 }
                                                   >> 252 
                                                   >> 253 inline
                                                   >> 254 G4double G4Cons::GetRmax2() const
                                                   >> 255 {
                                                   >> 256   return GetOuterRadiusPlusZ();
                                                   >> 257 }
                                                   >> 258 
                                                   >> 259 inline  
                                                   >> 260 G4double G4Cons::GetDz() const
                                                   >> 261 {
                                                   >> 262   return GetZHalfLength();
                                                   >> 263 }
                                                   >> 264 
                                                   >> 265 inline
                                                   >> 266 G4double G4Cons::GetSPhi() const
                                                   >> 267 {
                                                   >> 268   return GetStartPhiAngle();
                                                   >> 269 }
                                                   >> 270 
                                                   >> 271 inline
                                                   >> 272 G4double G4Cons::GetDPhi() const
                                                   >> 273 {
                                                   >> 274   return GetDeltaPhiAngle();
                                                   >> 275 }
                                                   >> 276 
226 inline                                            277 inline
227 G4double G4Cons::GetCubicVolume()                 278 G4double G4Cons::GetCubicVolume()
228 {                                                 279 {
229   if(fCubicVolume != 0.) {;}                      280   if(fCubicVolume != 0.) {;}
230   else                                         << 281   else   
231   {                                               282   {
232     G4double Rmean, rMean, deltaR, deltar;        283     G4double Rmean, rMean, deltaR, deltar;
233                                                   284 
234     Rmean  = 0.5*(fRmax1+fRmax2);                 285     Rmean  = 0.5*(fRmax1+fRmax2);
235     deltaR = fRmax1-fRmax2;                       286     deltaR = fRmax1-fRmax2;
236                                                   287 
237     rMean  = 0.5*(fRmin1+fRmin2);                 288     rMean  = 0.5*(fRmin1+fRmin2);
238     deltar = fRmin1-fRmin2;                       289     deltar = fRmin1-fRmin2;
239     fCubicVolume = fDPhi*fDz*(Rmean*Rmean-rMea    290     fCubicVolume = fDPhi*fDz*(Rmean*Rmean-rMean*rMean
240                             +(deltaR*deltaR-de << 291                             +(deltaR*deltaR-deltar*deltar)/12); 
241   }                                               292   }
242   return fCubicVolume;                            293   return fCubicVolume;
243 }                                                 294 }
244                                                   295 
245 inline                                            296 inline
246 G4double G4Cons::GetSurfaceArea()                 297 G4double G4Cons::GetSurfaceArea()
247 {                                                 298 {
248   if(fSurfaceArea != 0.) {;}                      299   if(fSurfaceArea != 0.) {;}
249   else                                         << 300   else   
250   {                                               301   {
251     G4double mmin, mmax, dmin, dmax;              302     G4double mmin, mmax, dmin, dmax;
252                                                   303 
253     mmin= (fRmin1+fRmin2)*0.5;                    304     mmin= (fRmin1+fRmin2)*0.5;
254     mmax= (fRmax1+fRmax2)*0.5;                    305     mmax= (fRmax1+fRmax2)*0.5;
255     dmin= (fRmin2-fRmin1);                        306     dmin= (fRmin2-fRmin1);
256     dmax= (fRmax2-fRmax1);                        307     dmax= (fRmax2-fRmax1);
257                                                << 308     
258     fSurfaceArea = fDPhi*( mmin * std::sqrt(dm    309     fSurfaceArea = fDPhi*( mmin * std::sqrt(dmin*dmin+4*fDz*fDz)
259                          + mmax * std::sqrt(dm    310                          + mmax * std::sqrt(dmax*dmax+4*fDz*fDz)
260                          + 0.5*(fRmax1*fRmax1-    311                          + 0.5*(fRmax1*fRmax1-fRmin1*fRmin1
261                                +fRmax2*fRmax2-    312                                +fRmax2*fRmax2-fRmin2*fRmin2 ));
262     if(!fPhiFullCone)                             313     if(!fPhiFullCone)
263     {                                             314     {
264       fSurfaceArea = fSurfaceArea+4*fDz*(mmax-    315       fSurfaceArea = fSurfaceArea+4*fDz*(mmax-mmin);
265     }                                             316     }
266   }                                               317   }
267   return fSurfaceArea;                            318   return fSurfaceArea;
268 }                                                 319 }
269                                                   320