Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4BooleanSolid.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// G4BooleanSolid
27//
28// Class description:
29//
30// Base class for solids created by Boolean operations between other solids.
31
32// Author: Vladimir Grichine (CERN), 10.09.1998 - Created.
33// --------------------------------------------------------------------
34#ifndef G4BOOLEANSOLID_HH
35#define G4BOOLEANSOLID_HH
36
37#include "G4DisplacedSolid.hh"
38
39#include "G4ThreeVector.hh"
40#include "G4RotationMatrix.hh"
41#include "G4Transform3D.hh"
42
44
46
47/**
48 * @brief G4BooleanSolid is the base class for solids created by Boolean
49 * operations between other solids.
50 */
51
53{
54 public:
55
56 /**
57 * Constructor of a Boolean composition between two solids with no
58 * displacement.
59 * @param[in] pName The name of the Boolean composition.
60 * @param[in] pSolidA Pointer to the first reference solid.
61 * @param[in] pSolidB Pointer to the second solid to form the composition.
62 */
63 G4BooleanSolid( const G4String& pName,
64 G4VSolid* pSolidA ,
65 G4VSolid* pSolidB );
66
67 /**
68 * Constructor of a Boolean composition between two solids with rotation
69 * and translation, used to transform the coordinate system of the second
70 * solid to the coordinate system of the first solid.
71 * @param[in] pName The name of the Boolean composition.
72 * @param[in] pSolidA Pointer to the first reference solid.
73 * @param[in] pSolidB Pointer to the second solid to form the composition.
74 * @param[in] rotMatrix Pointer to the rotation vector.
75 * @param[in] transVector The translation vector.
76 */
77 G4BooleanSolid( const G4String& pName,
78 G4VSolid* pSolidA ,
79 G4VSolid* pSolidB,
80 G4RotationMatrix* rotMatrix,
81 const G4ThreeVector& transVector );
82
83 /**
84 * Constructor of a Boolean composition between two solids with a
85 * transformation that moves the second solid from its desired position
86 * to its standard position.
87 * @param[in] pName The name of the Boolean composition.
88 * @param[in] pSolidA Pointer to the first reference solid.
89 * @param[in] pSolidB Pointer to the second solid to form the composition.
90 * @param[in] transform The composed 3D transformation.
91 */
92 G4BooleanSolid( const G4String& pName,
93 G4VSolid* pSolidA ,
94 G4VSolid* pSolidB ,
95 const G4Transform3D& transform );
96
97 /**
98 * Destructor. If using a displaced solid, deletes all cached
99 * transformations.
100 */
101 ~G4BooleanSolid() override;
102
103 /**
104 * Fake default constructor for usage restricted to direct object
105 * persistency for clients requiring preallocation of memory for
106 * persistifiable objects.
107 */
108 G4BooleanSolid(__void__&);
109
110 /**
111 * Copy constructor and assignment operator.
112 */
113 G4BooleanSolid(const G4BooleanSolid& rhs);
115
116 /**
117 * Methods returning the component solids of the Boolean composition.
118 * If the solid is made up from a Boolean operation of two solids,
119 * return the corresponding solid (for no=0 and 1). A fatal exception
120 * is thrown if the index provided is different from 0 or 1.
121 * @param[in] no Index 0/1 of the components.
122 * @returns The pointer to (const or not const) of the component solid.
123 * If the solid is not a "Boolean", returns nullptr.
124 */
125 const G4VSolid* GetConstituentSolid(G4int no) const override;
126 G4VSolid* GetConstituentSolid(G4int no) override;
127
128 /**
129 * Methods returning the computed capacity and surface area of the
130 * composition. The quantities returned are an estimate obtained by
131 * randomly sampling the Boolean composition and caching them for reuse.
132 */
133 G4double GetCubicVolume() override;
134 G4double GetSurfaceArea() override;
135
136 /**
137 * Returns the type ID, "G4BooleanSolid" of the solid.
138 */
139 G4GeometryType GetEntityType() const override;
140
141 /**
142 * Returns a pointer to the generated polyhedron representation of the
143 * composition, for use in visualisation.
144 */
145 G4Polyhedron* GetPolyhedron() const override;
146
147 /**
148 * Streams the object contents to an output stream.
149 */
150 std::ostream& StreamInfo(std::ostream& os) const override;
151
152 /**
153 * Accessor and setter for controlling/tuning the number of random points
154 * to be used for computing the cubic volume.
155 */
157 void SetCubVolStatistics(G4int st);
158
159 /**
160 * Accessor and setter for controlling/tuning the epsilon used for
161 * computing the cubic volume.
162 */
164 void SetCubVolEpsilon(G4double ep);
165
166 /**
167 * Accessor and setter for controlling/tuning the number of random points
168 * to be used for computing the surface area.
169 */
170 inline G4int GetAreaStatistics() const;
171 inline void SetAreaStatistics(G4int st);
172
173 /**
174 * Accessor and setter for controlling/tuning the level of accuracy used
175 * for computing the surface area.
176 */
177 inline G4double GetAreaAccuracy() const;
178 inline void SetAreaAccuracy(G4double ep);
179
180 /**
181 * Returns a point (G4ThreeVector) randomly and uniformly generated
182 * on the surface of the solid.
183 */
184 G4ThreeVector GetPointOnSurface() const override;
185
186 /**
187 * Returns the total number of constituent solids forming the Boolean
188 * composition.
189 */
190 G4int GetNumOfConstituents() const override;
191
192 /**
193 * Return true if the resulting solid has only planar faces.
194 */
195 G4bool IsFaceted() const override;
196
197 /**
198 * Gets/sets the Boolean processor for polyhedron to replace the default
199 * processor.
200 */
202 static void SetExternalBooleanProcessor(G4VBooleanProcessor* extProcessor);
203
204 protected:
205
206 /**
207 * Gets the list of constituent primitives of the solid and their placements.
208 */
209 void GetListOfPrimitives(std::vector<std::pair<G4VSolid *,G4Transform3D>>&,
210 const G4Transform3D&) const;
211 //
212
213 /**
214 * Stacks the polyhedra for processing.
215 * @returns A pointer to the top polyhedron.
216 */
218 const G4VSolid*) const;
219
220 protected:
221
222 /** Pointers to the costituent solids. */
225
226 /** Cached value of the capacity. */
228
229 /** Cached value of the surface area. */
231
232 /** Static pointer to the external Boolean processor. */
234
235 private:
236
237 G4int fCubVolStatistics = 1000000;
238 G4int fAreaStatistics = 1000000;
239 G4double fCubVolEpsilon = 0.001;
240 G4double fAreaAccuracy = -1;
241
242 mutable G4bool fRebuildPolyhedron = false;
243 mutable G4Polyhedron* fpPolyhedron = nullptr;
244
245 mutable std::vector<std::pair<G4VSolid *,G4Transform3D>> fPrimitives;
246 mutable G4double fPrimitivesSurfaceArea = 0.0;
247
248 /** If & only if this object created it, it must delete it. */
249 G4bool createdDisplacedSolid = false;
250};
251
252#include "G4BooleanSolid.icc"
253
254#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
G4double GetSurfaceArea() override
G4VSolid * fPtrSolidA
G4BooleanSolid & operator=(const G4BooleanSolid &rhs)
void SetCubVolEpsilon(G4double ep)
void SetAreaStatistics(G4int st)
G4Polyhedron * GetPolyhedron() const override
G4VSolid * fPtrSolidB
G4double GetAreaAccuracy() const
const G4VSolid * GetConstituentSolid(G4int no) const override
~G4BooleanSolid() override
void GetListOfPrimitives(std::vector< std::pair< G4VSolid *, G4Transform3D > > &, const G4Transform3D &) const
G4double GetCubVolEpsilon() const
G4int GetAreaStatistics() const
G4double GetCubicVolume() override
G4GeometryType GetEntityType() const override
G4BooleanSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
G4int GetCubVolStatistics() const
static G4VBooleanProcessor * GetExternalBooleanProcessor()
G4int GetNumOfConstituents() const override
static G4VBooleanProcessor * fExternalBoolProcessor
G4Polyhedron * StackPolyhedron(HepPolyhedronProcessor &, const G4VSolid *) const
std::ostream & StreamInfo(std::ostream &os) const override
void SetCubVolStatistics(G4int st)
G4bool IsFaceted() const override
void SetAreaAccuracy(G4double ep)
static void SetExternalBooleanProcessor(G4VBooleanProcessor *extProcessor)
G4ThreeVector GetPointOnSurface() const override
G4VBooleanProcessor is a virtual base class for Boolean solid processing.
G4VSolid(const G4String &name)
Definition G4VSolid.cc:59