Geant4 11.2.2
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// Fake default constructor - sets only member data and allocates memory
57// for usage restricted to object persistency.
58
59G4UParaboloid::G4UParaboloid( __void__& a )
60 : Base_t(a)
61{ }
62
63//////////////////////////////////////////////////////////////////////////
64//
65// Destructor
66
67G4UParaboloid::~G4UParaboloid() = default;
68
69//////////////////////////////////////////////////////////////////////////
70//
71// Copy constructor
72
73G4UParaboloid::G4UParaboloid(const G4UParaboloid& rhs)
74 : Base_t(rhs)
75{ }
76
77//////////////////////////////////////////////////////////////////////////
78//
79// Assignment operator
80
81G4UParaboloid& G4UParaboloid::operator = (const G4UParaboloid& rhs)
82{
83 // Check assignment to self
84 //
85 if (this == &rhs) { return *this; }
86
87 // Copy base class data
88 //
89 Base_t::operator=(rhs);
90
91 return *this;
92}
93
94//////////////////////////////////////////////////////////////////////////
95//
96// Accessors
97
98G4double G4UParaboloid::GetZHalfLength() const
99{
100 return GetDz();
101}
102
103G4double G4UParaboloid::GetRadiusMinusZ() const
104{
105 return GetRlo();
106}
107
108G4double G4UParaboloid::GetRadiusPlusZ() const
109{
110 return GetRhi();
111}
112
113//////////////////////////////////////////////////////////////////////////
114//
115// Modifiers
116
117void G4UParaboloid::SetZHalfLength(G4double dz)
118{
119 SetDz(dz);
120}
121
122void G4UParaboloid::SetRadiusMinusZ(G4double r1)
123{
124 SetRlo(r1);
125}
126
127void G4UParaboloid::SetRadiusPlusZ(G4double r2)
128{
129 SetRhi(r2);
130}
131
132//////////////////////////////////////////////////////////////////////////
133//
134// Make a clone of the object
135
136G4VSolid* G4UParaboloid::Clone() const
137{
138 return new G4UParaboloid(*this);
139}
140
141//////////////////////////////////////////////////////////////////////////
142//
143// Get bounding box
144
145void G4UParaboloid::BoundingLimits(G4ThreeVector& pMin,
146 G4ThreeVector& pMax) const
147{
148 static G4bool checkBBox = true;
149
150 G4double r2 = GetRadiusPlusZ();
151 G4double dz = GetZHalfLength();
152 pMin.set(-r2,-r2,-dz);
153 pMax.set( r2, r2, dz);
154
155 // Check correctness of the bounding box
156 //
157 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
158 {
159 std::ostringstream message;
160 message << "Bad bounding box (min >= max) for solid: "
161 << GetName() << " !"
162 << "\npMin = " << pMin
163 << "\npMax = " << pMax;
164 G4Exception("G4UParaboloid::BoundingLimits()", "GeomMgt0001",
165 JustWarning, message);
166 StreamInfo(G4cout);
167 }
168
169 // Check consistency of bounding boxes
170 //
171 if (checkBBox)
172 {
173 U3Vector vmin, vmax;
174 Extent(vmin,vmax);
175 if (std::abs(pMin.x()-vmin.x()) > kCarTolerance ||
176 std::abs(pMin.y()-vmin.y()) > kCarTolerance ||
177 std::abs(pMin.z()-vmin.z()) > kCarTolerance ||
178 std::abs(pMax.x()-vmax.x()) > kCarTolerance ||
179 std::abs(pMax.y()-vmax.y()) > kCarTolerance ||
180 std::abs(pMax.z()-vmax.z()) > kCarTolerance)
181 {
182 std::ostringstream message;
183 message << "Inconsistency in bounding boxes for solid: "
184 << GetName() << " !"
185 << "\nBBox min: wrapper = " << pMin << " solid = " << vmin
186 << "\nBBox max: wrapper = " << pMax << " solid = " << vmax;
187 G4Exception("G4UParaboloid::BoundingLimits()", "GeomMgt0001",
188 JustWarning, message);
189 checkBBox = false;
190 }
191 }
192}
193
194//////////////////////////////////////////////////////////////////////////
195//
196// Calculate extent under transform and specified limit
197
198G4bool
199G4UParaboloid::CalculateExtent(const EAxis pAxis,
200 const G4VoxelLimits& pVoxelLimit,
201 const G4AffineTransform& pTransform,
202 G4double& pMin, G4double& pMax) const
203{
204 G4ThreeVector bmin, bmax;
205
206 // Get bounding box
207 BoundingLimits(bmin,bmax);
208
209 // Find extent
210 G4BoundingEnvelope bbox(bmin,bmax);
211 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
212}
213
214////////////////////////////////////////////////////////////////////////
215//
216// CreatePolyhedron
217//
218G4Polyhedron* G4UParaboloid::CreatePolyhedron() const
219{
220 return new G4PolyhedronParaboloid(GetRadiusMinusZ(),
221 GetRadiusPlusZ(),
222 GetZHalfLength(), 0., twopi);
223}
224
225#endif // G4GEOM_USE_USOLIDS
const G4double kCarTolerance
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
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)
EAxis
Definition geomdefs.hh:54