Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Polyhedra.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// G4Polyhedra
27//
28// Class description:
29//
30// Class implementing a CSG-like type "PGON" Geant 3.21 volume,
31// inherited from class G4VCSGfaceted:
32//
33// G4Polyhedra( const G4String& name,
34// G4double phiStart, - initial phi starting angle
35// G4double phiTotal, - total phi angle
36// G4int numSide, - number sides
37// G4int numZPlanes, - number of z planes
38// const G4double zPlane[], - position of z planes
39// const G4double rInner[], - tangent distance to inner surface
40// const G4double rOuter[] ) - tangent distance to outer surface
41//
42// G4Polyhedra( const G4String& name,
43// G4double phiStart, - initial phi starting angle
44// G4double phiTotal, - total phi angle
45// G4int numSide, - number sides
46// G4int numRZ, - number corners in r,z space
47// const G4double r[], - r coordinates of these corners
48// const G4double z[] ) - z coordinates of these corners
49
50// Author: David C. Williams (UCSC), 1998 - First implementation
51// --------------------------------------------------------------------
52#ifndef G4POLYHEDRA_HH
53#define G4POLYHEDRA_HH
54
55#include "G4GeomTypes.hh"
56
57#if defined(G4GEOM_USE_USOLIDS)
58#define G4GEOM_USE_UPOLYHEDRA 1
59#endif
60
61#if defined(G4GEOM_USE_UPOLYHEDRA)
62 #define G4UPolyhedra G4Polyhedra
63 #include "G4UPolyhedra.hh"
64#else
65
66#include "G4VCSGfaceted.hh"
67#include "G4PolyhedraSide.hh"
69#include "G4Polyhedron.hh"
70
73
74/**
75 * @brief G4Polyhedra represents a composed closed polyhedra (PGON) made of
76 * planar sizes along the Z axis, with or without cut in Phi.
77 */
78
80{
81 public:
82
83 /**
84 * Constructs a polyhedra, given its parameters.
85 * @param[in] name The solid name.
86 * @param[in] phiStart Initial Phi starting angle.
87 * @param[in] phiTotal Total Phi angle.
88 * @param[in] numSide Number of sides.
89 * @param[in] numZPlanes Number of Z planes.
90 * @param[in] zPlane Position of Z planes.
91 * @param[in] rInner Tangent distance to inner surface.
92 * @param[in] rOuter Tangent distance to outer surface.
93 */
94 G4Polyhedra(const G4String& name,
95 G4double phiStart, // initial phi starting angle
96 G4double phiTotal, // total phi angle
97 G4int numSide, // number sides
98 G4int numZPlanes, // number of z planes
99 const G4double zPlane[], // position of z planes
100 const G4double rInner[], // tangent distance to inner surface
101 const G4double rOuter[] ); // tangent distance to outer surface
102
103 /**
104 * Alternative constructor of a polyhedra, given corners coordinates.
105 * @param[in] name The solid name.
106 * @param[in] phiStart Initial Phi starting angle.
107 * @param[in] phiTotal Total Phi angle.
108 * @param[in] numSide Number of sides.
109 * @param[in] numRZ Number of corners in r,Z space.
110 * @param[in] r r coordinates of corners.
111 * @param[in] z Z coordinates of corners.
112 */
113 G4Polyhedra(const G4String& name,
114 G4double phiStart, // initial phi starting angle
115 G4double phiTotal, // total phi angle
116 G4int numSide, // number sides
117 G4int numRZ, // number corners in r,z space
118 const G4double r[], // r coordinates of these corners
119 const G4double z[] ); // z coordinates of these corners
120
121 /**
122 * Destructor.
123 */
124 ~G4Polyhedra() override;
125
126 /**
127 * Accessors.
128 */
129 inline G4int GetNumSide() const;
130 inline G4double GetStartPhi() const;
131 inline G4double GetEndPhi() const;
132 inline G4double GetSinStartPhi() const;
133 inline G4double GetCosStartPhi() const;
134 inline G4double GetSinEndPhi() const;
135 inline G4double GetCosEndPhi() const;
136 inline G4bool IsOpen() const;
137 inline G4bool IsGeneric() const;
138 inline G4int GetNumRZCorner() const;
139 inline G4PolyhedraSideRZ GetCorner( const G4int index ) const;
140
141 /**
142 * Returns internal scaled parameters.
143 */
145
146 /**
147 * Sets internal parameters. Parameters 'Rmin' and 'Rmax' in input must
148 * be scaled first by a factor computed as 'cos(0.5*phiTotal/theNumSide)',
149 * if not already scaled.
150 */
152
153 /**
154 * Concrete implementations of the expected query interfaces for
155 * solids, as defined in G4VSolid. Remaining functions are concretely
156 * defined in the base class G4VCSGfaceted.
157 */
158 EInside Inside( const G4ThreeVector& p ) const override;
160 const G4ThreeVector& v ) const override;
161 G4double DistanceToIn( const G4ThreeVector& p ) const override;
162
163 /**
164 * Computes the bounding limits of the solid.
165 * @param[out] pMin The minimum bounding limit point.
166 * @param[out] pMax The maximum bounding limit point.
167 */
168 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
169
170 /**
171 * Calculates the minimum and maximum extent of the solid, when under the
172 * specified transform, and within the specified limits.
173 * @param[in] pAxis The axis along which compute the extent.
174 * @param[in] pVoxelLimit The limiting space dictated by voxels.
175 * @param[in] pTransform The internal transformation applied to the solid.
176 * @param[out] pMin The minimum extent value.
177 * @param[out] pMax The maximum extent value.
178 * @returns True if the solid is intersected by the extent region.
179 */
180 G4bool CalculateExtent(const EAxis pAxis,
181 const G4VoxelLimits& pVoxelLimit,
182 const G4AffineTransform& pTransform,
183 G4double& pmin, G4double& pmax) const override;
184
185 /**
186 * Dispatch method for parameterisation replication mechanism and
187 * dimension computation.
188 */
190 const G4int n,
191 const G4VPhysicalVolume* pRep) override;
192
193 /**
194 * Returns the type ID, "G4Polyhedra" of the solid.
195 */
196 G4GeometryType GetEntityType() const override;
197
198 /**
199 * Returns true as the solid has only planar faces.
200 */
201 G4bool IsFaceted () const override;
202
203 /**
204 * Makes a clone of the object for use in multi-treading.
205 * @returns A pointer to the new cloned allocated solid.
206 */
207 G4VSolid* Clone() const override;
208
209 /**
210 * Returning an estimation of the solid volume (capacity) and
211 * surface area, in internal units.
212 */
213 G4double GetCubicVolume() override;
214 G4double GetSurfaceArea() override;
215
216 /**
217 * Returns a random point located and uniformly distributed on the
218 * surface of the solid.
219 */
220 G4ThreeVector GetPointOnSurface() const override;
221
222 /**
223 * Streams the object contents to an output stream.
224 */
225 std::ostream& StreamInfo( std::ostream& os ) const override;
226
227 /**
228 * Returns a pointer to a generated polyhedron used for visualisation.
229 */
230 G4Polyhedron* CreatePolyhedron() const override;
231
232 /**
233 * Clears all parameters and rebuild the shape, for use in divisions.
234 */
235 G4bool Reset();
236
237 /**
238 * Fake default constructor for usage restricted to direct object
239 * persistency for clients requiring preallocation of memory for
240 * persistifiable objects.
241 */
242 G4Polyhedra(__void__&);
243
244 /**
245 * Copy constructor and assignment operator.
246 */
247 G4Polyhedra( const G4Polyhedra& source );
248 G4Polyhedra& operator=( const G4Polyhedra& source );
249
250 private:
251
252 /**
253 * Sets internal parameters for the generic constructor.
254 */
256
257 /**
258 * Generates the shape and is called by each constructor,
259 * after the conversion of the arguments.
260 */
261 void Create( G4double phiStart, // initial phi starting angle
262 G4double phiTotal, // total phi angle
263 G4int numSide, // number sides
264 G4ReduciblePolygon* rz ); // rz coordinates
265
266 /**
267 * Copy parameters from other solid or reset them.
268 * Used in copy constructor and assignment operator.
269 */
270 void CopyStuff( const G4Polyhedra& source );
271 void DeleteStuff();
272
273 /**
274 * Sets the vector of surface elements. Auxiliary method used for
275 * sampling random points on surface.
276 */
277 void SetSurfaceElements() const;
278
279 private:
280
281 G4int numSide = 0; // Number of sides
282 G4double startPhi; // Starting phi value (0 < phiStart < 2pi)
283 G4double endPhi; // end phi value (0 < endPhi-phiStart < 2pi)
284 G4bool phiIsOpen = false; // true if there is a phi segment
285 G4bool genericPgon = false; // true if created through 2nd generic ctor
286 G4int numCorner = 0; // number RZ points
287 G4PolyhedraSideRZ* corners = nullptr; // our corners
288 G4PolyhedraHistorical* original_parameters = nullptr; // original input pars
289
290 G4EnclosingCylinder* enclosingCylinder = nullptr;
291
292 struct surface_element { G4double area=0.; G4int i0=0, i1=0, i2=0; };
293 mutable std::vector<surface_element>* fElements = nullptr;
294};
295
296#include "G4Polyhedra.icc"
297
298#endif
299
300#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...
G4EnclosingCylinder is a utility class defining an envelope for quickly deciding if a point is clearl...
G4PolyhedraHistorical is a data structure for use in G4Polyhedra.
EInside Inside(const G4ThreeVector &p) const override
G4Polyhedra & operator=(const G4Polyhedra &source)
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
G4GeometryType GetEntityType() const override
G4double GetSurfaceArea() override
G4Polyhedra(const G4String &name, G4double phiStart, G4double phiTotal, G4int numSide, G4int numZPlanes, const G4double zPlane[], const G4double rInner[], const G4double rOuter[])
G4int GetNumRZCorner() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const override
G4ThreeVector GetPointOnSurface() const override
G4double GetSinStartPhi() const
G4bool IsOpen() const
G4double GetEndPhi() const
void SetOriginalParameters(G4PolyhedraHistorical *pars)
G4VSolid * Clone() const override
~G4Polyhedra() override
G4Polyhedron * CreatePolyhedron() const override
G4int GetNumSide() const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
G4bool IsFaceted() const override
G4PolyhedraHistorical * GetOriginalParameters() const
G4PolyhedraSideRZ GetCorner(const G4int index) const
std::ostream & StreamInfo(std::ostream &os) const override
G4bool Reset()
G4double GetCosEndPhi() const
G4double GetStartPhi() const
G4double GetCosStartPhi() const
G4bool IsGeneric() const
G4double GetSinEndPhi() const
G4double GetCubicVolume() override
G4ReduciblePolygon is a utility class used to specify, test, reduce, and/or otherwise manipulate a 2D...
G4VCSGfaceted(const G4String &name)
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