Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4DisplacedSolid.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// G4DisplacedSolid
27//
28// Class description:
29//
30// A displaced solid is a solid that has been shifted from its original
31// frame of reference to a new one. It is meant to be used **internally only**
32// for simplifying the implementation of "Boolean solids".
33
34// Author: Vladimir Grichine (CERN), 28.10.1998 - Created.
35// --------------------------------------------------------------------
36#ifndef G4DISPLACEDSOLID_HH
37#define G4DISPLACEDSOLID_HH
38
39#include "G4VSolid.hh"
40#include "G4RotationMatrix.hh"
41#include "G4ThreeVector.hh"
42#include "G4Transform3D.hh"
43#include "G4AffineTransform.hh"
44
45/**
46 * @brief G4DisplacedSolid is a solid that has been shifted from its original
47 * frame of reference to a new one. It is meant to be used **internally only**,
48 * for simplifying the implementation of "Boolean solids".
49 */
50
52{
53 public:
54
55 /**
56 * Constructor of a displaced solid rotation and translation vectors.
57 * @param[in] pName The name of the diplaced solid.
58 * @param[in] pSolid Pointer to the original reference solid.
59 * @param[in] rotMatrix Pointer to the rotation vector.
60 * @param[in] transVector The translation vector.
61 */
62 G4DisplacedSolid( const G4String& pName,
63 G4VSolid* pSolid ,
64 G4RotationMatrix* rotMatrix,
65 const G4ThreeVector& transVector ) ;
66
67 /**
68 * Constructor of a displaced solid with a transformation.
69 * @param[in] pName The name of the displaced solid.
70 * @param[in] pSolid Pointer to the original reference solid.
71 * @param[in] transform The composed 3D transformation.
72 */
73 G4DisplacedSolid( const G4String& pName,
74 G4VSolid* pSolid ,
75 const G4Transform3D& transform ) ;
76
77 /**
78 * Constructor for use in instantiating a transient instance from a
79 * persistent one.
80 * @param[in] pName The name of the displaced solid.
81 * @param[in] pSolid Pointer to the original reference solid.
82 * @param[in] directTransform The internal transformation.
83 */
84 G4DisplacedSolid( const G4String& pName,
85 G4VSolid* pSolid ,
86 const G4AffineTransform directTransform );
87
88 /**
89 * Destructor. Deletes all cached transformations.
90 */
91 ~G4DisplacedSolid() override ;
92
93 /**
94 * Fake default constructor for usage restricted to direct object
95 * persistency for clients requiring preallocation of memory for
96 * persistifiable objects.
97 */
98 G4DisplacedSolid(__void__&);
99
100 /**
101 * Copy constructor and assignment operator.
102 */
105
106 /**
107 * Returns if the given point "p" is inside or not the solid.
108 */
109 EInside Inside( const G4ThreeVector& p ) const override ;
110
111 /**
112 * Computes the bounding limits of the solid.
113 * @param[out] pMin The minimum bounding limit point.
114 * @param[out] pMax The maximum bounding limit point.
115 */
116 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
117
118 /**
119 * Calculates the minimum and maximum extent of the solid, when under the
120 * specified transform, and within the specified limits.
121 * @param[in] pAxis The axis along which compute the extent.
122 * @param[in] pVoxelLimit The limiting space dictated by voxels.
123 * @param[in] pTransform The internal transformation applied to the solid.
124 * @param[out] pMin The minimum extent value.
125 * @param[out] pMax The maximum extent value.
126 * @returns True if the solid is intersected by the extent region.
127 */
128 G4bool CalculateExtent(const EAxis pAxis,
129 const G4VoxelLimits& pVoxelLimit,
130 const G4AffineTransform& pTransform,
131 G4double& pMin, G4double& pMax) const override ;
132
133 /**
134 * Returns the outwards pointing unit normal of the shape for the
135 * surface closest to the point at offset "p".
136 */
137 G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override ;
138
139 /**
140 * Returns the distance along the normalised vector "v" to the shape,
141 * from the point at offset "p". If there is no intersection, return
142 * kInfinity. The first intersection resulting from leaving a
143 * surface/volume is discarded. Hence, it is tolerant of points on
144 * the surface of the shape.
145 */
147 const G4ThreeVector& v ) const override ;
148
149 /**
150 * Calculates the safety distance to the nearest surface of a shape from
151 * an outside point. The distance can be an underestimate.
152 */
153 G4double DistanceToIn( const G4ThreeVector& p) const override ;
154
155 /**
156 * Returns the distance along the normalised vector "v" to the shape,
157 * from a point at an offset "p" inside or on the surface of the shape.
158 * Intersections with surfaces, when the point is < Tolerance/2 from a
159 * surface must be ignored. Must be called as solid.DistanceToOut(p,v)
160 * or by specifying all the parameters.
161 * @param[in] p The reference point in space.
162 * @param[in] v The normalised direction.
163 * @param[in] calcNorm Flag to enable the normal computation or not.
164 * @param[out] validNorm Set to true if the solid lies entirely behind
165 * or on the exiting surface (calcNorm must be true, otherwise
166 * it is unused).
167 * @param[out] n The exiting outwards normal vector (undefined Magnitude).
168 * (calcNorm must be true, otherwise it is unused).
169 * @returns The distance value to exit the volume.
170 */
172 const G4ThreeVector& v,
173 const G4bool calcNorm = false,
174 G4bool* validNorm = nullptr,
175 G4ThreeVector* n = nullptr ) const override ;
176
177 /**
178 * Calculates the safety distance to the nearest surface of a shape from
179 * an inside point "p". The distance can be an underestimate.
180 */
181 G4double DistanceToOut( const G4ThreeVector& p ) const override ;
182
183
184 /**
185 * Throws an exception as paramterisations are not allowed for these solids.
186 */
188 const G4int n,
189 const G4VPhysicalVolume* pRep ) override ;
190
191 /**
192 * Deletes cached transformations. Used in destructor.
193 */
195
196 /**
197 * Methods returning an estimation of the solid volume (capacity) and
198 * surface area, in internal units.
199 */
200 G4double GetCubicVolume() override;
201 G4double GetSurfaceArea() override;
202
203 /**
204 * Returns a random point located on the surface of the solid.
205 * Points returned may not necessarily be uniformly distributed.
206 */
207 G4ThreeVector GetPointOnSurface() const override;
208
209 /**
210 * Returns the number of constituents of the solid.
211 * For non-Boolean solids the return value is one.
212 */
213 G4int GetNumOfConstituents() const override;
214
215 /**
216 * Returns true if the solid has only planar faces, false otherwise.
217 */
218 G4bool IsFaceted() const override;
219
220 /**
221 * Returns the type ID, "G4DisplacedSolid" of the solid.
222 */
223 G4GeometryType GetEntityType() const override;
224
225 /**
226 * Makes a clone of the object for use in multi-treading.
227 * @returns A pointer to the new cloned allocated solid.
228 */
229 G4VSolid* Clone() const override;
230
231 /**
232 * If the Solid is a "G4DisplacedSolid", return a self pointer else
233 * return nullptr.
234 */
235 const G4DisplacedSolid* GetDisplacedSolidPtr() const override;
237
238 /**
239 * Returns a pointer to the original not displaced solid.
240 */
242
243 /**
244 * Accessor/modifier for the associated internal transformation.
245 */
248
249 /**
250 * Accessor/modifier for the associated internal transformation, as above.
251 */
254
255 /**
256 * Get/Set the rotation/translation, as applied to the frame of reference.
257 */
262
263 /**
264 * Get/Set the rotation/translation, as applied to the object.
265 */
270
271 /**
272 * Streams the object contents to an output stream.
273 */
274 std::ostream& StreamInfo(std::ostream& os) const override;
275
276 /**
277 * Methods for creating graphical representations (i.e. for visualisation).
278 */
279 void DescribeYourselfTo ( G4VGraphicsScene& scene ) const override ;
280 G4Polyhedron* CreatePolyhedron () const override ;
281 G4Polyhedron* GetPolyhedron () const override ;
282
283 protected:
284
285 G4VSolid* fPtrSolid = nullptr;
288 mutable G4bool fRebuildPolyhedron = false;
289 mutable G4Polyhedron* fpPolyhedron = nullptr;
290};
291
292#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...
G4ThreeVector GetPointOnSurface() const override
G4double GetCubicVolume() override
G4double GetSurfaceArea() override
G4RotationMatrix GetObjectRotation() const
G4Polyhedron * fpPolyhedron
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
void SetTransform(G4AffineTransform &)
G4AffineTransform * fPtrTransform
G4AffineTransform * fDirectTransform
G4VSolid * Clone() const override
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
G4Polyhedron * CreatePolyhedron() const override
G4VSolid * GetConstituentMovedSolid() const
G4AffineTransform GetTransform() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) 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
EInside Inside(const G4ThreeVector &p) const override
~G4DisplacedSolid() override
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
std::ostream & StreamInfo(std::ostream &os) const override
G4int GetNumOfConstituents() const override
void SetObjectRotation(const G4RotationMatrix &)
G4GeometryType GetEntityType() const override
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
const G4DisplacedSolid * GetDisplacedSolidPtr() const override
G4DisplacedSolid & operator=(const G4DisplacedSolid &rhs)
G4DisplacedSolid(const G4String &pName, G4VSolid *pSolid, G4RotationMatrix *rotMatrix, const G4ThreeVector &transVector)
void SetDirectTransform(G4AffineTransform &)
G4ThreeVector GetObjectTranslation() const
G4bool IsFaceted() const override
void SetFrameRotation(const G4RotationMatrix &)
void SetFrameTranslation(const G4ThreeVector &)
G4AffineTransform GetDirectTransform() const
G4Polyhedron * GetPolyhedron() const override
G4RotationMatrix GetFrameRotation() const
void SetObjectTranslation(const G4ThreeVector &)
G4ThreeVector GetFrameTranslation() const
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