Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Box.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// G4Box
27//
28// Class description:
29//
30// A Box is a cuboid of given half lengths dx,dy,dz. The Box is
31// centred on the origin with sides parallel to the x/y/z axes.
32
33// Author: Paul Kent (CERN), 30.06.1995 - Converted from code developed end 94
34// --------------------------------------------------------------------
35#ifndef G4BOX_HH
36#define G4BOX_HH
37
38#include "G4GeomTypes.hh"
39
40#if defined(G4GEOM_USE_USOLIDS)
41#define G4GEOM_USE_UBOX 1
42#endif
43
44#if defined(G4GEOM_USE_UBOX)
45 #define G4UBox G4Box
46 #include "G4UBox.hh"
47#else
48
49#include "G4CSGSolid.hh"
50#include "G4Polyhedron.hh"
51
52/**
53 * @brief G4Box is a cuboid of given half lengths dx,dy,dz. The Box is
54 * centred on the origin with sides parallel to the x/y/z axes.
55 */
56
57class G4Box : public G4CSGSolid
58{
59 public:
60
61 /**
62 * Constructs a box with name, and half lengths pX, pY, pZ.
63 * @param[in] pName The name of the solid.
64 * @param[in] pX Half length in X.
65 * @param[in] pY Half length in Y.
66 * @param[in] pZ Half length in Z.
67 */
68 G4Box(const G4String& pName, G4double pX, G4double pY, G4double pZ);
69
70 /**
71 * Default destructor.
72 */
73 ~G4Box() override = default;
74
75 /**
76 * Dispatch method for parameterisation replication mechanism and
77 * dimension computation.
78 */
80 const G4int n,
81 const G4VPhysicalVolume* pRep) override;
82
83 /**
84 * Computes the bounding limits of the solid.
85 * @param[out] pMin The minimum bounding limit point.
86 * @param[out] pMax The maximum bounding limit point.
87 */
88 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
89
90 /**
91 * Calculates the minimum and maximum extent of the solid, when under the
92 * specified transform, and within the specified limits.
93 * @param[in] pAxis The axis along which compute the extent.
94 * @param[in] pVoxelLimit The limiting space dictated by voxels.
95 * @param[in] pTransform The internal transformation applied to the solid.
96 * @param[out] pMin The minimum extent value.
97 * @param[out] pMax The maximum extent value.
98 * @returns True if the solid is intersected by the extent region.
99 */
100 G4bool CalculateExtent(const EAxis pAxis,
101 const G4VoxelLimits& pVoxelLimit,
102 const G4AffineTransform& pTransform,
103 G4double& pMin, G4double& pMax) const override;
104
105 /**
106 * Accessors and modifiers.
107 */
108 inline G4double GetXHalfLength() const;
109 inline G4double GetYHalfLength() const;
110 inline G4double GetZHalfLength() const;
111 void SetXHalfLength(G4double dx) ;
112 void SetYHalfLength(G4double dy) ;
113 void SetZHalfLength(G4double dz) ;
114
115 /**
116 * Returning an estimation of the solid volume (capacity) and
117 * surface area, in internal units.
118 */
119 G4double GetCubicVolume() override;
120 G4double GetSurfaceArea() override;
121
122 /**
123 * Concrete implementations of the expected query interfaces for
124 * solids, as defined in the base class G4VSolid.
125 */
126 EInside Inside(const G4ThreeVector& p) const override;
127 G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
129 const G4ThreeVector& v) const override;
130 G4double DistanceToIn(const G4ThreeVector& p) const override;
132 const G4bool calcNorm = false,
133 G4bool* validNorm = nullptr,
134 G4ThreeVector* n = nullptr) const override;
135 G4double DistanceToOut(const G4ThreeVector& p) const override;
136
137 /**
138 * Returns the type ID, "G4Box" of the solid.
139 */
140 G4GeometryType GetEntityType() const override;
141
142 /**
143 * Returns a random point located and uniformly distributed on the
144 * surface of the solid.
145 */
146 G4ThreeVector GetPointOnSurface() const override;
147
148 /**
149 * Returns true as the solid has only planar faces.
150 */
151 G4bool IsFaceted() const override;
152
153 /**
154 * Makes a clone of the object for use in multi-treading.
155 * @returns A pointer to the new cloned allocated solid.
156 */
157 G4VSolid* Clone() const override;
158
159 /**
160 * Streams the object contents to an output stream.
161 */
162 std::ostream& StreamInfo(std::ostream& os) const override;
163
164 /**
165 * Methods for creating graphical representations (i.e. for visualisation).
166 */
167 void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
168 G4VisExtent GetExtent() const override;
169 G4Polyhedron* CreatePolyhedron() const override;
170
171 /**
172 * Fake default constructor for usage restricted to direct object
173 * persistency for clients requiring preallocation of memory for
174 * persistifiable objects.
175 */
176 G4Box(__void__&);
177
178 /**
179 * Copy constructor and assignment operator.
180 */
181 G4Box(const G4Box& rhs) = default;
182 G4Box& operator=(const G4Box& rhs);
183
184 private:
185
186 /**
187 * Algorithm for SurfaceNormal() following the original specification
188 * for points not on the surface.
189 */
190 G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
191
192 private:
193
194 G4double fDx = 0.0, fDy = 0.0, fDz = 0.0;
195 G4double delta; // Cached half Cartesian tolerance
196};
197
198#include "G4Box.icc"
199
200#endif
201
202#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...
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
Definition G4Box.cc:185
G4double GetYHalfLength() const
G4Box(const G4String &pName, G4double pX, G4double pY, G4double pZ)
Definition G4Box.cc:58
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
Definition G4Box.cc:572
G4VSolid * Clone() const override
Definition G4Box.cc:563
G4Polyhedron * CreatePolyhedron() const override
Definition G4Box.cc:582
G4Box & operator=(const G4Box &rhs)
Definition G4Box.cc:90
G4GeometryType GetEntityType() const override
Definition G4Box.cc:462
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
Definition G4Box.cc:319
G4double GetZHalfLength() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
Definition G4Box.cc:252
G4VisExtent GetExtent() const override
Definition G4Box.cc:577
G4Box(const G4Box &rhs)=default
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
Definition G4Box.cc:372
~G4Box() override=default
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
Definition G4Box.cc:196
G4double GetCubicVolume() override
Definition G4Box.cc:533
void SetZHalfLength(G4double dz)
Definition G4Box.cc:161
EInside Inside(const G4ThreeVector &p) const override
Definition G4Box.cc:238
G4ThreeVector GetPointOnSurface() const override
Definition G4Box.cc:500
G4bool IsFaceted() const override
Definition G4Box.cc:471
G4double GetXHalfLength() const
void SetYHalfLength(G4double dy)
Definition G4Box.cc:138
void SetXHalfLength(G4double dx)
Definition G4Box.cc:114
std::ostream & StreamInfo(std::ostream &os) const override
Definition G4Box.cc:480
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
Definition G4Box.cc:219
G4double GetSurfaceArea() override
Definition G4Box.cc:548
G4CSGSolid(const G4String &pName)
Definition G4CSGSolid.cc:49
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