00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 #ifndef G4Sphere_HH
00070 #define G4Sphere_HH
00071
00072 #include <CLHEP/Units/PhysicalConstants.h>
00073 #include "G4CSGSolid.hh"
00074
00075 class G4VisExtent;
00076
00077 class G4Sphere : public G4CSGSolid
00078 {
00079 public:
00080
00081 G4Sphere(const G4String& pName,
00082 G4double pRmin, G4double pRmax,
00083 G4double pSPhi, G4double pDPhi,
00084 G4double pSTheta, G4double pDTheta);
00085
00086
00087
00088
00089 ~G4Sphere();
00090
00091
00092
00093
00094
00095 inline G4double GetInnerRadius () const;
00096 inline G4double GetOuterRadius () const;
00097 inline G4double GetStartPhiAngle () const;
00098 inline G4double GetDeltaPhiAngle () const;
00099 inline G4double GetStartThetaAngle() const;
00100 inline G4double GetDeltaThetaAngle() const;
00101
00102
00103
00104 inline void SetInnerRadius (G4double newRMin);
00105 inline void SetOuterRadius (G4double newRmax);
00106 inline void SetStartPhiAngle (G4double newSphi, G4bool trig=true);
00107 inline void SetDeltaPhiAngle (G4double newDphi);
00108 inline void SetStartThetaAngle(G4double newSTheta);
00109 inline void SetDeltaThetaAngle(G4double newDTheta);
00110
00111
00112
00113 inline G4double GetCubicVolume();
00114 G4double GetSurfaceArea();
00115
00116 void ComputeDimensions( G4VPVParameterisation* p,
00117 const G4int n,
00118 const G4VPhysicalVolume* pRep);
00119
00120 G4bool CalculateExtent(const EAxis pAxis,
00121 const G4VoxelLimits& pVoxelLimit,
00122 const G4AffineTransform& pTransform,
00123 G4double& pmin, G4double& pmax) const;
00124
00125 EInside Inside(const G4ThreeVector& p) const;
00126
00127 G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
00128
00129 G4double DistanceToIn(const G4ThreeVector& p,
00130 const G4ThreeVector& v) const;
00131
00132 G4double DistanceToIn(const G4ThreeVector& p) const;
00133
00134 G4double DistanceToOut(const G4ThreeVector& p,
00135 const G4ThreeVector& v,
00136 const G4bool calcNorm=G4bool(false),
00137 G4bool *validNorm=0,
00138 G4ThreeVector *n=0) const;
00139
00140 G4double DistanceToOut(const G4ThreeVector& p) const;
00141
00142 G4GeometryType GetEntityType() const;
00143
00144 G4ThreeVector GetPointOnSurface() const;
00145
00146 G4VSolid* Clone() const;
00147
00148 std::ostream& StreamInfo(std::ostream& os) const;
00149
00150
00151
00152 G4VisExtent GetExtent () const;
00153 void DescribeYourselfTo(G4VGraphicsScene& scene) const;
00154 G4Polyhedron* CreatePolyhedron() const;
00155 G4NURBS* CreateNURBS() const;
00156
00157 public:
00158
00159 G4Sphere(__void__&);
00160
00161
00162
00163
00164
00165 G4Sphere(const G4Sphere& rhs);
00166 G4Sphere& operator=(const G4Sphere& rhs);
00167
00168
00169
00170
00171 inline G4double GetRmin() const;
00172 inline G4double GetRmax() const;
00173 inline G4double GetSPhi() const;
00174 inline G4double GetDPhi() const;
00175 inline G4double GetSTheta() const;
00176 inline G4double GetDTheta() const;
00177 inline G4double GetInsideRadius() const;
00178 inline void SetInsideRadius(G4double newRmin);
00179
00180 private:
00181
00182 G4ThreeVectorList*
00183 CreateRotatedVertices(const G4AffineTransform& pTransform,
00184 G4int& noPolygonVertices) const;
00185
00186
00187
00188
00189 inline void Initialize();
00190
00191
00192
00193 inline void CheckThetaAngles(G4double sTheta, G4double dTheta);
00194 inline void CheckSPhiAngle(G4double sPhi);
00195 inline void CheckDPhiAngle(G4double dPhi);
00196 inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
00197
00198
00199
00200 inline void InitializePhiTrigonometry();
00201 inline void InitializeThetaTrigonometry();
00202
00203
00204
00205 G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p) const;
00206
00207
00208
00209
00210 private:
00211
00212
00213
00214 enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kSTheta,kETheta};
00215
00216
00217
00218 enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNSTheta,kNETheta};
00219
00220 G4double fRminTolerance, fRmaxTolerance, kAngTolerance,
00221 kRadTolerance, fEpsilon;
00222
00223
00224
00225 G4double fRmin, fRmax, fSPhi, fDPhi, fSTheta, fDTheta;
00226
00227
00228
00229 G4double sinCPhi, cosCPhi, cosHDPhiOT, cosHDPhiIT,
00230 sinSPhi, cosSPhi, sinEPhi, cosEPhi, hDPhi, cPhi, ePhi;
00231
00232
00233
00234 G4double sinSTheta, cosSTheta, sinETheta, cosETheta,
00235 tanSTheta, tanSTheta2, tanETheta, tanETheta2, eTheta;
00236
00237
00238
00239 G4bool fFullPhiSphere, fFullThetaSphere, fFullSphere;
00240
00241
00242 };
00243
00244 #include "G4Sphere.icc"
00245
00246 #endif