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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 9.5)


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