Ignore:
Timestamp:
Jan 8, 2010, 11:56:51 AM (16 years ago)
Author:
garnier
Message:

update geant4.9.3 tag

Location:
trunk/source/geometry/solids/CSG/include
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/geometry/solids/CSG/include/G4Box.hh

    r1058 r1228  
    2626//
    2727// $Id: G4Box.hh,v 1.17 2006/10/19 15:33:37 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// --------------------------------------------------------------------
  • trunk/source/geometry/solids/CSG/include/G4Box.icc

    r1058 r1228  
    2626//
    2727// $Id: G4Box.icc,v 1.6 2006/10/19 15:33:37 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// --------------------------------------------------------------------
  • trunk/source/geometry/solids/CSG/include/G4CSGSolid.hh

    r1058 r1228  
    2626//
    2727// $Id: G4CSGSolid.hh,v 1.12 2006/10/19 15:33:37 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// 
  • trunk/source/geometry/solids/CSG/include/G4Cons.hh

    r1058 r1228  
    2525//
    2626//
    27 // $Id: G4Cons.hh,v 1.21 2008/11/06 11:04:00 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4Cons.hh,v 1.22 2009/03/31 09:56:24 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    8080                 G4double pDz,
    8181                 G4double pSPhi, G4double pDPhi);
    82          
    83     virtual ~G4Cons() ;
     82      //
     83      // Constructs a cone with the given name and dimensions
     84
     85   ~G4Cons() ;
     86      //
     87      // Destructor
    8488
    8589    // Accessors
    8690
    87     inline G4double    GetInnerRadiusMinusZ() const;
    88     inline G4double    GetOuterRadiusMinusZ() const;
    89     inline G4double    GetInnerRadiusPlusZ()  const;
    90     inline G4double    GetOuterRadiusPlusZ()  const;
    91  
    92     inline G4double    GetZHalfLength()       const;
    93  
    94     inline G4double    GetStartPhiAngle () const;
    95     inline G4double    GetDeltaPhiAngle () const;
     91    inline G4double GetInnerRadiusMinusZ() const;
     92    inline G4double GetOuterRadiusMinusZ() const;
     93    inline G4double GetInnerRadiusPlusZ()  const;
     94    inline G4double GetOuterRadiusPlusZ()  const;
     95    inline G4double GetZHalfLength()       const;
     96    inline G4double GetStartPhiAngle()     const;
     97    inline G4double GetDeltaPhiAngle()     const;
    9698 
    9799    // Modifiers
    98100
    99     inline void    SetInnerRadiusMinusZ( G4double Rmin1 );
    100     inline void    SetOuterRadiusMinusZ( G4double Rmax1 );
    101     inline void    SetInnerRadiusPlusZ ( G4double Rmin2 );
    102     inline void    SetOuterRadiusPlusZ ( G4double Rmax2 );
    103          
    104     inline void    SetZHalfLength      ( G4double newDz );
    105     inline void    SetStartPhiAngle    ( G4double newSPhi);
    106     inline void    SetDeltaPhiAngle    ( G4double newDPhi);
     101    inline void SetInnerRadiusMinusZ (G4double Rmin1 );
     102    inline void SetOuterRadiusMinusZ (G4double Rmax1 );
     103    inline void SetInnerRadiusPlusZ  (G4double Rmin2 );
     104    inline void SetOuterRadiusPlusZ  (G4double Rmax2 );
     105    inline void SetZHalfLength       (G4double newDz );
     106    inline void SetStartPhiAngle     (G4double newSPhi, G4bool trig=true);
     107    inline void SetDeltaPhiAngle     (G4double newDPhi);
    107108
    108109    // Other methods for solid
    109110
    110     inline G4double    GetCubicVolume();
    111     inline G4double    GetSurfaceArea();
    112 
    113     void ComputeDimensions(G4VPVParameterisation* p,
    114                            const G4int n,
    115                            const G4VPhysicalVolume* pRep);
    116 
    117     G4bool CalculateExtent(const EAxis pAxis,
    118                            const G4VoxelLimits& pVoxelLimit,
    119                            const G4AffineTransform& pTransform,
    120                                  G4double& pmin, G4double& pmax) const;         
    121 
    122     EInside Inside(const G4ThreeVector& p) const;
    123 
    124     G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const;
     111    inline G4double GetCubicVolume();
     112    inline G4double GetSurfaceArea();
     113
     114    void ComputeDimensions(       G4VPVParameterisation* p,
     115                            const G4int n,
     116                            const G4VPhysicalVolume* pRep );
     117
     118    G4bool CalculateExtent( const EAxis pAxis,
     119                            const G4VoxelLimits& pVoxelLimit,
     120                            const G4AffineTransform& pTransform,
     121                                  G4double& pmin, G4double& pmax ) const;         
     122
     123    EInside Inside( const G4ThreeVector& p ) const;
     124
     125    G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const;
    125126
    126127    G4double DistanceToIn (const G4ThreeVector& p,
     
    134135    G4double DistanceToOut(const G4ThreeVector& p) const;
    135136
    136     G4GeometryType  GetEntityType() const;
     137    G4GeometryType GetEntityType() const;
    137138       
    138139    G4ThreeVector GetPointOnSurface() const;
     
    160161    inline G4double    GetRmin2() const;
    161162    inline G4double    GetRmax2() const;
    162  
    163163    inline G4double    GetDz()    const;
    164  
    165164    inline G4double    GetSPhi() const;
    166165    inline G4double    GetDPhi() const;
    167166
    168   protected:
     167  private:
    169168 
    170169    G4ThreeVectorList*
    171170    CreateRotatedVertices(const G4AffineTransform& pTransform) const;
    172171 
    173     G4double fRmin1, fRmin2, fRmax1, fRmax2, fDz, fSPhi, fDPhi;
    174     G4bool fPhiFullCone;
     172    inline void Initialize();
     173      //
     174      // Reset relevant values to zero
     175
     176    inline void CheckSPhiAngle(G4double sPhi);
     177    inline void CheckDPhiAngle(G4double dPhi);
     178    inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
     179      //
     180      // Reset relevant flags and angle values
     181
     182    inline void InitializeTrigonometry();
     183      //
     184      // Recompute relevant trigonometric values and cache them
     185
     186    G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
     187      //
     188      // Algorithm for SurfaceNormal() following the original
     189      // specification for points not on the surface
     190
     191  private:
    175192
    176193    // Used by distanceToOut
    177  
     194    //
    178195    enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ};
    179196 
    180197    // used by normal
    181  
     198    //
    182199    enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ};
    183200
    184   private:
    185 
    186     inline void Initialise();
    187       // Reset relevant values to zero
    188 
    189     inline void InitializeTrigonometry();
    190       //
    191       // Recompute relevant trigonometric values and cache them
    192 
    193     G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
    194       //
    195       // Algorithm for SurfaceNormal() following the original
    196       // specification for points not on the surface
    197 
    198   private:
    199 
    200201    G4double kRadTolerance, kAngTolerance;
    201202      //
    202203      // Radial and angular tolerances
     204
     205    G4double fRmin1, fRmin2, fRmax1, fRmax2, fDz, fSPhi, fDPhi;
     206      //
     207      // Radial and angular dimensions
    203208
    204209    G4double sinCPhi, cosCPhi, cosHDPhiOT, cosHDPhiIT,
     
    206211      //
    207212      // Cached trigonometric values
     213
     214    G4bool fPhiFullCone;
     215      //
     216      // Flag for identification of section or full cone
    208217};
    209218
  • trunk/source/geometry/solids/CSG/include/G4Cons.icc

    r1058 r1228  
    2525//
    2626//
    27 // $Id: G4Cons.icc,v 1.8 2008/11/06 10:55:40 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4Cons.icc,v 1.11 2009/06/09 16:08:23 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// --------------------------------------------------------------------
     
    3737
    3838inline
    39 void G4Cons::Initialise()
    40 {
    41   fCubicVolume= 0.;
    42   fSurfaceArea= 0.;
     39G4double G4Cons::GetInnerRadiusMinusZ() const
     40{
     41  return fRmin1 ;
     42}
     43
     44inline
     45G4double G4Cons::GetOuterRadiusMinusZ() const
     46{
     47  return fRmax1 ;
     48}
     49
     50inline
     51G4double G4Cons::GetInnerRadiusPlusZ() const
     52{
     53  return fRmin2 ;
     54}
     55
     56inline
     57G4double G4Cons::GetOuterRadiusPlusZ() const
     58{
     59  return fRmax2 ;
     60}
     61
     62inline
     63G4double G4Cons::GetZHalfLength() const
     64{
     65  return fDz ;
     66}
     67
     68inline 
     69G4double G4Cons::GetStartPhiAngle() const
     70{
     71  return fSPhi ;
     72}
     73
     74inline
     75G4double G4Cons::GetDeltaPhiAngle() const
     76{
     77  return fDPhi;
     78}
     79
     80inline
     81void G4Cons::Initialize()
     82{
     83  fCubicVolume = 0.;
     84  fSurfaceArea = 0.;
    4385  fpPolyhedron = 0;
    4486}
     
    61103}
    62104
    63 inline
    64 G4double G4Cons::GetInnerRadiusMinusZ() const
    65 {
    66   return fRmin1 ;
    67 }
    68 
    69 inline
    70 G4double G4Cons::GetOuterRadiusMinusZ() const
    71 {
    72   return fRmax1 ;
    73 }
    74 
    75 inline
    76 G4double G4Cons::GetInnerRadiusPlusZ() const
    77 {
    78   return fRmin2 ;
    79 }
    80 
    81 inline
    82 G4double G4Cons::GetOuterRadiusPlusZ() const
    83 {
    84   return fRmax2 ;
    85 }
    86 
    87 inline
    88 G4double G4Cons::GetZHalfLength() const
    89 {
    90   return fDz ;
    91 }
    92 
    93 inline 
    94 G4double G4Cons::GetStartPhiAngle() const
    95 {
    96   return fSPhi ;
    97 }
    98 
    99 inline
    100 G4double G4Cons::GetDeltaPhiAngle() const
    101 {
    102   return fDPhi;
     105inline void G4Cons::CheckSPhiAngle(G4double sPhi)
     106{
     107  // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0
     108
     109  if ( sPhi < 0 )
     110  {
     111    fSPhi = twopi - std::fmod(std::fabs(sPhi),twopi);
     112  }
     113  else
     114  {
     115    fSPhi = std::fmod(sPhi,twopi) ;
     116  }
     117  if ( fSPhi+fDPhi > twopi )
     118  {
     119    fSPhi -= twopi ;
     120  }
     121}
     122
     123inline void G4Cons::CheckDPhiAngle(G4double dPhi)
     124{
     125  fPhiFullCone = true;
     126  if ( dPhi >= twopi-kAngTolerance*0.5 )
     127  {
     128    fDPhi=twopi;
     129    fSPhi=0;
     130  }
     131  else
     132  {
     133    fPhiFullCone = false;
     134    if ( dPhi > 0 )
     135    {
     136      fDPhi = dPhi;
     137    }
     138    else
     139    {
     140      G4cerr << "ERROR - G4Cons()::CheckDPhiAngle()" << G4endl
     141             << "        Negative or zero delta-Phi (" << dPhi << ") in solid: "
     142             << GetName() << G4endl;
     143      G4Exception("G4Cons::CheckDPhiAngle()", "InvalidSetup",
     144                  FatalException, "Invalid dphi.");
     145    }
     146  }
     147}
     148
     149inline void G4Cons::CheckPhiAngles(G4double sPhi, G4double dPhi)
     150{
     151  CheckDPhiAngle(dPhi);
     152  if ( (fDPhi<twopi) && (sPhi) ) { CheckSPhiAngle(sPhi); }
     153  InitializeTrigonometry();
    103154}
    104155
     
    107158{
    108159  fRmin1= Rmin1 ;
    109   Initialise();
     160  Initialize();
    110161}
    111162
     
    114165{
    115166  fRmax1= Rmax1 ;
    116   Initialise();
     167  Initialize();
    117168}
    118169
     
    121172{
    122173  fRmin2= Rmin2 ;
    123   Initialise();
     174  Initialize();
    124175}
    125176
     
    128179{
    129180  fRmax2= Rmax2 ;
    130   Initialise();
     181  Initialize();
    131182}
    132183
     
    135186{
    136187  fDz= newDz ;
    137   Initialise();
    138 }
    139 
    140 inline
    141 void G4Cons::SetStartPhiAngle ( G4double newSPhi )
    142 {
    143   fSPhi= newSPhi;
    144   Initialise();
    145   InitializeTrigonometry();
     188  Initialize();
     189}
     190
     191inline
     192void G4Cons::SetStartPhiAngle ( G4double newSPhi, G4bool compute )
     193{
     194  // Flag 'compute' can be used to explicitely avoid recomputation of
     195  // trigonometry in case SetDeltaPhiAngle() is invoked afterwards
     196
     197  CheckSPhiAngle(newSPhi);
     198  fPhiFullCone = false;
     199  if (compute)  { InitializeTrigonometry(); }
     200  Initialize();
    146201}
    147202
    148203void G4Cons::SetDeltaPhiAngle ( G4double newDPhi )
    149204{
    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();
     205  CheckPhiAngles(fSPhi, newDPhi);
     206  Initialize();
    168207}
    169208
  • trunk/source/geometry/solids/CSG/include/G4Orb.hh

    r1058 r1228  
    2626//
    2727// $Id: G4Orb.hh,v 1.11 2006/10/19 15:33:37 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
  • trunk/source/geometry/solids/CSG/include/G4Orb.icc

    r1058 r1228  
    2626//
    2727// $Id: G4Orb.icc,v 1.5 2006/10/19 15:33:37 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// --------------------------------------------------------------------
  • trunk/source/geometry/solids/CSG/include/G4Para.hh

    r1058 r1228  
    2626//
    2727// $Id: G4Para.hh,v 1.18 2006/10/19 15:33:37 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
  • trunk/source/geometry/solids/CSG/include/G4Para.icc

    r1058 r1228  
    2626//
    2727// $Id: G4Para.icc,v 1.7 2006/10/19 15:33:37 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// --------------------------------------------------------------------
  • trunk/source/geometry/solids/CSG/include/G4Sphere.hh

    r1058 r1228  
    2525//
    2626//
    27 // $Id: G4Sphere.hh,v 1.21 2008/11/21 09:50:05 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4Sphere.hh,v 1.24 2009/03/31 07:51:49 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    3636// Class description:
    3737//
    38 //   A G4Sphere is, in the general case, section of a spherical shell,
     38//   A G4Sphere is, in the general case, a section of a spherical shell,
    3939//   between specified phi and theta angles
    4040//
     
    8383                   G4double pSPhi, G4double pDPhi,
    8484                   G4double pSTheta, G4double pDTheta);
     85      //
     86      // Constructs a sphere or sphere shell section
     87      // with the given name and dimensions
    8588       
    86     virtual ~G4Sphere() ;
    87    
     89   ~G4Sphere();
     90      //
     91      // Destructor
     92
    8893    // Accessors
    8994       
     
    99104    inline void SetInnerRadius    (G4double newRMin);
    100105    inline void SetOuterRadius    (G4double newRmax);
    101     inline void SetStartPhiAngle  (G4double newSphi);
     106    inline void SetStartPhiAngle  (G4double newSphi, G4bool trig=true);
    102107    inline void SetDeltaPhiAngle  (G4double newDphi);
    103108    inline void SetStartThetaAngle(G4double newSTheta);
     
    107112
    108113    inline G4double GetCubicVolume();
    109     inline G4double GetSurfaceArea();
     114    G4double GetSurfaceArea();
    110115
    111116    void ComputeDimensions(      G4VPVParameterisation* p,
     
    142147
    143148    // Visualisation functions
     149
    144150    G4VisExtent   GetExtent          () const;   
    145151    void          DescribeYourselfTo(G4VGraphicsScene& scene) const;
     
    150156   
    151157    G4Sphere(__void__&);
     158      //
    152159      // Fake default constructor for usage restricted to direct object
    153160      // persistency for clients requiring preallocation of memory for
     
    165172    inline void SetInsideRadius(G4double newRmin);
    166173
    167   protected:
     174  private:
    168175 
    169176    G4ThreeVectorList*
    170177    CreateRotatedVertices(const G4AffineTransform& pTransform,
    171178                                G4int& noPolygonVertices) const;
    172  
     179      //
     180      // Creates the List of transformed vertices in the format required
     181      // for G4VSolid:: ClipCrossSection and ClipBetweenSections
     182
     183    inline void Initialize();
     184      //
     185      // Reset relevant values to zero
     186
     187    inline void CheckThetaAngles(G4double sTheta, G4double dTheta);
     188    inline void CheckSPhiAngle(G4double sPhi);
     189    inline void CheckDPhiAngle(G4double dPhi);
     190    inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
     191      //
     192      // Reset relevant flags and angle values
     193
     194    inline void InitializePhiTrigonometry();
     195    inline void InitializeThetaTrigonometry();
     196      //
     197      // Recompute relevant trigonometric values and cache them
     198
     199    G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p) const;
     200      //
     201      // Algorithm for SurfaceNormal() following the original
     202      // specification for points not on the surface
     203
     204  private:
     205
    173206    // Used by distanceToOut
    174  
     207    //
    175208    enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kSTheta,kETheta};
    176209 
    177210    // used by normal
    178  
     211    //
    179212    enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNSTheta,kNETheta};
    180213
    181   private:
    182 
    183     G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p) const;
    184       // Algorithm for SurfaceNormal() following the original
    185       // specification for points not on the surface
    186 
    187   private:
    188 
    189     G4double kAngTolerance, kRadTolerance;
    190 
    191     G4double fRmin,fRmax,
    192              fSPhi,fDPhi,
    193              fSTheta,fDTheta;
    194     G4double fEpsilon;
     214    G4double fEpsilon, fRminTolerance, fRmaxTolerance, kAngTolerance;
     215      //
     216      // Radial and angular tolerances
     217
     218    G4double fRmin, fRmax, fSPhi, fDPhi, fSTheta, fDTheta;
     219      //
     220      // Radial and angular dimensions
     221
     222    G4double sinCPhi, cosCPhi, cosHDPhiOT, cosHDPhiIT,
     223             sinSPhi, cosSPhi, sinEPhi, cosEPhi, hDPhi, cPhi, ePhi;
     224      //
     225      // Cached trigonometric values for Phi angle
     226
     227    G4double sinSTheta, cosSTheta, sinETheta, cosETheta,
     228             tanSTheta, tanSTheta2, tanETheta, tanETheta2, eTheta;
     229      //
     230      // Cached trigonometric values for Theta angle
     231
     232    G4bool fFullPhiSphere, fFullThetaSphere, fFullSphere;
     233      //
     234      // Flags for identification of section, shell or full sphere
    195235};
    196236
  • trunk/source/geometry/solids/CSG/include/G4Sphere.icc

    r1058 r1228  
    2525//
    2626//
    27 // $Id: G4Sphere.icc,v 1.8 2008/11/21 09:50:05 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4Sphere.icc,v 1.11 2009/05/13 11:23:00 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// --------------------------------------------------------------------
     
    7777}
    7878
     79inline
     80void G4Sphere::Initialize()
     81{
     82  fCubicVolume = 0.;
     83  fSurfaceArea = 0.;
     84  fpPolyhedron = 0;
     85}
     86
     87inline
     88void G4Sphere::InitializePhiTrigonometry()
     89{
     90  hDPhi = 0.5*fDPhi;                       // half delta phi
     91  cPhi  = fSPhi + hDPhi;
     92  ePhi  = fSPhi + fDPhi;
     93
     94  sinCPhi    = std::sin(cPhi);
     95  cosCPhi    = std::cos(cPhi);
     96  cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance); // inner/outer tol half dphi
     97  cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance);
     98  sinSPhi = std::sin(fSPhi);
     99  cosSPhi = std::cos(fSPhi);
     100  sinEPhi = std::sin(ePhi);
     101  cosEPhi = std::cos(ePhi);
     102}
     103
     104inline
     105void G4Sphere::InitializeThetaTrigonometry()
     106{
     107  eTheta  = fSTheta + fDTheta;
     108
     109  sinSTheta = std::sin(fSTheta);
     110  cosSTheta = std::cos(fSTheta);
     111  sinETheta = std::sin(eTheta);
     112  cosETheta = std::cos(eTheta);
     113
     114  tanSTheta  = std::tan(fSTheta);
     115  tanSTheta2 = tanSTheta*tanSTheta;
     116  tanETheta  = std::tan(eTheta);
     117  tanETheta2 = tanETheta*tanETheta;
     118}
     119
     120inline
     121void G4Sphere::CheckThetaAngles(G4double sTheta, G4double dTheta)
     122{
     123  if ( (sTheta<0) || (sTheta>pi) )
     124  {
     125    G4cerr << "ERROR - G4Sphere()::CheckThetaAngles()" << G4endl
     126           << "        Invalid starting Theta angle for solid: " << GetName()
     127           << G4endl;
     128    G4Exception("G4Sphere::CheckThetaAngles()", "InvalidSetup",
     129                FatalException, "sTheta outside 0-PI range.");
     130  }
     131  else
     132  {
     133    fSTheta=sTheta;
     134  }
     135  if ( dTheta+sTheta >= pi )
     136  {
     137    fDTheta=pi-sTheta;
     138  }
     139  else if ( dTheta > 0 )
     140  {
     141    fDTheta=dTheta;
     142  }
     143  else
     144  {
     145    G4cerr << "ERROR - G4Sphere()::CheckThetaAngles(): " << G4endl
     146           << "        Negative delta-Theta (" << dTheta << "), for solid: "
     147           << GetName() << G4endl;
     148    G4Exception("G4Sphere::CheckThetaAngles()", "InvalidSetup",
     149                FatalException, "Invalid dTheta.");
     150  }
     151  if ( fDTheta-fSTheta < pi ) { fFullThetaSphere = false; }
     152  else                        { fFullThetaSphere = true ; }
     153  fFullSphere = fFullPhiSphere && fFullThetaSphere;
     154
     155  InitializeThetaTrigonometry();
     156}
     157
     158inline
     159void G4Sphere::CheckSPhiAngle(G4double sPhi)
     160{
     161  // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0
     162
     163  if ( sPhi < 0 )
     164  {
     165    fSPhi = twopi - std::fmod(std::fabs(sPhi),twopi);
     166  }
     167  else
     168  {
     169    fSPhi = std::fmod(sPhi,twopi) ;
     170  }
     171  if ( fSPhi+fDPhi > twopi )
     172  {
     173    fSPhi -= twopi ;
     174  }
     175}
     176
     177inline
     178void G4Sphere::CheckDPhiAngle(G4double dPhi)
     179{
     180  fFullPhiSphere = true;
     181  if ( dPhi >= twopi-kAngTolerance*0.5 )
     182  {
     183    fDPhi=twopi;
     184    fSPhi=0;
     185  }
     186  else
     187  {
     188    fFullPhiSphere = false;
     189    if ( dPhi > 0 )
     190    {
     191      fDPhi = dPhi;
     192    }
     193    else
     194    {
     195      G4cerr << "ERROR - G4Sphere()::CheckDPhiAngle(): " << GetName() << G4endl
     196             << "        Negative delta-Phi ! - "
     197             << dPhi << G4endl;
     198      G4Exception("G4Sphere::CheckDPhiAngle()", "InvalidSetup",
     199                  FatalException, "Invalid dphi.");
     200    }
     201  }
     202}
     203
     204inline
     205void G4Sphere::CheckPhiAngles(G4double sPhi, G4double dPhi)
     206{
     207  CheckDPhiAngle(dPhi);
     208  if (!fFullPhiSphere && sPhi) { CheckSPhiAngle(sPhi); }
     209  fFullSphere = fFullPhiSphere && fFullThetaSphere;
     210
     211  InitializePhiTrigonometry();
     212}
     213
    79214inline
    80215void G4Sphere::SetInsideRadius(G4double newRmin)
    81216{
    82217  fRmin= newRmin;
    83   fCubicVolume= 0.;
    84   fSurfaceArea= 0.;
    85   fpPolyhedron = 0;
     218  Initialize();
    86219}
    87220
     
    90223{
    91224  fRmin= newRmin;
    92   fCubicVolume= 0.;
    93   fSurfaceArea= 0.;
    94   fpPolyhedron = 0;
     225  Initialize();
    95226}
    96227
     
    99230{
    100231  fRmax= newRmax;
    101   fCubicVolume= 0.;
    102   fSurfaceArea= 0.;
    103   fpPolyhedron = 0;
    104 }
    105 
    106 inline
    107 void G4Sphere::SetStartPhiAngle(G4double newSphi)
    108 {
    109   fSPhi= newSphi;
    110   fCubicVolume= 0.;
    111   fSurfaceArea= 0.;
    112   fpPolyhedron = 0;
    113 }
    114 
    115 inline
    116 void G4Sphere::SetDeltaPhiAngle(G4double newDphi)
    117 {
    118   fDPhi= newDphi;
    119   fCubicVolume= 0.;
    120   fSurfaceArea= 0.;
    121   fpPolyhedron = 0;
     232  Initialize();
     233}
     234
     235inline
     236void G4Sphere::SetStartPhiAngle(G4double newSPhi, G4bool compute)
     237{
     238  // Flag 'compute' can be used to explicitely avoid recomputation of
     239  // trigonometry in case SetDeltaPhiAngle() is invoked afterwards
     240
     241  CheckSPhiAngle(newSPhi);
     242  fFullPhiSphere = false;
     243  if (compute)  { InitializePhiTrigonometry(); }
     244  Initialize();
     245}
     246
     247inline
     248void G4Sphere::SetDeltaPhiAngle(G4double newDPhi)
     249{
     250  CheckPhiAngles(fSPhi, newDPhi);
     251  Initialize();
    122252}
    123253
     
    125255void G4Sphere::SetStartThetaAngle(G4double newSTheta)
    126256{
    127   fSTheta=newSTheta;
    128   fCubicVolume= 0.;
    129   fSurfaceArea= 0.;
    130   fpPolyhedron = 0;
     257  CheckThetaAngles(newSTheta, fDTheta);
     258  Initialize();
    131259}
    132260
     
    134262void G4Sphere::SetDeltaThetaAngle(G4double newDTheta)
    135263{
    136   fDTheta=newDTheta;
    137   fCubicVolume= 0.;
    138   fSurfaceArea= 0.;
    139   fpPolyhedron = 0;
     264  CheckThetaAngles(fSTheta, newDTheta);
     265  Initialize();
    140266}
    141267
     
    182308{
    183309  if(fCubicVolume != 0.) {;}
    184   else   fCubicVolume = fDPhi*(std::cos(fSTheta)-std::cos(fSTheta+fDTheta))*
    185                               (fRmax*fRmax*fRmax-fRmin*fRmin*fRmin)/3.;
     310  else { fCubicVolume = fDPhi*(std::cos(fSTheta)-std::cos(fSTheta+fDTheta))*
     311                              (fRmax*fRmax*fRmax-fRmin*fRmin*fRmin)/3.; }
    186312  return fCubicVolume;
    187313}
    188 
    189 
    190 inline
    191 G4double G4Sphere::GetSurfaceArea()
    192 {
    193   if(fSurfaceArea != 0.) {;}
    194   else
    195   {   
    196     G4double Rsq=fRmax*fRmax;
    197     G4double rsq=fRmin*fRmin;
    198          
    199     fSurfaceArea = fDPhi*(rsq+Rsq)*(std::cos(fSTheta)
    200                  - std::cos(fSTheta+fDTheta));
    201     if(fDPhi < twopi)
    202     {
    203       fSurfaceArea = fSurfaceArea + fDTheta*(Rsq-rsq);
    204     }
    205     if(fSTheta >0)
    206     {
    207       G4double acos1=std::acos( std::pow(std::sin(fSTheta),2)
    208                                *std::cos(fDPhi)
    209                                +std::pow(std::cos(fSTheta),2));
    210       if(fDPhi>pi)
    211       {
    212         fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*(twopi-acos1);
    213       }
    214       else
    215       {
    216         fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*acos1;
    217       }
    218     }
    219     if(fDTheta+fSTheta < pi)
    220     {
    221       G4double acos2=std::acos( std::pow(std::sin(fSTheta+fDTheta),2)
    222                                *std::cos(fDPhi)
    223                                +std::pow(std::cos(fSTheta+fDTheta),2));
    224       if(fDPhi>pi)
    225       {
    226         fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*(twopi-acos2);
    227       }
    228       else
    229       {
    230         fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*acos2;
    231       }
    232     }
    233   }
    234   return fSurfaceArea;
    235 }
  • trunk/source/geometry/solids/CSG/include/G4Torus.hh

    r1058 r1228  
    2626//
    2727// $Id: G4Torus.hh,v 1.27 2007/05/18 07:38:00 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
  • trunk/source/geometry/solids/CSG/include/G4Torus.icc

    r1058 r1228  
    2626//
    2727// $Id: G4Torus.icc,v 1.6 2006/10/19 15:33:37 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// --------------------------------------------------------------------
  • trunk/source/geometry/solids/CSG/include/G4Trap.hh

    r1058 r1228  
    2626//
    2727// $Id: G4Trap.hh,v 1.17 2006/10/19 15:33:37 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
  • trunk/source/geometry/solids/CSG/include/G4Trap.icc

    r1058 r1228  
    2626//
    2727// $Id: G4Trap.icc,v 1.8 2006/10/19 15:33:37 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// --------------------------------------------------------------------
  • trunk/source/geometry/solids/CSG/include/G4Trd.hh

    r1058 r1228  
    2626//
    2727// $Id: G4Trd.hh,v 1.16 2006/10/19 15:33:37 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
  • trunk/source/geometry/solids/CSG/include/G4Trd.icc

    r1058 r1228  
    2626//
    2727// $Id: G4Trd.icc,v 1.7 2006/10/19 15:33:37 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// --------------------------------------------------------------------
  • trunk/source/geometry/solids/CSG/include/G4Tubs.hh

    r1058 r1228  
    2525//
    2626//
    27 // $Id: G4Tubs.hh,v 1.21 2008/11/06 10:55:40 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4Tubs.hh,v 1.22 2009/03/26 16:25:44 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030//
     
    8686      // Constructs a tubs with the given name and dimensions
    8787
    88     virtual ~G4Tubs();
     88   ~G4Tubs();
    8989      //
    9090      // Destructor
     
    103103    inline void SetOuterRadius   (G4double newRMax);
    104104    inline void SetZHalfLength   (G4double newDz);
    105     inline void SetStartPhiAngle (G4double newSPhi);
     105    inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true);
    106106    inline void SetDeltaPhiAngle (G4double newDPhi);
    107107   
     
    159159    inline G4double GetDPhi() const;
    160160
    161   protected:
     161  private:
    162162
    163163    G4ThreeVectorList*
     
    167167      // for G4VSolid:: ClipCrossSection and ClipBetweenSections
    168168
    169     G4double fRMin, fRMax, fDz, fSPhi, fDPhi;
    170     G4bool fPhiFullTube;
    171    
    172       // Used by distanceToOut
    173 
    174     enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ};
    175 
    176       // Used by normal
    177 
    178     enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ};
    179 
    180   private:
    181 
    182169    inline void Initialize();
    183170      //
    184171      // Reset relevant values to zero
     172
     173    inline void CheckSPhiAngle(G4double sPhi);
     174    inline void CheckDPhiAngle(G4double dPhi);
     175    inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
     176      //
     177      // Reset relevant flags and angle values
    185178
    186179    inline void InitializeTrigonometry();
     
    195188  private:
    196189
     190    // Used by distanceToOut
     191    //
     192    enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ};
     193
     194    // Used by normal
     195    //
     196    enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ};
     197
    197198    G4double kRadTolerance, kAngTolerance;
    198199      //
    199200      // Radial and angular tolerances
    200201
     202    G4double fRMin, fRMax, fDz, fSPhi, fDPhi;
     203      //
     204      // Radial and angular dimensions
     205   
    201206    G4double sinCPhi, cosCPhi, cosHDPhiOT, cosHDPhiIT,
    202207             sinSPhi, cosSPhi, sinEPhi, cosEPhi;
    203208      //
    204209      // Cached trigonometric values
     210
     211    G4bool fPhiFullTube;
     212      //
     213      // Flag for identification of section or full tube
    205214};
    206215
  • trunk/source/geometry/solids/CSG/include/G4Tubs.icc

    r1058 r1228  
    2525//
    2626//
    27 // $Id: G4Tubs.icc,v 1.11 2008/11/06 10:55:40 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4Tubs.icc,v 1.14 2009/06/09 16:08:23 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-03 $
    2929//
    3030// --------------------------------------------------------------------
     
    9191}
    9292
     93inline void G4Tubs::CheckSPhiAngle(G4double sPhi)
     94{
     95  // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0
     96
     97  if ( sPhi < 0 )
     98  {
     99    fSPhi = twopi - std::fmod(std::fabs(sPhi),twopi);
     100  }
     101  else
     102  {
     103    fSPhi = std::fmod(sPhi,twopi) ;
     104  }
     105  if ( fSPhi+fDPhi > twopi )
     106  {
     107    fSPhi -= twopi ;
     108  }
     109}
     110
     111inline void G4Tubs::CheckDPhiAngle(G4double dPhi)
     112{
     113  fPhiFullTube = true;
     114  if ( dPhi >= twopi-kAngTolerance*0.5 )
     115  {
     116    fDPhi=twopi;
     117    fSPhi=0;
     118  }
     119  else
     120  {
     121    fPhiFullTube = false;
     122    if ( dPhi > 0 )
     123    {
     124      fDPhi = dPhi;
     125    }
     126    else
     127    {
     128      G4cerr << "ERROR - G4Tubs()::CheckDPhiAngle()" << G4endl
     129             << "        Negative or zero delta-Phi (" << dPhi << ") in solid: "
     130             << GetName() << G4endl;
     131      G4Exception("G4Tubs::CheckDPhiAngle()", "InvalidSetup",
     132                  FatalException, "Invalid dphi.");
     133    }
     134  }
     135}
     136
     137inline void G4Tubs::CheckPhiAngles(G4double sPhi, G4double dPhi)
     138{
     139  CheckDPhiAngle(dPhi);
     140  if ( (fDPhi<twopi) && (sPhi) ) { CheckSPhiAngle(sPhi); }
     141  InitializeTrigonometry();
     142}
     143
    93144inline
    94145void G4Tubs::SetInnerRadius (G4double newRMin)
     
    113164
    114165inline
    115 void G4Tubs::SetStartPhiAngle (G4double newSPhi)
    116 {
    117   fSPhi= newSPhi;
    118   Initialize();
    119   InitializeTrigonometry();
     166void G4Tubs::SetStartPhiAngle (G4double newSPhi, G4bool compute)
     167{
     168  // Flag 'compute' can be used to explicitely avoid recomputation of
     169  // trigonometry in case SetDeltaPhiAngle() is invoked afterwards
     170
     171  CheckSPhiAngle(newSPhi);
     172  fPhiFullTube = false;
     173  if (compute)  { InitializeTrigonometry(); }
     174  Initialize();
    120175}
    121176
     
    123178void G4Tubs::SetDeltaPhiAngle (G4double newDPhi)
    124179{
    125   if ( newDPhi >= twopi-kAngTolerance*0.5 )
    126   {
    127     fPhiFullTube = true;
    128   }
    129   else if ( newDPhi > 0 )
    130   {
    131     fPhiFullTube = false;
    132   }
    133   else
    134   {
    135      G4cerr << "ERROR - G4Tubs()::SetDeltaPhiAngle() : " << GetName() << G4endl
    136             << "        Negative delta-Phi ! - " << newDPhi << G4endl;
    137      G4Exception("G4Tubs::SetDeltaPhiAngle()", "InvalidSetup",
    138                   FatalException, "Invalid dphi.");
    139   }
    140   fDPhi= newDPhi;
    141   Initialize();
    142   InitializeTrigonometry();
     180  CheckPhiAngles(fSPhi, newDPhi);
     181  Initialize();
    143182}
    144183
Note: See TracChangeset for help on using the changeset viewer.