2// ********************************************************************
 
    3// * License and Disclaimer                                           *
 
    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.                             *
 
   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.         *
 
   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// ********************************************************************
 
   26// Implementation of inline methods of G4Cons
 
   27// --------------------------------------------------------------------
 
   30G4double G4Cons::GetInnerRadiusMinusZ() const
 
   36G4double G4Cons::GetOuterRadiusMinusZ() const
 
   42G4double G4Cons::GetInnerRadiusPlusZ() const
 
   48G4double G4Cons::GetOuterRadiusPlusZ() const
 
   54G4double G4Cons::GetZHalfLength() const
 
   60G4double G4Cons::GetStartPhiAngle() const
 
   66G4double G4Cons::GetDeltaPhiAngle() const
 
   72G4double G4Cons::GetSinStartPhi() const
 
   78G4double G4Cons::GetCosStartPhi() const
 
   84G4double G4Cons::GetSinEndPhi() const
 
   90G4double G4Cons::GetCosEndPhi() const
 
   96void G4Cons::Initialize()
 
  100  fRebuildPolyhedron = true;
 
  104void G4Cons::InitializeTrigonometry()
 
  106  G4double hDPhi = 0.5*fDPhi;                       // half delta phi
 
  107  G4double cPhi  = fSPhi + hDPhi;
 
  108  G4double ePhi  = fSPhi + fDPhi;
 
  110  sinCPhi    = std::sin(cPhi);
 
  111  cosCPhi    = std::cos(cPhi);
 
  112  cosHDPhi   = std::cos(hDPhi);
 
  113  cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance); // inner/outer tol half dphi
 
  114  cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance);
 
  115  sinSPhi = std::sin(fSPhi);
 
  116  cosSPhi = std::cos(fSPhi);
 
  117  sinEPhi = std::sin(ePhi);
 
  118  cosEPhi = std::cos(ePhi);
 
  121inline void G4Cons::CheckSPhiAngle(G4double sPhi)
 
  123  // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0
 
  127    fSPhi = CLHEP::twopi - std::fmod(std::fabs(sPhi),CLHEP::twopi);
 
  131    fSPhi = std::fmod(sPhi,CLHEP::twopi) ;
 
  133  if ( fSPhi+fDPhi > CLHEP::twopi )
 
  135    fSPhi -= CLHEP::twopi ;
 
  139inline void G4Cons::CheckDPhiAngle(G4double dPhi)
 
  142  if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5 )
 
  149    fPhiFullCone = false;
 
  156      std::ostringstream message;
 
  157      message << "Invalid dphi." << G4endl
 
  158              << "Negative or zero delta-Phi (" << dPhi << ") in solid: "
 
  160      G4Exception("G4Cons::CheckDPhiAngle()", "GeomSolids0002",
 
  161                  FatalException, message);
 
  166inline void G4Cons::CheckPhiAngles(G4double sPhi, G4double dPhi)
 
  168  CheckDPhiAngle(dPhi);
 
  169  if ( (fDPhi<CLHEP::twopi) && (sPhi) ) { CheckSPhiAngle(sPhi); }
 
  170  InitializeTrigonometry();
 
  174void G4Cons::SetInnerRadiusMinusZ( G4double Rmin1 )
 
  181void G4Cons::SetOuterRadiusMinusZ( G4double Rmax1 )
 
  188void G4Cons::SetInnerRadiusPlusZ ( G4double Rmin2 )
 
  195void G4Cons::SetOuterRadiusPlusZ ( G4double Rmax2 )
 
  202void G4Cons::SetZHalfLength ( G4double newDz )
 
  209void G4Cons::SetStartPhiAngle ( G4double newSPhi, G4bool compute )
 
  211  // Flag 'compute' can be used to explicitely avoid recomputation of
 
  212  // trigonometry in case SetDeltaPhiAngle() is invoked afterwards
 
  214  CheckSPhiAngle(newSPhi);
 
  215  fPhiFullCone = false;
 
  216  if (compute)  { InitializeTrigonometry(); }
 
  220void G4Cons::SetDeltaPhiAngle ( G4double newDPhi )
 
  222  CheckPhiAngles(fSPhi, newDPhi);
 
  227G4double G4Cons::GetCubicVolume()
 
  229  if(fCubicVolume != 0.) {;}
 
  232    G4double Rmean, rMean, deltaR, deltar;
 
  234    Rmean  = 0.5*(fRmax1+fRmax2);
 
  235    deltaR = fRmax1-fRmax2;
 
  237    rMean  = 0.5*(fRmin1+fRmin2);
 
  238    deltar = fRmin1-fRmin2;
 
  239    fCubicVolume = fDPhi*fDz*(Rmean*Rmean-rMean*rMean
 
  240                            +(deltaR*deltaR-deltar*deltar)/12);
 
  246G4double G4Cons::GetSurfaceArea()
 
  248  if(fSurfaceArea != 0.) {;}
 
  251    G4double mmin, mmax, dmin, dmax;
 
  253    mmin= (fRmin1+fRmin2)*0.5;
 
  254    mmax= (fRmax1+fRmax2)*0.5;
 
  255    dmin= (fRmin2-fRmin1);
 
  256    dmax= (fRmax2-fRmax1);
 
  258    fSurfaceArea = fDPhi*( mmin * std::sqrt(dmin*dmin+4*fDz*fDz)
 
  259                         + mmax * std::sqrt(dmax*dmax+4*fDz*fDz)
 
  260                         + 0.5*(fRmax1*fRmax1-fRmin1*fRmin1
 
  261                               +fRmax2*fRmax2-fRmin2*fRmin2 ));
 
  264      fSurfaceArea = fSurfaceArea+4*fDz*(mmax-mmin);