Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UEllipsoid.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 G4UEllipsoid wrapper class
27//
28// 13-08-2019 Gabriele Cosmo, CERN
29// --------------------------------------------------------------------
30
31#include "G4Ellipsoid.hh"
32#include "G4UEllipsoid.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
47G4UEllipsoid::G4UEllipsoid(const G4String& pName,
48 G4double dx,
49 G4double dy,
50 G4double dz,
51 G4double bcut,
52 G4double tcut )
53 : Base_t(pName, dx, dy, dz, bcut, tcut)
54{ }
55
56//////////////////////////////////////////////////////////////////////////
57//
58// Copy constructor
59
60G4UEllipsoid::G4UEllipsoid(const G4UEllipsoid& rhs)
61 : Base_t(rhs)
62{ }
63
64//////////////////////////////////////////////////////////////////////////
65//
66// Assignment operator
67
68G4UEllipsoid& G4UEllipsoid::operator = (const G4UEllipsoid& rhs)
69{
70 // Check assignment to self
71 //
72 if (this == &rhs) { return *this; }
73
74 // Copy base class data
75 //
76 Base_t::operator=(rhs);
77
78 return *this;
79}
80
81//////////////////////////////////////////////////////////////////////////
82//
83// Accessors
84
85G4double G4UEllipsoid::GetDx() const
86{
87 return Base_t::GetDx();
88}
89
90G4double G4UEllipsoid::GetDy() const
91{
92 return Base_t::GetDy();
93}
94
95G4double G4UEllipsoid::GetDz() const
96{
97 return Base_t::GetDz();
98}
99
100G4double G4UEllipsoid::GetSemiAxisMax (G4int i) const
101{
102 return (i==0) ? GetDx()
103 : (i==1) ? GetDy()
104 : GetDz();
105}
106
107G4double G4UEllipsoid::GetZBottomCut() const
108{
109 return Base_t::GetZBottomCut();
110}
111
112G4double G4UEllipsoid::GetZTopCut() const
113{
114 return Base_t::GetZTopCut();
115}
116
117//////////////////////////////////////////////////////////////////////////
118//
119// Modifiers
120
121void G4UEllipsoid::SetSemiAxis (G4double x, G4double y, G4double z)
122{
123 Base_t::SetSemiAxes(x, y, z);
124}
125
126void G4UEllipsoid::SetZCuts (G4double newzBottomCut, G4double newzTopCut)
127{
128 Base_t::SetZCuts(newzBottomCut, newzTopCut);
129}
130
131//////////////////////////////////////////////////////////////////////////
132//
133// Make a clone of the object
134
135G4VSolid* G4UEllipsoid::Clone() const
136{
137 return new G4UEllipsoid(*this);
138}
139
140//////////////////////////////////////////////////////////////////////////
141//
142// Get bounding box
143
144void G4UEllipsoid::BoundingLimits(G4ThreeVector& pMin,
145 G4ThreeVector& pMax) const
146{
147 G4double dx = GetDx();
148 G4double dy = GetDy();
149 G4double dz = GetDz();
150 G4double zmin = std::max(-dz,GetZBottomCut());
151 G4double zmax = std::min( dz,GetZTopCut());
152 pMin.set(-dx,-dy,zmin);
153 pMax.set( dx, dy,zmax);
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("G4UEllipsoid::BoundingLimits()", "GeomMgt0001",
165 JustWarning, message);
166 StreamInfo(G4cout);
167 }
168}
169
170//////////////////////////////////////////////////////////////////////////
171//
172// Calculate extent under transform and specified limit
173
174G4bool
175G4UEllipsoid::CalculateExtent(const EAxis pAxis,
176 const G4VoxelLimits& pVoxelLimit,
177 const G4AffineTransform& pTransform,
178 G4double& pMin, G4double& pMax) const
179{
180 G4ThreeVector bmin, bmax;
181
182 // Get bounding box
183 BoundingLimits(bmin,bmax);
184
185 // Find extent
186 G4BoundingEnvelope bbox(bmin,bmax);
187 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
188}
189
190////////////////////////////////////////////////////////////////////////
191//
192// CreatePolyhedron
193
194G4Polyhedron* G4UEllipsoid::CreatePolyhedron() const
195{
196 return new G4PolyhedronEllipsoid(GetDx(), GetDy(), GetDz(),
197 GetZBottomCut(), GetZTopCut());
198}
199
200#endif // G4GEOM_USE_USOLIDS
@ 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
int G4int
Definition G4Types.hh:85
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