Geant4-11
G4Cons.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
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. *
10// * *
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. *
17// * *
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// ********************************************************************
25//
26// G4Cons
27//
28// Class description:
29//
30// A G4Cons is, in the general case, a Phi segment of a cone, with
31// half-length fDz, inner and outer radii specified at -fDz and +fDz.
32// The Phi segment is described by a starting fSPhi angle, and the
33// +fDPhi delta angle for the shape.
34// If the delta angle is >=2*pi, the shape is treated as continuous
35// in Phi
36//
37// Member Data:
38//
39// fRmin1 inside radius at -fDz
40// fRmin2 inside radius at +fDz
41// fRmax1 outside radius at -fDz
42// fRmax2 outside radius at +fDz
43// fDz half length in z
44//
45// fSPhi starting angle of the segment in radians
46// fDPhi delta angle of the segment in radians
47//
48// fPhiFullCone Boolean variable used for indicate the Phi Section
49//
50// Note:
51// Internally fSPhi & fDPhi are adjusted so that fDPhi<=2PI,
52// and fDPhi+fSPhi<=2PI. This enables simpler comparisons to be
53// made with (say) Phi of a point.
54
55// 19.3.94 P.Kent: Old C++ code converted to tolerant geometry
56// 13.9.96 V.Grichine: Final modifications to commit
57// --------------------------------------------------------------------
58#ifndef G4CONS_HH
59#define G4CONS_HH
60
61#include "G4GeomTypes.hh"
62
63#if defined(G4GEOM_USE_USOLIDS)
64#define G4GEOM_USE_UCONS 1
65#endif
66
67#if defined(G4GEOM_USE_UCONS)
68 #define G4UCons G4Cons
69 #include "G4UCons.hh"
70#else
71
73
74#include "G4CSGSolid.hh"
75#include "G4Polyhedron.hh"
76
77class G4Cons : public G4CSGSolid
78{
79 public: // with description
80
81 G4Cons(const G4String& pName,
82 G4double pRmin1, G4double pRmax1,
83 G4double pRmin2, G4double pRmax2,
84 G4double pDz,
85 G4double pSPhi, G4double pDPhi);
86 //
87 // Constructs a cone with the given name and dimensions
88
89 ~G4Cons() ;
90 //
91 // Destructor
92
93 // Accessors
94
99 inline G4double GetZHalfLength() const;
102 inline G4double GetSinStartPhi() const;
103 inline G4double GetCosStartPhi() const;
104 inline G4double GetSinEndPhi() const;
105 inline G4double GetCosEndPhi() const;
106
107 // Modifiers
108
109 inline void SetInnerRadiusMinusZ (G4double Rmin1 );
110 inline void SetOuterRadiusMinusZ (G4double Rmax1 );
111 inline void SetInnerRadiusPlusZ (G4double Rmin2 );
112 inline void SetOuterRadiusPlusZ (G4double Rmax2 );
113 inline void SetZHalfLength (G4double newDz );
114 inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true);
115 inline void SetDeltaPhiAngle (G4double newDPhi);
116
117 // Other methods for solid
118
121
123 const G4int n,
124 const G4VPhysicalVolume* pRep );
125
127
128 G4bool CalculateExtent( const EAxis pAxis,
129 const G4VoxelLimits& pVoxelLimit,
130 const G4AffineTransform& pTransform,
131 G4double& pMin, G4double& pMax ) const;
132
133 EInside Inside( const G4ThreeVector& p ) const;
134
135 G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const;
136
138 const G4ThreeVector& v) const;
139 G4double DistanceToIn (const G4ThreeVector& p) const;
141 const G4ThreeVector& v,
142 const G4bool calcNorm = false,
143 G4bool* validNorm = nullptr,
144 G4ThreeVector* n = nullptr) const;
145 G4double DistanceToOut(const G4ThreeVector& p) const;
146
148
150
151 G4VSolid* Clone() const;
152
153 std::ostream& StreamInfo(std::ostream& os) const;
154
155 // Visualisation functions
156
157 void DescribeYourselfTo( G4VGraphicsScene& scene ) const;
159
160 public: // without description
161
162 G4Cons(__void__&);
163 //
164 // Fake default constructor for usage restricted to direct object
165 // persistency for clients requiring preallocation of memory for
166 // persistifiable objects.
167
168 G4Cons(const G4Cons& rhs);
169 G4Cons& operator=(const G4Cons& rhs);
170 // Copy constructor and assignment operator.
171
172 private:
173
174 inline void Initialize();
175 //
176 // Reset relevant values to zero
177
178 inline void CheckSPhiAngle(G4double sPhi);
179 inline void CheckDPhiAngle(G4double dPhi);
180 inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
181 //
182 // Reset relevant flags and angle values
183
185 //
186 // Recompute relevant trigonometric values and cache them
187
189 //
190 // Algorithm for SurfaceNormal() following the original
191 // specification for points not on the surface
192
193 private:
194
195 // Used by distanceToOut
196 //
198
199 // used by normal
200 //
202
204 //
205 // Radial and angular tolerances
206
208 //
209 // Radial and angular dimensions
210
213 //
214 // Cached trigonometric values
215
217 //
218 // Flag for identification of section or full cone
219
221 //
222 // Cached half tolerance values
223};
224
225#include "G4Cons.icc"
226
227#endif
228
229#endif
static const G4double pMax
static const G4double pMin
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
Definition: G4Cons.hh:78
G4VSolid * Clone() const
Definition: G4Cons.cc:2103
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
Definition: G4Cons.cc:304
G4double GetOuterRadiusPlusZ() const
G4double GetCosStartPhi() const
G4double fSPhi
Definition: G4Cons.hh:207
G4double cosSPhi
Definition: G4Cons.hh:212
void SetInnerRadiusPlusZ(G4double Rmin2)
void SetZHalfLength(G4double newDz)
G4double GetStartPhiAngle() const
G4double fDPhi
Definition: G4Cons.hh:207
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4Cons.cc:250
G4double fDz
Definition: G4Cons.hh:207
G4double GetDeltaPhiAngle() const
void SetStartPhiAngle(G4double newSPhi, G4bool trig=true)
G4double kAngTolerance
Definition: G4Cons.hh:203
G4double halfRadTolerance
Definition: G4Cons.hh:220
void DescribeYourselfTo(G4VGraphicsScene &scene) const
Definition: G4Cons.cc:2225
void SetOuterRadiusMinusZ(G4double Rmax1)
G4double GetInnerRadiusMinusZ() const
void SetOuterRadiusPlusZ(G4double Rmax2)
G4double cosHDPhiIT
Definition: G4Cons.hh:211
void CheckPhiAngles(G4double sPhi, G4double dPhi)
void CheckDPhiAngle(G4double dPhi)
G4double cosHDPhi
Definition: G4Cons.hh:211
void Initialize()
G4double cosHDPhiOT
Definition: G4Cons.hh:211
G4double GetInnerRadiusPlusZ() const
void InitializeTrigonometry()
G4GeometryType GetEntityType() const
Definition: G4Cons.cc:2094
G4double GetSurfaceArea()
@ kMZ
Definition: G4Cons.hh:197
@ kSPhi
Definition: G4Cons.hh:197
@ kRMax
Definition: G4Cons.hh:197
@ kEPhi
Definition: G4Cons.hh:197
@ kNull
Definition: G4Cons.hh:197
@ kRMin
Definition: G4Cons.hh:197
@ kPZ
Definition: G4Cons.hh:197
G4double sinEPhi
Definition: G4Cons.hh:212
G4double cosCPhi
Definition: G4Cons.hh:211
void SetDeltaPhiAngle(G4double newDPhi)
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Definition: G4Cons.cc:261
~G4Cons()
Definition: G4Cons.cc:136
G4double fRmax2
Definition: G4Cons.hh:207
G4bool fPhiFullCone
Definition: G4Cons.hh:216
void SetInnerRadiusMinusZ(G4double Rmin1)
G4double GetCosEndPhi() const
G4Polyhedron * CreatePolyhedron() const
Definition: G4Cons.cc:2230
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
Definition: G4Cons.cc:523
G4double halfAngTolerance
Definition: G4Cons.hh:220
G4double GetCubicVolume()
G4Cons(const G4String &pName, G4double pRmin1, G4double pRmax1, G4double pRmin2, G4double pRmax2, G4double pDz, G4double pSPhi, G4double pDPhi)
Definition: G4Cons.cc:72
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
Definition: G4Cons.cc:419
G4double GetOuterRadiusMinusZ() const
G4double GetSinEndPhi() const
G4Cons & operator=(const G4Cons &rhs)
Definition: G4Cons.cc:162
G4double GetSinStartPhi() const
EInside Inside(const G4ThreeVector &p) const
Definition: G4Cons.cc:195
G4ThreeVector GetPointOnSurface() const
Definition: G4Cons.cc:2139
G4double GetZHalfLength() const
G4double kRadTolerance
Definition: G4Cons.hh:203
void CheckSPhiAngle(G4double sPhi)
G4double sinCPhi
Definition: G4Cons.hh:211
G4double sinSPhi
Definition: G4Cons.hh:212
G4double fRmin1
Definition: G4Cons.hh:207
@ kNEPhi
Definition: G4Cons.hh:201
@ kNRMin
Definition: G4Cons.hh:201
@ kNSPhi
Definition: G4Cons.hh:201
@ kNRMax
Definition: G4Cons.hh:201
@ kNZ
Definition: G4Cons.hh:201
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Cons.cc:661
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const
Definition: G4Cons.cc:1393
G4double halfCarTolerance
Definition: G4Cons.hh:220
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4Cons.cc:2112
G4double fRmin2
Definition: G4Cons.hh:207
G4double fRmax1
Definition: G4Cons.hh:207
G4double cosEPhi
Definition: G4Cons.hh:212
EAxis
Definition: geomdefs.hh:54
EInside
Definition: geomdefs.hh:67