Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ScaledSolid.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// G4ScaledSolid
27//
28// Class description:
29//
30// A scaled solid is a solid that has been scaled in dimensions
31// in X, Y or Z, from its original description.
32
33// Author: Gabriele Cosmo (CERN), 27.10.2015 - Created
34// --------------------------------------------------------------------
35#ifndef G4SCALEDSOLID_HH
36#define G4SCALEDSOLID_HH
37
38#include "G4VSolid.hh"
39#include "G4ThreeVector.hh"
40#include "G4Transform3D.hh"
41#include "G4AffineTransform.hh"
42
44
45/**
46 * @brief G4ScaledSolid is a solid that has been scaled in dimensions
47 * in X, Y or Z, from its original description.
48 */
49
50class G4ScaledSolid : public G4VSolid
51{
52 public:
53
54 /**
55 * Constructor of a solid with scaled transformation.
56 * @param[in] pName The name of the solid.
57 * @param[in] pSolid Pointer to the original reference solid.
58 * @param[in] pScale The scaling transformation.
59 */
60 G4ScaledSolid( const G4String& pName,
61 G4VSolid* pSolid ,
62 const G4Scale3D& pScale );
63
64 /**
65 * The destructor, clearing the cached transformation.
66 */
67 ~G4ScaledSolid() override;
68
69 /**
70 * Fake default constructor for usage restricted to direct object
71 * persistency for clients requiring preallocation of memory for
72 * persistifiable objects.
73 */
74 G4ScaledSolid(__void__&);
75
76 /**
77 * Copy constructor and assignment operator.
78 */
79 G4ScaledSolid(const G4ScaledSolid& rhs);
81
82 /**
83 * Returns if the given point "p" is inside or not the solid.
84 */
85 EInside Inside( const G4ThreeVector& p ) const override;
86
87 /**
88 * Computes the bounding limits of the solid.
89 * @param[out] pMin The minimum bounding limit point.
90 * @param[out] pMax The maximum bounding limit point.
91 */
92 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
93
94 /**
95 * Calculates the minimum and maximum extent of the solid, when under the
96 * specified transform, and within the specified limits.
97 * @param[in] pAxis The axis along which compute the extent.
98 * @param[in] pVoxelLimit The limiting space dictated by voxels.
99 * @param[in] pTransform The internal transformation applied to the solid.
100 * @param[out] pMin The minimum extent value.
101 * @param[out] pMax The maximum extent value.
102 * @returns True if the solid is intersected by the extent region.
103 */
104 G4bool CalculateExtent(const EAxis pAxis,
105 const G4VoxelLimits& pVoxelLimit,
106 const G4AffineTransform& pTransform,
107 G4double& pMin, G4double& pMax) const override;
108
109 /**
110 * Returns the outwards pointing unit normal of the shape for the
111 * surface closest to the point at offset "p".
112 */
113 G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
114
115 /**
116 * Returns the distance along the normalised vector "v" to the shape,
117 * from the point at offset "p". If there is no intersection, return
118 * kInfinity. The first intersection resulting from leaving a
119 * surface/volume is discarded. Hence, it is tolerant of points on
120 * the surface of the shape.
121 */
123 const G4ThreeVector& v ) const override;
124
125 /**
126 * Calculates the safety distance to the nearest surface of a shape from
127 * an outside point. The distance can be an underestimate.
128 */
129 G4double DistanceToIn( const G4ThreeVector& p) const override;
130
131 /**
132 * Returns the distance along the normalised vector "v" to the shape,
133 * from a point at an offset "p" inside or on the surface of the shape.
134 * Intersections with surfaces, when the point is < Tolerance/2 from a
135 * surface must be ignored. Must be called as solid.DistanceToOut(p,v)
136 * or by specifying all the parameters.
137 * @param[in] p The reference point in space.
138 * @param[in] v The normalised direction.
139 * @param[in] calcNorm Flag to enable the normal computation or not.
140 * @param[out] validNorm Set to true if the solid lies entirely behind
141 * or on the exiting surface (calcNorm must be true, otherwise
142 * it is unused).
143 * @param[out] n The exiting outwards normal vector (undefined Magnitude).
144 * (calcNorm must be true, otherwise it is unused).
145 * @returns The distance value to exit the volume.
146 */
148 const G4ThreeVector& v,
149 const G4bool calcNorm = false,
150 G4bool* validNorm = nullptr,
151 G4ThreeVector* n = nullptr ) const override;
152
153 /**
154 * Calculates the safety distance to the nearest surface of a shape from
155 * an inside point "p". The distance can be an underestimate.
156 */
157 G4double DistanceToOut( const G4ThreeVector& p ) const override;
158
159 /**
160 * Throws an exception as paramterisations are not allowed for these solids.
161 */
163 const G4int n,
164 const G4VPhysicalVolume* pRep ) override;
165
166 /**
167 * Methods returning an estimation of the solid volume (capacity) and
168 * surface area, in internal units.
169 */
170 G4double GetCubicVolume() override;
171 G4double GetSurfaceArea() override;
172
173 /**
174 * Returns a random point located on the surface of the solid.
175 * Points returned may not necessarily be uniformly distributed.
176 */
177 G4ThreeVector GetPointOnSurface() const override;
178
179 /**
180 * Returns the number of constituents of the solid.
181 * For non-Boolean solids the return value is one.
182 */
183 G4int GetNumOfConstituents() const override;
184
185 /**
186 * Returns true if the solid has only planar faces, false otherwise.
187 */
188 G4bool IsFaceted() const override;
189
190 /**
191 * Accessor and setter for the scaling transformation.
192 */
194 void SetScaleTransform(const G4Scale3D& scale);
195
196 /**
197 * Returns a pointer to the original not scaled solid.
198 */
199 G4VSolid* GetUnscaledSolid() const;
200
201 /**
202 * Returns the type ID, "G4ScaledSolid" of the solid.
203 */
204 G4GeometryType GetEntityType() const override;
205
206 /**
207 * Makes a clone of the object for use in multi-treading.
208 * @returns A pointer to the new cloned allocated solid.
209 */
210 G4VSolid* Clone() const override;
211
212 /**
213 * Streams the object contents to an output stream.
214 */
215 std::ostream& StreamInfo(std::ostream& os) const override;
216
217 /**
218 * Methods for creating graphical representations (i.e. for visualisation).
219 */
220 void DescribeYourselfTo ( G4VGraphicsScene& scene ) const override;
221 G4Polyhedron* CreatePolyhedron () const override;
222 G4Polyhedron* GetPolyhedron () const override;
223
224 private:
225
226 G4VSolid* fPtrSolid = nullptr;
227 G4ScaleTransform* fScale = nullptr;
228 G4double fCubicVolume = -1.0;
229 G4double fSurfaceArea = -1.0;
230 mutable G4bool fRebuildPolyhedron = false;
231 mutable G4Polyhedron* fpPolyhedron = nullptr;
232};
233
234#endif
CLHEP::Hep3Vector G4ThreeVector
HepGeom::Scale3D G4Scale3D
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...
G4ScaleTransform is a class for geometric scaling transformations. It supports efficient arbitrary tr...
G4Polyhedron * CreatePolyhedron() const override
G4VSolid * GetUnscaledSolid() const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
G4ThreeVector GetPointOnSurface() const override
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
G4ScaledSolid & operator=(const G4ScaledSolid &rhs)
G4bool IsFaceted() const override
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
G4Scale3D GetScaleTransform() const
G4double GetCubicVolume() override
G4int GetNumOfConstituents() const override
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
void SetScaleTransform(const G4Scale3D &scale)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
G4ScaledSolid(const G4String &pName, G4VSolid *pSolid, const G4Scale3D &pScale)
EInside Inside(const G4ThreeVector &p) const override
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
G4Polyhedron * GetPolyhedron() const override
G4VSolid * Clone() const override
G4double GetSurfaceArea() override
std::ostream & StreamInfo(std::ostream &os) const override
~G4ScaledSolid() override
G4GeometryType GetEntityType() const override
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) 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