Changeset 1228 for trunk/source/geometry/solids/CSG/include
- Timestamp:
- Jan 8, 2010, 11:56:51 AM (16 years ago)
- Location:
- trunk/source/geometry/solids/CSG/include
- Files:
-
- 19 edited
-
G4Box.hh (modified) (1 diff)
-
G4Box.icc (modified) (1 diff)
-
G4CSGSolid.hh (modified) (1 diff)
-
G4Cons.hh (modified) (5 diffs)
-
G4Cons.icc (modified) (8 diffs)
-
G4Orb.hh (modified) (1 diff)
-
G4Orb.icc (modified) (1 diff)
-
G4Para.hh (modified) (1 diff)
-
G4Para.icc (modified) (1 diff)
-
G4Sphere.hh (modified) (8 diffs)
-
G4Sphere.icc (modified) (7 diffs)
-
G4Torus.hh (modified) (1 diff)
-
G4Torus.icc (modified) (1 diff)
-
G4Trap.hh (modified) (1 diff)
-
G4Trap.icc (modified) (1 diff)
-
G4Trd.hh (modified) (1 diff)
-
G4Trd.icc (modified) (1 diff)
-
G4Tubs.hh (modified) (6 diffs)
-
G4Tubs.icc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/geometry/solids/CSG/include/G4Box.hh
r1058 r1228 26 26 // 27 27 // $Id: G4Box.hh,v 1.17 2006/10/19 15:33:37 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -------------------------------------------------------------------- -
trunk/source/geometry/solids/CSG/include/G4Box.icc
r1058 r1228 26 26 // 27 27 // $Id: G4Box.icc,v 1.6 2006/10/19 15:33:37 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -------------------------------------------------------------------- -
trunk/source/geometry/solids/CSG/include/G4CSGSolid.hh
r1058 r1228 26 26 // 27 27 // $Id: G4CSGSolid.hh,v 1.12 2006/10/19 15:33:37 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -
trunk/source/geometry/solids/CSG/include/G4Cons.hh
r1058 r1228 25 25 // 26 26 // 27 // $Id: G4Cons.hh,v 1.2 1 2008/11/06 11:04:00gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$27 // $Id: G4Cons.hh,v 1.22 2009/03/31 09:56:24 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // … … 80 80 G4double pDz, 81 81 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 84 88 85 89 // Accessors 86 90 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; 96 98 97 99 // Modifiers 98 100 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); 107 108 108 109 // Other methods for solid 109 110 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; 125 126 126 127 G4double DistanceToIn (const G4ThreeVector& p, … … 134 135 G4double DistanceToOut(const G4ThreeVector& p) const; 135 136 136 G4GeometryType GetEntityType() const;137 G4GeometryType GetEntityType() const; 137 138 138 139 G4ThreeVector GetPointOnSurface() const; … … 160 161 inline G4double GetRmin2() const; 161 162 inline G4double GetRmax2() const; 162 163 163 inline G4double GetDz() const; 164 165 164 inline G4double GetSPhi() const; 166 165 inline G4double GetDPhi() const; 167 166 168 pr otected:167 private: 169 168 170 169 G4ThreeVectorList* 171 170 CreateRotatedVertices(const G4AffineTransform& pTransform) const; 172 171 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: 175 192 176 193 // Used by distanceToOut 177 194 // 178 195 enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ}; 179 196 180 197 // used by normal 181 198 // 182 199 enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ}; 183 200 184 private:185 186 inline void Initialise();187 // Reset relevant values to zero188 189 inline void InitializeTrigonometry();190 //191 // Recompute relevant trigonometric values and cache them192 193 G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;194 //195 // Algorithm for SurfaceNormal() following the original196 // specification for points not on the surface197 198 private:199 200 201 G4double kRadTolerance, kAngTolerance; 201 202 // 202 203 // Radial and angular tolerances 204 205 G4double fRmin1, fRmin2, fRmax1, fRmax2, fDz, fSPhi, fDPhi; 206 // 207 // Radial and angular dimensions 203 208 204 209 G4double sinCPhi, cosCPhi, cosHDPhiOT, cosHDPhiIT, … … 206 211 // 207 212 // Cached trigonometric values 213 214 G4bool fPhiFullCone; 215 // 216 // Flag for identification of section or full cone 208 217 }; 209 218 -
trunk/source/geometry/solids/CSG/include/G4Cons.icc
r1058 r1228 25 25 // 26 26 // 27 // $Id: G4Cons.icc,v 1. 8 2008/11/06 10:55:40gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$27 // $Id: G4Cons.icc,v 1.11 2009/06/09 16:08:23 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -------------------------------------------------------------------- … … 37 37 38 38 inline 39 void G4Cons::Initialise() 40 { 41 fCubicVolume= 0.; 42 fSurfaceArea= 0.; 39 G4double G4Cons::GetInnerRadiusMinusZ() const 40 { 41 return fRmin1 ; 42 } 43 44 inline 45 G4double G4Cons::GetOuterRadiusMinusZ() const 46 { 47 return fRmax1 ; 48 } 49 50 inline 51 G4double G4Cons::GetInnerRadiusPlusZ() const 52 { 53 return fRmin2 ; 54 } 55 56 inline 57 G4double G4Cons::GetOuterRadiusPlusZ() const 58 { 59 return fRmax2 ; 60 } 61 62 inline 63 G4double G4Cons::GetZHalfLength() const 64 { 65 return fDz ; 66 } 67 68 inline 69 G4double G4Cons::GetStartPhiAngle() const 70 { 71 return fSPhi ; 72 } 73 74 inline 75 G4double G4Cons::GetDeltaPhiAngle() const 76 { 77 return fDPhi; 78 } 79 80 inline 81 void G4Cons::Initialize() 82 { 83 fCubicVolume = 0.; 84 fSurfaceArea = 0.; 43 85 fpPolyhedron = 0; 44 86 } … … 61 103 } 62 104 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; 105 inline 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 123 inline 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 149 inline void G4Cons::CheckPhiAngles(G4double sPhi, G4double dPhi) 150 { 151 CheckDPhiAngle(dPhi); 152 if ( (fDPhi<twopi) && (sPhi) ) { CheckSPhiAngle(sPhi); } 153 InitializeTrigonometry(); 103 154 } 104 155 … … 107 158 { 108 159 fRmin1= Rmin1 ; 109 Initiali se();160 Initialize(); 110 161 } 111 162 … … 114 165 { 115 166 fRmax1= Rmax1 ; 116 Initiali se();167 Initialize(); 117 168 } 118 169 … … 121 172 { 122 173 fRmin2= Rmin2 ; 123 Initiali se();174 Initialize(); 124 175 } 125 176 … … 128 179 { 129 180 fRmax2= Rmax2 ; 130 Initiali se();181 Initialize(); 131 182 } 132 183 … … 135 186 { 136 187 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 191 inline 192 void 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(); 146 201 } 147 202 148 203 void G4Cons::SetDeltaPhiAngle ( G4double newDPhi ) 149 204 { 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(); 168 207 } 169 208 -
trunk/source/geometry/solids/CSG/include/G4Orb.hh
r1058 r1228 26 26 // 27 27 // $Id: G4Orb.hh,v 1.11 2006/10/19 15:33:37 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -
trunk/source/geometry/solids/CSG/include/G4Orb.icc
r1058 r1228 26 26 // 27 27 // $Id: G4Orb.icc,v 1.5 2006/10/19 15:33:37 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -------------------------------------------------------------------- -
trunk/source/geometry/solids/CSG/include/G4Para.hh
r1058 r1228 26 26 // 27 27 // $Id: G4Para.hh,v 1.18 2006/10/19 15:33:37 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -
trunk/source/geometry/solids/CSG/include/G4Para.icc
r1058 r1228 26 26 // 27 27 // $Id: G4Para.icc,v 1.7 2006/10/19 15:33:37 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -------------------------------------------------------------------- -
trunk/source/geometry/solids/CSG/include/G4Sphere.hh
r1058 r1228 25 25 // 26 26 // 27 // $Id: G4Sphere.hh,v 1.2 1 2008/11/21 09:50:05gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$27 // $Id: G4Sphere.hh,v 1.24 2009/03/31 07:51:49 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // … … 36 36 // Class description: 37 37 // 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, 39 39 // between specified phi and theta angles 40 40 // … … 83 83 G4double pSPhi, G4double pDPhi, 84 84 G4double pSTheta, G4double pDTheta); 85 // 86 // Constructs a sphere or sphere shell section 87 // with the given name and dimensions 85 88 86 virtual ~G4Sphere() ; 87 89 ~G4Sphere(); 90 // 91 // Destructor 92 88 93 // Accessors 89 94 … … 99 104 inline void SetInnerRadius (G4double newRMin); 100 105 inline void SetOuterRadius (G4double newRmax); 101 inline void SetStartPhiAngle (G4double newSphi );106 inline void SetStartPhiAngle (G4double newSphi, G4bool trig=true); 102 107 inline void SetDeltaPhiAngle (G4double newDphi); 103 108 inline void SetStartThetaAngle(G4double newSTheta); … … 107 112 108 113 inline G4double GetCubicVolume(); 109 inlineG4double GetSurfaceArea();114 G4double GetSurfaceArea(); 110 115 111 116 void ComputeDimensions( G4VPVParameterisation* p, … … 142 147 143 148 // Visualisation functions 149 144 150 G4VisExtent GetExtent () const; 145 151 void DescribeYourselfTo(G4VGraphicsScene& scene) const; … … 150 156 151 157 G4Sphere(__void__&); 158 // 152 159 // Fake default constructor for usage restricted to direct object 153 160 // persistency for clients requiring preallocation of memory for … … 165 172 inline void SetInsideRadius(G4double newRmin); 166 173 167 pr otected:174 private: 168 175 169 176 G4ThreeVectorList* 170 177 CreateRotatedVertices(const G4AffineTransform& pTransform, 171 178 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 173 206 // Used by distanceToOut 174 207 // 175 208 enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kSTheta,kETheta}; 176 209 177 210 // used by normal 178 211 // 179 212 enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNSTheta,kNETheta}; 180 213 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 195 235 }; 196 236 -
trunk/source/geometry/solids/CSG/include/G4Sphere.icc
r1058 r1228 25 25 // 26 26 // 27 // $Id: G4Sphere.icc,v 1. 8 2008/11/21 09:50:05gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$27 // $Id: G4Sphere.icc,v 1.11 2009/05/13 11:23:00 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -------------------------------------------------------------------- … … 77 77 } 78 78 79 inline 80 void G4Sphere::Initialize() 81 { 82 fCubicVolume = 0.; 83 fSurfaceArea = 0.; 84 fpPolyhedron = 0; 85 } 86 87 inline 88 void 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 104 inline 105 void 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 120 inline 121 void 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 158 inline 159 void 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 177 inline 178 void 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 204 inline 205 void 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 79 214 inline 80 215 void G4Sphere::SetInsideRadius(G4double newRmin) 81 216 { 82 217 fRmin= newRmin; 83 fCubicVolume= 0.; 84 fSurfaceArea= 0.; 85 fpPolyhedron = 0; 218 Initialize(); 86 219 } 87 220 … … 90 223 { 91 224 fRmin= newRmin; 92 fCubicVolume= 0.; 93 fSurfaceArea= 0.; 94 fpPolyhedron = 0; 225 Initialize(); 95 226 } 96 227 … … 99 230 { 100 231 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 235 inline 236 void 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 247 inline 248 void G4Sphere::SetDeltaPhiAngle(G4double newDPhi) 249 { 250 CheckPhiAngles(fSPhi, newDPhi); 251 Initialize(); 122 252 } 123 253 … … 125 255 void G4Sphere::SetStartThetaAngle(G4double newSTheta) 126 256 { 127 fSTheta=newSTheta; 128 fCubicVolume= 0.; 129 fSurfaceArea= 0.; 130 fpPolyhedron = 0; 257 CheckThetaAngles(newSTheta, fDTheta); 258 Initialize(); 131 259 } 132 260 … … 134 262 void G4Sphere::SetDeltaThetaAngle(G4double newDTheta) 135 263 { 136 fDTheta=newDTheta; 137 fCubicVolume= 0.; 138 fSurfaceArea= 0.; 139 fpPolyhedron = 0; 264 CheckThetaAngles(fSTheta, newDTheta); 265 Initialize(); 140 266 } 141 267 … … 182 308 { 183 309 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.; } 186 312 return fCubicVolume; 187 313 } 188 189 190 inline191 G4double G4Sphere::GetSurfaceArea()192 {193 if(fSurfaceArea != 0.) {;}194 else195 {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 else215 {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 else229 {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 26 26 // 27 27 // $Id: G4Torus.hh,v 1.27 2007/05/18 07:38:00 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -
trunk/source/geometry/solids/CSG/include/G4Torus.icc
r1058 r1228 26 26 // 27 27 // $Id: G4Torus.icc,v 1.6 2006/10/19 15:33:37 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -------------------------------------------------------------------- -
trunk/source/geometry/solids/CSG/include/G4Trap.hh
r1058 r1228 26 26 // 27 27 // $Id: G4Trap.hh,v 1.17 2006/10/19 15:33:37 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -
trunk/source/geometry/solids/CSG/include/G4Trap.icc
r1058 r1228 26 26 // 27 27 // $Id: G4Trap.icc,v 1.8 2006/10/19 15:33:37 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -------------------------------------------------------------------- -
trunk/source/geometry/solids/CSG/include/G4Trd.hh
r1058 r1228 26 26 // 27 27 // $Id: G4Trd.hh,v 1.16 2006/10/19 15:33:37 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -
trunk/source/geometry/solids/CSG/include/G4Trd.icc
r1058 r1228 26 26 // 27 27 // $Id: G4Trd.icc,v 1.7 2006/10/19 15:33:37 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -------------------------------------------------------------------- -
trunk/source/geometry/solids/CSG/include/G4Tubs.hh
r1058 r1228 25 25 // 26 26 // 27 // $Id: G4Tubs.hh,v 1.2 1 2008/11/06 10:55:40gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$27 // $Id: G4Tubs.hh,v 1.22 2009/03/26 16:25:44 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // … … 86 86 // Constructs a tubs with the given name and dimensions 87 87 88 virtual~G4Tubs();88 ~G4Tubs(); 89 89 // 90 90 // Destructor … … 103 103 inline void SetOuterRadius (G4double newRMax); 104 104 inline void SetZHalfLength (G4double newDz); 105 inline void SetStartPhiAngle (G4double newSPhi );105 inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true); 106 106 inline void SetDeltaPhiAngle (G4double newDPhi); 107 107 … … 159 159 inline G4double GetDPhi() const; 160 160 161 pr otected:161 private: 162 162 163 163 G4ThreeVectorList* … … 167 167 // for G4VSolid:: ClipCrossSection and ClipBetweenSections 168 168 169 G4double fRMin, fRMax, fDz, fSPhi, fDPhi;170 G4bool fPhiFullTube;171 172 // Used by distanceToOut173 174 enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ};175 176 // Used by normal177 178 enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ};179 180 private:181 182 169 inline void Initialize(); 183 170 // 184 171 // 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 185 178 186 179 inline void InitializeTrigonometry(); … … 195 188 private: 196 189 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 197 198 G4double kRadTolerance, kAngTolerance; 198 199 // 199 200 // Radial and angular tolerances 200 201 202 G4double fRMin, fRMax, fDz, fSPhi, fDPhi; 203 // 204 // Radial and angular dimensions 205 201 206 G4double sinCPhi, cosCPhi, cosHDPhiOT, cosHDPhiIT, 202 207 sinSPhi, cosSPhi, sinEPhi, cosEPhi; 203 208 // 204 209 // Cached trigonometric values 210 211 G4bool fPhiFullTube; 212 // 213 // Flag for identification of section or full tube 205 214 }; 206 215 -
trunk/source/geometry/solids/CSG/include/G4Tubs.icc
r1058 r1228 25 25 // 26 26 // 27 // $Id: G4Tubs.icc,v 1.1 1 2008/11/06 10:55:40gcosmo Exp $28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$27 // $Id: G4Tubs.icc,v 1.14 2009/06/09 16:08:23 gcosmo Exp $ 28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // -------------------------------------------------------------------- … … 91 91 } 92 92 93 inline 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 111 inline 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 137 inline void G4Tubs::CheckPhiAngles(G4double sPhi, G4double dPhi) 138 { 139 CheckDPhiAngle(dPhi); 140 if ( (fDPhi<twopi) && (sPhi) ) { CheckSPhiAngle(sPhi); } 141 InitializeTrigonometry(); 142 } 143 93 144 inline 94 145 void G4Tubs::SetInnerRadius (G4double newRMin) … … 113 164 114 165 inline 115 void G4Tubs::SetStartPhiAngle (G4double newSPhi) 116 { 117 fSPhi= newSPhi; 118 Initialize(); 119 InitializeTrigonometry(); 166 void 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(); 120 175 } 121 176 … … 123 178 void G4Tubs::SetDeltaPhiAngle (G4double newDPhi) 124 179 { 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(); 143 182 } 144 183
Note:
See TracChangeset
for help on using the changeset viewer.
