Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UParaboloid.cc
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// Implementation for G4UParaboloid wrapper class
27//
28// 19.08.2015 Guilherme Lima, FNAL
29// --------------------------------------------------------------------
30
31#include "G4Paraboloid.hh"
32#include "G4UParaboloid.hh"
33
34#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
35
36#include "G4AffineTransform.hh"
39#include "G4BoundingEnvelope.hh"
40#include "G4Polyhedron.hh"
41
42////////////////////////////////////////////////////////////////////////
43//
44// Constructor - check & set half widths
45
46
47G4UParaboloid::G4UParaboloid(const G4String& pName,
48 G4double dz,
49 G4double rlo,
50 G4double rhi )
51 : Base_t(pName, rlo, rhi, dz)
52{ }
53
54//////////////////////////////////////////////////////////////////////////
55//
56// Copy constructor
57
58G4UParaboloid::G4UParaboloid(const G4UParaboloid& rhs)
59 : Base_t(rhs)
60{ }
61
62//////////////////////////////////////////////////////////////////////////
63//
64// Assignment operator
65
66G4UParaboloid& G4UParaboloid::operator = (const G4UParaboloid& rhs)
67{
68 // Check assignment to self
69 //
70 if (this == &rhs) { return *this; }
71
72 // Copy base class data
73 //
74 Base_t::operator=(rhs);
75
76 return *this;
77}
78
79//////////////////////////////////////////////////////////////////////////
80//
81// Accessors
82
83G4double G4UParaboloid::GetZHalfLength() const
84{
85 return GetDz();
86}
87
88G4double G4UParaboloid::GetRadiusMinusZ() const
89{
90 return GetRlo();
91}
92
93G4double G4UParaboloid::GetRadiusPlusZ() const
94{
95 return GetRhi();
96}
97
98//////////////////////////////////////////////////////////////////////////
99//
100// Modifiers
101
102void G4UParaboloid::SetZHalfLength(G4double dz)
103{
104 SetDz(dz);
105}
106
107void G4UParaboloid::SetRadiusMinusZ(G4double r1)
108{
109 SetRlo(r1);
110}
111
112void G4UParaboloid::SetRadiusPlusZ(G4double r2)
113{
114 SetRhi(r2);
115}
116
117//////////////////////////////////////////////////////////////////////////
118//
119// Make a clone of the object
120
121G4VSolid* G4UParaboloid::Clone() const
122{
123 return new G4UParaboloid(*this);
124}
125
126//////////////////////////////////////////////////////////////////////////
127//
128// Get bounding box
129
130void G4UParaboloid::BoundingLimits(G4ThreeVector& pMin,
131 G4ThreeVector& pMax) const
132{
133 static G4bool checkBBox = true;
134
135 G4double r2 = GetRadiusPlusZ();
136 G4double dz = GetZHalfLength();
137 pMin.set(-r2,-r2,-dz);
138 pMax.set( r2, r2, dz);
139
140 // Check correctness of the bounding box
141 //
142 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
143 {
144 std::ostringstream message;
145 message << "Bad bounding box (min >= max) for solid: "
146 << GetName() << " !"
147 << "\npMin = " << pMin
148 << "\npMax = " << pMax;
149 G4Exception("G4UParaboloid::BoundingLimits()", "GeomMgt0001",
150 JustWarning, message);
151 StreamInfo(G4cout);
152 }
153
154 // Check consistency of bounding boxes
155 //
156 if (checkBBox)
157 {
158 U3Vector vmin, vmax;
159 Extent(vmin,vmax);
160 if (std::abs(pMin.x()-vmin.x()) > kCarTolerance ||
161 std::abs(pMin.y()-vmin.y()) > kCarTolerance ||
162 std::abs(pMin.z()-vmin.z()) > kCarTolerance ||
163 std::abs(pMax.x()-vmax.x()) > kCarTolerance ||
164 std::abs(pMax.y()-vmax.y()) > kCarTolerance ||
165 std::abs(pMax.z()-vmax.z()) > kCarTolerance)
166 {
167 std::ostringstream message;
168 message << "Inconsistency in bounding boxes for solid: "
169 << GetName() << " !"
170 << "\nBBox min: wrapper = " << pMin << " solid = " << vmin
171 << "\nBBox max: wrapper = " << pMax << " solid = " << vmax;
172 G4Exception("G4UParaboloid::BoundingLimits()", "GeomMgt0001",
173 JustWarning, message);
174 checkBBox = false;
175 }
176 }
177}
178
179//////////////////////////////////////////////////////////////////////////
180//
181// Calculate extent under transform and specified limit
182
183G4bool
184G4UParaboloid::CalculateExtent(const EAxis pAxis,
185 const G4VoxelLimits& pVoxelLimit,
186 const G4AffineTransform& pTransform,
187 G4double& pMin, G4double& pMax) const
188{
189 G4ThreeVector bmin, bmax;
190
191 // Get bounding box
192 BoundingLimits(bmin,bmax);
193
194 // Find extent
195 G4BoundingEnvelope bbox(bmin,bmax);
196 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
197}
198
199////////////////////////////////////////////////////////////////////////
200//
201// CreatePolyhedron
202//
203G4Polyhedron* G4UParaboloid::CreatePolyhedron() const
204{
205 return new G4PolyhedronParaboloid(GetRadiusMinusZ(),
206 GetRadiusPlusZ(),
207 GetZHalfLength(), 0., twopi);
208}
209
210#endif // G4GEOM_USE_USOLIDS
const G4double kCarTolerance
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
G4GLOB_DLL std::ostream G4cout
double z() const
double x() const
double y() const
void set(double x, double y, double z)
G4AffineTransform is a class for geometric affine transformations. It supports efficient arbitrary ro...
G4BoundingEnvelope is a helper class to facilitate calculation of the extent of a solid within the li...
G4VSolid is an abstract base class for solids, physical shapes that can be tracked through....
Definition G4VSolid.hh:80
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...
EAxis
Definition geomdefs.hh:54