Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UnionSolid.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// G4UnionSolid
27//
28// Class description:
29//
30// Class for description of union of two solids.
31
32// Author: Vladimir Grichine (CERN), 12.09.1998 - Created
33// --------------------------------------------------------------------
34#ifndef G4UNIONSOLID_HH
35#define G4UNIONSOLID_HH
36
37#include "G4BooleanSolid.hh"
38#include "G4VSolid.hh"
39
40#include "G4RotationMatrix.hh"
41#include "G4ThreeVector.hh"
42#include "G4Transform3D.hh"
43#include "G4AffineTransform.hh"
44
45/**
46 * @brief G4UnionSolid is a solid describing the Boolean union of two solids.
47 */
48
50{
51 public:
52
53 /**
54 * Constructor of a Boolean union between two solids with no
55 * displacement.
56 * @param[in] pName The name of the Boolean composition.
57 * @param[in] pSolidA Pointer to the first reference solid.
58 * @param[in] pSolidB Pointer to the second solid to form the composition.
59 */
60 G4UnionSolid( const G4String& pName,
61 G4VSolid* pSolidA ,
62 G4VSolid* pSolidB ) ;
63
64 /**
65 * Constructor of a Boolean union between two solids with rotation
66 * and translation, used to transform the coordinate system of the second
67 * solid to the coordinate system of the first solid.
68 * @param[in] pName The name of the Boolean composition.
69 * @param[in] pSolidA Pointer to the first reference solid.
70 * @param[in] pSolidB Pointer to the second solid to form the composition.
71 * @param[in] rotMatrix Pointer to the rotation vector.
72 * @param[in] transVector The translation vector.
73 */
74 G4UnionSolid( const G4String& pName,
75 G4VSolid* pSolidA ,
76 G4VSolid* pSolidB ,
77 G4RotationMatrix* rotMatrix,
78 const G4ThreeVector& transVector ) ;
79
80 /**
81 * Constructor of a Boolean union between two solids with a
82 * transformation that moves the second solid from its desired position
83 * to its standard position.
84 * @param[in] pName The name of the Boolean composition.
85 * @param[in] pSolidA Pointer to the first reference solid.
86 * @param[in] pSolidB Pointer to the second solid to form the composition.
87 * @param[in] transform The composed 3D transformation.
88 */
89 G4UnionSolid( const G4String& pName,
90 G4VSolid* pSolidA ,
91 G4VSolid* pSolidB ,
92 const G4Transform3D& transform ) ;
93
94 /**
95 * Default destructor.
96 */
97 ~G4UnionSolid() override = default ;
98
99 /**
100 * Fake default constructor for usage restricted to direct object
101 * persistency for clients requiring preallocation of memory for
102 * persistifiable objects.
103 */
104 G4UnionSolid(__void__&);
105
106 /**
107 * Copy constructor and assignment operator.
108 */
109 G4UnionSolid(const G4UnionSolid& rhs);
111
112 /**
113 * Returns the type ID, "G4UnionSolid" of the solid.
114 */
115 G4GeometryType GetEntityType() const override ;
116
117 /**
118 * Makes a clone of the object for use in multi-treading.
119 * @returns A pointer to the new cloned allocated solid.
120 */
121 G4VSolid* Clone() const override;
122
123 /**
124 * Computes the bounding limits of the solid.
125 * @param[out] pMin The minimum bounding limit point.
126 * @param[out] pMax The maximum bounding limit point.
127 */
128 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
129
130 /**
131 * Calculates the minimum and maximum extent of the solid, when under the
132 * specified transform, and within the specified limits.
133 * @param[in] pAxis The axis along which compute the extent.
134 * @param[in] pVoxelLimit The limiting space dictated by voxels.
135 * @param[in] pTransform The internal transformation applied to the solid.
136 * @param[out] pMin The minimum extent value.
137 * @param[out] pMax The maximum extent value.
138 * @returns True if the solid is intersected by the extent region.
139 */
140 G4bool CalculateExtent( const EAxis pAxis,
141 const G4VoxelLimits& pVoxelLimit,
142 const G4AffineTransform& pTransform,
143 G4double& pMin, G4double& pMax ) const override ;
144
145 /**
146 * Returns if the given point "p" is inside or not the solid.
147 */
148 EInside Inside( const G4ThreeVector& p ) const override ;
149
150 /**
151 * Returns the outwards pointing unit normal of the shape for the
152 * surface closest to the point at offset "p".
153 */
154 G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override ;
155
156 /**
157 * Returns the distance along the normalised vector "v" to the shape,
158 * from the point at offset "p". If there is no intersection, return
159 * kInfinity. The first intersection resulting from leaving a
160 * surface/volume is discarded. Hence, it is tolerant of points on
161 * the surface of the shape.
162 */
164 const G4ThreeVector& v ) const override ;
165
166 /**
167 * Calculates the safety distance to the nearest surface of a shape from
168 * an outside point. The distance can be an underestimate.
169 */
170 G4double DistanceToIn( const G4ThreeVector& p ) const override ;
171
172 /**
173 * Returns the distance along the normalised vector "v" to the shape,
174 * from a point at an offset "p" inside or on the surface of the shape.
175 * Intersections with surfaces, when the point is < Tolerance/2 from a
176 * surface must be ignored. Must be called as solid.DistanceToOut(p,v)
177 * or by specifying all the parameters.
178 * @param[in] p The reference point in space.
179 * @param[in] v The normalised direction.
180 * @param[in] calcNorm Flag to enable the normal computation or not.
181 * @param[out] validNorm Set to true if the solid lies entirely behind
182 * or on the exiting surface (calcNorm must be true, otherwise
183 * it is unused).
184 * @param[out] n The exiting outwards normal vector (undefined Magnitude).
185 * (calcNorm must be true, otherwise it is unused).
186 * @returns The distance value to exit the volume.
187 */
189 const G4ThreeVector& v,
190 const G4bool calcNorm = false,
191 G4bool* validNorm = nullptr,
192 G4ThreeVector* n = nullptr ) const override ;
193
194 /**
195 * Calculates the safety distance to the nearest surface of a shape from
196 * an inside point "p". The distance can be an underestimate.
197 */
198 G4double DistanceToOut( const G4ThreeVector& p ) const override ;
199
200 /**
201 * Throws an exception as paramterisations are not allowed for these solids.
202 */
204 const G4int n,
205 const G4VPhysicalVolume* pRep ) override ;
206
207 /**
208 * Methods for creating graphical representations (i.e. for visualisation).
209 */
210 void DescribeYourselfTo ( G4VGraphicsScene& scene ) const override ;
211 G4Polyhedron* CreatePolyhedron () const override ;
212
213 /**
214 * Returns an estimate of the capacity of the Boolean composition.
215 */
216 G4double GetCubicVolume() final;
217
218 private:
219
220 /**
221 * Initialisation method used in constructors.
222 */
223 void Init();
224
225 G4ThreeVector fPMin, fPMax; // bounding box extended by half-tolerance
226 G4double halfCarTolerance;
227};
228
229#endif
CLHEP::HepRotation G4RotationMatrix
CLHEP::Hep3Vector G4ThreeVector
HepGeom::Transform3D G4Transform3D
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...
G4BooleanSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
G4UnionSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
G4GeometryType GetEntityType() const override
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
G4UnionSolid & operator=(const G4UnionSolid &rhs)
EInside Inside(const G4ThreeVector &p) const override
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
G4double GetCubicVolume() final
G4Polyhedron * CreatePolyhedron() const override
~G4UnionSolid() override=default
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
G4VSolid * Clone() const override
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
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