Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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// Author: Paul Kent (CERN), 19.3.1994 - Code converted to tolerant geometry
56// --------------------------------------------------------------------
57#ifndef G4CONS_HH
58#define G4CONS_HH
59
60#include "G4GeomTypes.hh"
61
62#if defined(G4GEOM_USE_USOLIDS)
63#define G4GEOM_USE_UCONS 1
64#endif
65
66#if defined(G4GEOM_USE_UCONS)
67 #define G4UCons G4Cons
68 #include "G4UCons.hh"
69#else
70
72
73#include "G4CSGSolid.hh"
74#include "G4Polyhedron.hh"
75
76/**
77 * @brief G4Cons is, in the general case, a Phi segment of a cone, with
78 * half-length fDz, inner and outer radii specified at -fDz and +fDz.
79 * The Phi segment is described by a starting fSPhi angle, and the
80 * +fDPhi delta angle for the shape.
81 * If the delta angle is >=2*pi, the shape is treated as continuous in Phi.
82 */
83
84class G4Cons : public G4CSGSolid
85{
86 public:
87
88 /**
89 * Constructs a cone with the given name and dimensions.
90 * @param[in] pName The name of the solid.
91 * @param[in] pRmin1 Inside radius at -fDz.
92 * @param[in] pRmax1 Outside radius at -fDz
93 * @param[in] pRmin2 Inside radius at +fDz.
94 * @param[in] pRmax2 Outside radius at +fDz
95 * @param[in] pDZ Half length in Z.
96 * @param[in] pSPhi Starting angle of the segment in radians.
97 * @param[in] pDPhi Delta angle of the segment in radians.
98 */
99 G4Cons(const G4String& pName,
100 G4double pRmin1, G4double pRmax1,
101 G4double pRmin2, G4double pRmax2,
102 G4double pDz,
103 G4double pSPhi, G4double pDPhi);
104
105 /**
106 * Default destructor.
107 */
108 ~G4Cons() override = default;
109
110 /**
111 * Accessors.
112 */
117 inline G4double GetZHalfLength() const;
120 inline G4double GetSinStartPhi() const;
121 inline G4double GetCosStartPhi() const;
122 inline G4double GetSinEndPhi() const;
123 inline G4double GetCosEndPhi() const;
124
125 /**
126 * Modifiers.
127 */
128 inline void SetInnerRadiusMinusZ (G4double Rmin1 );
129 inline void SetOuterRadiusMinusZ (G4double Rmax1 );
130 inline void SetInnerRadiusPlusZ (G4double Rmin2 );
131 inline void SetOuterRadiusPlusZ (G4double Rmax2 );
132 inline void SetZHalfLength (G4double newDz );
133 inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true);
134 inline void SetDeltaPhiAngle (G4double newDPhi);
135
136 /**
137 * Returning an estimation of the solid volume (capacity) and
138 * surface area, in internal units.
139 */
140 G4double GetCubicVolume() override;
141 G4double GetSurfaceArea() override;
142
143 /**
144 * Dispatch method for parameterisation replication mechanism and
145 * dimension computation.
146 */
148 const G4int n,
149 const G4VPhysicalVolume* pRep) override;
150
151 /**
152 * Computes the bounding limits of the solid.
153 * @param[out] pMin The minimum bounding limit point.
154 * @param[out] pMax The maximum bounding limit point.
155 */
156 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
157
158 /**
159 * Calculates the minimum and maximum extent of the solid, when under the
160 * specified transform, and within the specified limits.
161 * @param[in] pAxis The axis along which compute the extent.
162 * @param[in] pVoxelLimit The limiting space dictated by voxels.
163 * @param[in] pTransform The internal transformation applied to the solid.
164 * @param[out] pMin The minimum extent value.
165 * @param[out] pMax The maximum extent value.
166 * @returns True if the solid is intersected by the extent region.
167 */
168 G4bool CalculateExtent(const EAxis pAxis,
169 const G4VoxelLimits& pVoxelLimit,
170 const G4AffineTransform& pTransform,
171 G4double& pMin, G4double& pMax) const override;
172
173 /**
174 * Concrete implementations of the expected query interfaces for
175 * solids, as defined in the base class G4VSolid.
176 */
177 EInside Inside( const G4ThreeVector& p ) const override;
178 G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
180 const G4ThreeVector& v) const override;
181 G4double DistanceToIn (const G4ThreeVector& p) const override;
183 const G4ThreeVector& v,
184 const G4bool calcNorm = false,
185 G4bool* validNorm = nullptr,
186 G4ThreeVector* n = nullptr) const override;
187 G4double DistanceToOut(const G4ThreeVector& p) const override;
188
189 /**
190 * Returns the type ID, "G4Cons" of the solid.
191 */
192 G4GeometryType GetEntityType() const override;
193
194 /**
195 * Returns a random point located and uniformly distributed on the
196 * surface of the solid.
197 */
198 G4ThreeVector GetPointOnSurface() const override;
199
200 /**
201 * Makes a clone of the object for use in multi-treading.
202 * @returns A pointer to the new cloned allocated solid.
203 */
204 G4VSolid* Clone() const override;
205
206 /**
207 * Streams the object contents to an output stream.
208 */
209 std::ostream& StreamInfo(std::ostream& os) const override;
210
211 /**
212 * Methods for creating graphical representations (i.e. for visualisation).
213 */
214 void DescribeYourselfTo( G4VGraphicsScene& scene ) const override;
215 G4Polyhedron* CreatePolyhedron() const override;
216
217 /**
218 * Fake default constructor for usage restricted to direct object
219 * persistency for clients requiring preallocation of memory for
220 * persistifiable objects.
221 */
222 G4Cons(__void__&);
223
224 /**
225 * Copy constructor and assignment operator.
226 */
227 G4Cons(const G4Cons& rhs) = default;
228 G4Cons& operator=(const G4Cons& rhs);
229
230 private:
231
232 /**
233 * Resets relevant values to zero.
234 */
235 inline void Initialize();
236
237 /**
238 * Reset relevant flags and angle values.
239 */
240 inline void CheckSPhiAngle(G4double sPhi);
241 inline void CheckDPhiAngle(G4double dPhi);
242 inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
243
244 /**
245 * Recomputes relevant trigonometric values and cache them.
246 */
247 inline void InitializeTrigonometry();
248
249 /**
250 * Algorithm for SurfaceNormal() following the original specification
251 * for points not on the surface.
252 */
253 G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
254
255 private:
256
257 /** Radial and angular tolerances. */
258 G4double kRadTolerance, kAngTolerance;
259
260 /** Radial and angular dimensions. */
261 G4double fRmin1, fRmin2, fRmax1, fRmax2, fDz, fSPhi, fDPhi;
262
263 /** Cached trigonometric values. */
264 G4double sinCPhi, cosCPhi, cosHDPhi, cosHDPhiOT, cosHDPhiIT,
265 sinSPhi, cosSPhi, sinEPhi, cosEPhi;
266
267 /** Flag for identification of section or full cone. */
268 G4bool fPhiFullCone = false;
269
270 /** Cached half tolerance values. */
271 G4double halfCarTolerance, halfRadTolerance, halfAngTolerance;
272};
273
274#include "G4Cons.icc"
275
276#endif
277
278#endif
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4String G4GeometryType
Definition G4VSolid.hh:70
G4AffineTransform is a class for geometric affine transformations. It supports efficient arbitrary ro...
G4CSGSolid(const G4String &pName)
Definition G4CSGSolid.cc:49
G4double GetOuterRadiusPlusZ() const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
Definition G4Cons.cc:230
G4double GetCosStartPhi() const
G4ThreeVector GetPointOnSurface() const override
Definition G4Cons.cc:2107
void SetInnerRadiusPlusZ(G4double Rmin2)
void SetZHalfLength(G4double newDz)
G4double GetStartPhiAngle() const
EInside Inside(const G4ThreeVector &p) const override
Definition G4Cons.cc:175
G4double GetDeltaPhiAngle() const
void SetStartPhiAngle(G4double newSPhi, G4bool trig=true)
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
Definition G4Cons.cc:241
void SetOuterRadiusMinusZ(G4double Rmax1)
G4double GetInnerRadiusMinusZ() const
void SetOuterRadiusPlusZ(G4double Rmax2)
G4double GetCubicVolume() override
Definition G4Cons.cc:2182
G4Polyhedron * CreatePolyhedron() const override
Definition G4Cons.cc:2239
G4double GetInnerRadiusPlusZ() const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
Definition G4Cons.cc:1368
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
Definition G4Cons.cc:405
~G4Cons() override=default
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
Definition G4Cons.cc:647
void SetDeltaPhiAngle(G4double newDPhi)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
Definition G4Cons.cc:284
void SetInnerRadiusMinusZ(G4double Rmin1)
G4double GetCosEndPhi() const
G4VSolid * Clone() const override
Definition G4Cons.cc:2073
G4Cons(const G4String &pName, G4double pRmin1, G4double pRmax1, G4double pRmin2, G4double pRmax2, G4double pDz, G4double pSPhi, G4double pDPhi)
Definition G4Cons.cc:83
G4double GetOuterRadiusMinusZ() const
G4double GetSinEndPhi() const
std::ostream & StreamInfo(std::ostream &os) const override
Definition G4Cons.cc:2082
G4Cons & operator=(const G4Cons &rhs)
Definition G4Cons.cc:142
G4double GetSinStartPhi() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
Definition G4Cons.cc:2234
G4double GetZHalfLength() const
G4Cons(const G4Cons &rhs)=default
G4double GetSurfaceArea() override
Definition G4Cons.cc:2205
G4GeometryType GetEntityType() const override
Definition G4Cons.cc:2064
G4VPVParameterisation ia an abstract base class for Parameterisation, able to compute the transformat...
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VSolid(const G4String &name)
Definition G4VSolid.cc:59
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...
EAxis
Definition geomdefs.hh:54
EInside
Definition geomdefs.hh:67