Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
UBox Class Reference

#include <UBox.hh>

Inheritance diagram for UBox:
VUSolid

Public Member Functions

 UBox ()
 
 UBox (const std::string &name, double dx, double dy, double dz)
 
virtual ~UBox ()
 
 UBox (const UBox &rhs)
 
UBoxoperator= (const UBox &rhs)
 
void Set (double dx, double dy, double dz)
 
void Set (const UVector3 &vec)
 
double GetXHalfLength () const
 
double GetYHalfLength () const
 
double GetZHalfLength () const
 
void SetXHalfLength (double dx)
 
void SetYHalfLength (double dy)
 
void SetZHalfLength (double dz)
 
EnumInside Inside (const UVector3 &aPoint) const
 
double SafetyFromInside (const UVector3 &aPoint, bool aAccurate=false) const
 
double SafetyFromOutside (const UVector3 &aPoint, bool aAccurate=false) const
 
double DistanceToIn (const UVector3 &aPoint, const UVector3 &aDirection, double aPstep=UUtils::kInfinity) const
 
double DistanceToOut (const UVector3 &aPoint, const UVector3 &aDirection, UVector3 &aNormalVector, bool &aConvex, double aPstep=UUtils::kInfinity) const
 
bool Normal (const UVector3 &aPoint, UVector3 &aNormal) const
 
void Extent (UVector3 &aMin, UVector3 &aMax) const
 
double Capacity ()
 
double SurfaceArea ()
 
VUSolidClone () const
 
UGeometryType GetEntityType () const
 
void ComputeBBox (UBBox *, bool)
 
void GetParametersList (int, double *aArray) const
 
UVector3 GetPointOnSurface () const
 
std::ostream & StreamInfo (std::ostream &os) const
 
- Public Member Functions inherited from VUSolid
 VUSolid ()
 
 VUSolid (const std::string &name)
 
virtual ~VUSolid ()
 
double GetCarTolerance () const
 
double GetRadTolerance () const
 
double GetAngTolerance () const
 
void SetCarTolerance (double eps)
 
void SetRadTolerance (double eps)
 
void SetAngTolerance (double eps)
 
virtual void ExtentAxis (EAxisType aAxis, double &aMin, double &aMax) const
 
const std::string & GetName () const
 
void SetName (const std::string &aName)
 
virtual void SamplePointsInside (int, UVector3 *) const
 
virtual void SamplePointsOnSurface (int, UVector3 *) const
 
virtual void SamplePointsOnEdge (int, UVector3 *) const
 
double EstimateCubicVolume (int nStat, double epsilon) const
 
double EstimateSurfaceArea (int nStat, double ell) const
 

Additional Inherited Members

- Public Types inherited from VUSolid
enum  EnumInside { eInside =0, eSurface =1, eOutside =2 }
 
enum  EAxisType { eXaxis =0, eYaxis =1, eZaxis =2 }
 
- Static Public Member Functions inherited from VUSolid
static double Tolerance ()
 
- Static Protected Attributes inherited from VUSolid
static double fgTolerance = 1.0E-9
 
static double frTolerance = 1.0E-9
 
static double faTolerance = 1.0E-9
 

Detailed Description

Definition at line 33 of file UBox.hh.

Constructor & Destructor Documentation

UBox::UBox ( )
inline

Definition at line 37 of file UBox.hh.

Referenced by Clone().

37 : VUSolid(), fDx(0), fDy(0), fDz(0),fCubicVolume(0.), fSurfaceArea(0.) {}
VUSolid()
Definition: VUSolid.cc:18
UBox::UBox ( const std::string &  name,
double  dx,
double  dy,
double  dz 
)

Definition at line 23 of file UBox.cc.

References UUtils::Exception(), FatalErrorInArguments, VUSolid::fgTolerance, and VUSolid::GetName().

24  : VUSolid(name),
25  fDx(dx),
26  fDy(dy),
27  fDz(dz), fCubicVolume(0.), fSurfaceArea(0.)
28 {
29  // Named constructor
30 
31  if ((dx < 2 * VUSolid::fgTolerance)
32  || (dy < 2 * VUSolid::fgTolerance)
33  || (dz < 2 * VUSolid::fgTolerance)) // limit to thickness of surfaces
34  {
35  //std::ostringstream message;
36  std::ostringstream message;
37  message << "Dimensions too small for Solid: " << GetName() << "!" << std::endl
38  << " dx, dy, dz = " << dx << ", " << dy << ", " << dz;
39  UUtils::Exception("UBox::UBox()", "UGeomSolids", FatalErrorInArguments, 1, message.str().c_str());
40  }
41 }
VUSolid()
Definition: VUSolid.cc:18
const std::string & GetName() const
Definition: VUSolid.hh:103
static double fgTolerance
Definition: VUSolid.hh:30
const XML_Char * name
void Exception(const char *originOfException, const char *exceptionCode, ExceptionSeverity severity, int level, const char *description)
Definition: UUtils.cc:177
UBox::~UBox ( )
virtual

Definition at line 57 of file UBox.cc.

58 {
59 
60 }
UBox::UBox ( const UBox rhs)

Definition at line 63 of file UBox.cc.

64  : VUSolid(rhs), fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz),
65  fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea)
66 {
67 }
VUSolid()
Definition: VUSolid.cc:18

Member Function Documentation

double UBox::Capacity ( )
inlinevirtual

Implements VUSolid.

Definition at line 126 of file UBox.hh.

127 {
128  if (fCubicVolume != 0.)
129  {
130  ;
131  }
132  else
133  {
134  fCubicVolume = 8 * fDx * fDy * fDz;
135  }
136  return fCubicVolume;
137 }
VUSolid * UBox::Clone ( ) const
virtual

Implements VUSolid.

Definition at line 553 of file UBox.cc.

References UBox().

554 {
555  return new UBox(*this);
556 }
UBox()
Definition: UBox.hh:37
void UBox::ComputeBBox ( UBBox ,
bool   
)
inlinevirtual

Implements VUSolid.

Definition at line 88 of file UBox.hh.

88 {}
double UBox::DistanceToIn ( const UVector3 aPoint,
const UVector3 aDirection,
double  aPstep = UUtils::kInfinity 
) const
virtual

Implements VUSolid.

Definition at line 117 of file UBox.cc.

References VUSolid::fgTolerance, UVector3::x, UVector3::y, and UVector3::z.

Referenced by UVoxelizer::DistanceToFirst(), UVCSGfaceted::DistanceToIn(), and UPolycone::DistanceToIn().

121 {
122  // Computes distance from a point presumably outside the solid to the solid
123  // surface. Ignores first surface if the point is actually inside. Early return
124  // infinity in case the safety to any surface is found greater than the proposed
125  // step aPstep.
126  // The normal vector to the crossed surface is filled only in case the box is
127  // crossed, otherwise aNormal.IsNull() is true.
128 
129  // Compute safety to the closest surface on each axis.
130  // Early exits if safety bigger than proposed step.
131  static const double delta = VUSolid::fgTolerance;
132  // aNormal.SetNull();
133  double safx = std::abs(aPoint.x) - fDx;
134  double safy = std::abs(aPoint.y) - fDy;
135  double safz = std::abs(aPoint.z) - fDz;
136  if ((safx > aPstep) || (safy > aPstep) || (safz > aPstep))
137  return UUtils::kInfinity;
138  // Check numerical outside.
139  bool outside = (safx > 0) || (safy > 0) || (safz > 0);
140  if (!outside)
141  {
142  // If point close to this surface, check against the normal
143  if (safx > -delta)
144  {
145  // aNormal.x = UUtils::Sign(1.0, aPoint.x);
146  return (aPoint.x * aDirection.x > 0) ? UUtils::kInfinity : 0.0;
147  }
148  if (safy > -delta)
149  {
150  // aNormal.y = UUtils::Sign(1.0, aPoint.y);
151  return (aPoint.y * aDirection.y > 0) ? UUtils::kInfinity : 0.0;
152  }
153  if (safz > -delta)
154  {
155  // aNormal.z = UUtils::Sign(1.0, aPoint.z);
156  return (aPoint.z * aDirection.z > 0) ? UUtils::kInfinity : 0.0;
157  }
158  // Point actually "deep" inside, return zero distance, normal un-defined
159  return 0.0;
160  }
161  // The point is really outside. Only axis with positive safety to be
162  // considered. Early exit on each axis if point and direction components
163  // have the same .sign.
164  double dist = 0.0;
165  double coordinate = 0.0;
166  if (safx > 0)
167  {
168  if (aPoint.x * aDirection.x >= 0) return UUtils::kInfinity;
169  dist = safx / std::abs(aDirection.x);
170  coordinate = aPoint.y + dist * aDirection.y;
171  if (std::abs(coordinate) < fDy)
172  {
173  coordinate = aPoint.z + dist * aDirection.z;
174  if (std::abs(coordinate) < fDz)
175  {
176  // aNormal.x = UUtils::Sign(1.0, aPoint.x);
177  if (dist < 0.5 * delta) dist = 0.;
178  return dist;
179  }
180  }
181  }
182  if (safy > 0)
183  {
184  if (aPoint.y * aDirection.y >= 0) return UUtils::kInfinity;
185  dist = safy / std::abs(aDirection.y);
186  coordinate = aPoint.x + dist * aDirection.x;
187  if (std::abs(coordinate) < fDx)
188  {
189  coordinate = aPoint.z + dist * aDirection.z;
190  if (std::abs(coordinate) < fDz)
191  {
192  // aNormal.y = UUtils::Sign(1.0, aPoint.y);
193  if (dist < 0.5 * delta) dist = 0.;
194  return dist;
195  }
196  }
197  }
198  if (safz > 0)
199  {
200  if (aPoint.z * aDirection.z >= 0) return UUtils::kInfinity;
201  dist = safz / std::abs(aDirection.z);
202  coordinate = aPoint.x + dist * aDirection.x;
203  if (std::abs(coordinate) < fDx)
204  {
205  coordinate = aPoint.y + dist * aDirection.y;
206  if (std::abs(coordinate) < fDy)
207  {
208  // aNormal.z = UUtils::Sign(1.0, aPoint.z);
209  if (dist < 0.5 * delta) dist = 0.;
210  return dist;
211  }
212  }
213  }
214  return UUtils::kInfinity;
215 }
static double fgTolerance
Definition: VUSolid.hh:30
double x
Definition: UVector3.hh:136
double z
Definition: UVector3.hh:138
double y
Definition: UVector3.hh:137
double UBox::DistanceToOut ( const UVector3 aPoint,
const UVector3 aDirection,
UVector3 aNormalVector,
bool &  aConvex,
double  aPstep = UUtils::kInfinity 
) const
virtual

Implements VUSolid.

Definition at line 218 of file UBox.cc.

References VUSolid::fgTolerance, UVector3::Set(), UUtils::Sign(), UVector3::x, UVector3::y, and UVector3::z.

222 {
223  // Computes distance from a point presumably intside the solid to the solid
224  // surface. Ignores first surface along each axis systematically (for points
225  // inside or outside. Early returns zero in case the second surface is behind
226  // the starting point.
227  // o The proposed step is ignored.
228  // o The normal vector to the crossed surface is always filled.
229  double smin = UUtils::kInfinity;
230  double snxt, signDir;
231  convex = true; // Box is convex (even if the starting point is outside)
232  // Check always the "away" surface along direction on axis. This responds
233  // corectly even for points outside the solid (no need for tolerance check)
234  if (aDirection.x != 0.0)
235  {
236  signDir = UUtils::Sign(1.0, aDirection.x);
237  aNormal.Set(signDir, 0., 0.);
238  snxt = (-aPoint.x + signDir * fDx) / aDirection.x;
239  if (snxt <= 0) return 0.0; // point outside moving outwards
240  smin = snxt;
241  }
242 
243  if (aDirection.y != 0.0)
244  {
245  signDir = UUtils::Sign(1.0, aDirection.y);
246  snxt = (-aPoint.y + signDir * fDy) / aDirection.y;
247  if (snxt <= 0)
248  {
249  aNormal.Set(0., signDir, 0.);
250  return 0.0; // point outside moving outwards
251  }
252  if (snxt < smin)
253  {
254  smin = snxt;
255  aNormal.Set(0., signDir, 0.);
256  }
257  }
258 
259  if (aDirection.z != 0.0)
260  {
261  signDir = UUtils::Sign(1.0, aDirection.z);
262  snxt = (-aPoint.z + signDir * fDz) / aDirection.z;
263  if (snxt <= 0)
264  {
265  aNormal.Set(0., 0., signDir);
266  return 0.0; // point outside moving outwards
267  }
268  if (snxt < smin)
269  {
270  smin = snxt;
271  aNormal.Set(0., 0., signDir);
272  }
273  }
274  if (smin < 0.5 * VUSolid::fgTolerance) smin = 0.;
275  return smin;
276 }
static double fgTolerance
Definition: VUSolid.hh:30
double x
Definition: UVector3.hh:136
double z
Definition: UVector3.hh:138
short Sign(short a, short b)
Definition: UUtils.hh:184
double y
Definition: UVector3.hh:137
void UBox::Extent ( UVector3 aMin,
UVector3 aMax 
) const
virtual

Implements VUSolid.

Definition at line 400 of file UBox.cc.

References UVector3::x, UVector3::y, and UVector3::z.

401 {
402  // Returns the full 3D cartesian extent of the solid.
403  aMin.x = -fDx;
404  aMax.x = fDx;
405  aMin.y = -fDy;
406  aMax.y = fDy;
407  aMin.z = -fDz;
408  aMax.z = fDz;
409 }
double x
Definition: UVector3.hh:136
double z
Definition: UVector3.hh:138
double y
Definition: UVector3.hh:137
UGeometryType UBox::GetEntityType ( ) const
virtual

Implements VUSolid.

Definition at line 548 of file UBox.cc.

549 {
550  return "Box";
551 }
void UBox::GetParametersList ( int  ,
double *  aArray 
) const
inlinevirtual

Implements VUSolid.

Definition at line 91 of file UBox.hh.

References GetXHalfLength(), GetYHalfLength(), and GetZHalfLength().

92  {
93  aArray[0] = GetXHalfLength();
94  aArray[1] = GetYHalfLength();
95  aArray[2] = GetZHalfLength();
96  }
double GetXHalfLength() const
Definition: UBox.hh:113
double GetYHalfLength() const
Definition: UBox.hh:117
double GetZHalfLength() const
Definition: UBox.hh:121
UVector3 UBox::GetPointOnSurface ( ) const
virtual

Implements VUSolid.

Definition at line 418 of file UBox.cc.

References UUtils::Random().

419 {
420  double px, py, pz, select, sumS;
421  double Sxy = fDx * fDy, Sxz = fDx * fDz, Syz = fDy * fDz;
422 
423  sumS = Sxy + Sxz + Syz;
424  select = sumS * UUtils::Random();
425 
426  if (select < Sxy)
427  {
428  px = -fDx + 2 * fDx * UUtils::Random();
429  py = -fDy + 2 * fDy * UUtils::Random();
430 
431  if (UUtils::Random() > 0.5)
432  {
433  pz = fDz;
434  }
435  else
436  {
437  pz = -fDz;
438  }
439  }
440  else if ((select - Sxy) < Sxz)
441  {
442  px = -fDx + 2 * fDx * UUtils::Random();
443  pz = -fDz + 2 * fDz * UUtils::Random();
444 
445  if (UUtils::Random() > 0.5)
446  {
447  py = fDy;
448  }
449  else
450  {
451  py = -fDy;
452  }
453  }
454  else
455  {
456  py = -fDy + 2 * fDy * UUtils::Random();
457  pz = -fDz + 2 * fDz * UUtils::Random();
458 
459  if (UUtils::Random() > 0.5)
460  {
461  px = fDx;
462  }
463  else
464  {
465  px = -fDx;
466  }
467  }
468  return UVector3(px, py, pz);
469 }
double Random(double min=0.0, double max=1.0)
Definition: UUtils.cc:69
double UBox::GetXHalfLength ( ) const
inline

Definition at line 113 of file UBox.hh.

Referenced by GetParametersList(), and G4UBox::GetXHalfLength().

114 {
115  return fDx;
116 }
double UBox::GetYHalfLength ( ) const
inline

Definition at line 117 of file UBox.hh.

Referenced by GetParametersList(), and G4UBox::GetYHalfLength().

118 {
119  return fDy;
120 }
double UBox::GetZHalfLength ( ) const
inline

Definition at line 121 of file UBox.hh.

Referenced by UPolycone::DistanceToIn(), GetParametersList(), G4UBox::GetZHalfLength(), UVCSGfaceted::InitVoxels(), and UPolycone::Inside().

122 {
123  return fDz;
124 }
VUSolid::EnumInside UBox::Inside ( const UVector3 aPoint) const
virtual

Implements VUSolid.

Definition at line 97 of file UBox.cc.

References VUSolid::eInside, VUSolid::eOutside, VUSolid::eSurface, VUSolid::fgTolerance, UVector3::x, UVector3::y, and UVector3::z.

Referenced by UPolycone::Inside().

98 {
99  // Classify point location with respect to solid:
100  // o eInside - inside the solid
101  // o eSurface - close to surface within tolerance
102  // o eOutside - outside the solid
103  static const double delta = VUSolid::fgTolerance;
104  // Early returns on outside condition on any axis. Check Z first for faster
105  // exclusion in phi symmetric geometries.
106  double ddz = std::abs(aPoint.z) - fDz;
107  if (ddz > delta) return eOutside;
108  double ddx = std::abs(aPoint.x) - fDx;
109  if (ddx > delta) return eOutside;
110  double ddy = std::abs(aPoint.y) - fDy;
111  if (ddy > delta) return eOutside;
112  if (ddx > - delta || ddy > -delta || ddz > -delta) return eSurface;
113  return eInside;
114 }
static double fgTolerance
Definition: VUSolid.hh:30
double x
Definition: UVector3.hh:136
double z
Definition: UVector3.hh:138
double y
Definition: UVector3.hh:137
bool UBox::Normal ( const UVector3 aPoint,
UVector3 aNormal 
) const
virtual

Implements VUSolid.

Definition at line 331 of file UBox.cc.

References VUSolid::fgTolerance, UVector3::Set(), UUtils::Sign(), UVector3::x, UVector3::y, and UVector3::z.

332 {
333  // Computes the normal on a surface and returns it as a unit vector
334  // In case a point is further than tolerance_normal from a surface, set validNormal=false
335  // Must return a valid vector. (even if the point is not on the surface.)
336  //
337  // On an edge or corner, provide an average normal of all facets within tolerance
338  // NOTE: the tolerance value used in here is not yet the global surface
339  // tolerance - we will have to revise this value - TODO
340  static const double delta = 100.*VUSolid::fgTolerance;
341  static const double kInvSqrt2 = 1. / std::sqrt(2.);
342  static const double kInvSqrt3 = 1. / std::sqrt(3.);
343  aNormal.Set(0.);
344  UVector3 crt_normal, min_normal;
345  int nsurf = 0;
346  double safx = std::abs(std::abs(aPoint.x) - fDx);
347  double safmin = safx;
348  crt_normal.Set(UUtils::Sign(1., aPoint.x), 0., 0.);
349  min_normal = crt_normal;
350  if (safx < delta)
351  {
352  nsurf++;
353  aNormal += crt_normal;
354  }
355  double safy = std::abs(std::abs(aPoint.y) - fDy);
356  crt_normal.Set(0., UUtils::Sign(1., aPoint.y), 0.);
357  if (safy < delta)
358  {
359  nsurf++;
360  aNormal += crt_normal;
361  }
362  if (safy < safmin)
363  {
364  min_normal = crt_normal;
365  safmin = safy;
366  }
367  double safz = std::abs(std::abs(aPoint.z) - fDz);
368  crt_normal.Set(0., 0., UUtils::Sign(1., aPoint.z));
369  if (safz < delta)
370  {
371  nsurf++;
372  aNormal += crt_normal;
373  }
374  if (safz < safmin)
375  {
376  min_normal = crt_normal;
377  safmin = safz;
378  }
379 
380  bool valid = true;
381  switch (nsurf)
382  {
383  case 0:
384  aNormal = min_normal;
385  valid = false;
386  break;
387  case 1:
388  break;
389  case 2:
390  aNormal *= kInvSqrt2;
391  break;
392  case 3:
393  aNormal *= kInvSqrt3;
394  };
395  return valid;
396 }
static double fgTolerance
Definition: VUSolid.hh:30
double x
Definition: UVector3.hh:136
void Set(double xx, double yy, double zz)
Definition: UVector3.hh:245
double z
Definition: UVector3.hh:138
short Sign(short a, short b)
Definition: UUtils.hh:184
double y
Definition: UVector3.hh:137
UBox & UBox::operator= ( const UBox rhs)

Definition at line 72 of file UBox.cc.

73 {
74  // Check assignment to self
75  //
76  if (this == &rhs)
77  {
78  return *this;
79  }
80 
81  // Copy base class data
82  //
83  VUSolid::operator=(rhs);
84 
85  // Copy data
86  //
87  fDx = rhs.fDx;
88  fDy = rhs.fDy;
89  fDz = rhs.fDz;
90  fCubicVolume = rhs.fCubicVolume;
91  fSurfaceArea = rhs.fSurfaceArea;
92 
93  return *this;
94 }
double UBox::SafetyFromInside ( const UVector3 aPoint,
bool  aAccurate = false 
) const
virtual

Implements VUSolid.

Definition at line 279 of file UBox.cc.

References G4INCL::Math::max(), UVector3::x, UVector3::y, and UVector3::z.

281 {
282  // Estimates the isotropic safety from a point inside the current solid to any
283  // of its surfaces. The algorithm may be accurate or should provide a fast
284  // underestimate.
285  double safe, safy, safz;
286  safe = fDx - std::abs(aPoint.x);
287  safy = fDy - std::abs(aPoint.y);
288  if (safy < safe) safe = safy;
289  safz = fDz - std::abs(aPoint.z);
290  if (safz < safe) safe = safz;
291  return std::max(0.0, safe);
292 }
double x
Definition: UVector3.hh:136
T max(const T t1, const T t2)
brief Return the largest of the two arguments
double z
Definition: UVector3.hh:138
double y
Definition: UVector3.hh:137
double UBox::SafetyFromOutside ( const UVector3 aPoint,
bool  aAccurate = false 
) const
virtual

Implements VUSolid.

Definition at line 295 of file UBox.cc.

References UVector3::x, UVector3::y, and UVector3::z.

Referenced by UVCSGfaceted::SafetyFromOutside().

297 {
298  // Estimates the isotropic safety from a point outside the current solid to any
299  // of its surfaces. The algorithm may be accurate or should provide a fast
300  // underestimate.
301  double safe, safx, safy, safz;
302  safe = safx = -fDx + std::abs(aPoint.x);
303  safy = -fDy + std::abs(aPoint.y);
304  if (safy > safe) safe = safy;
305  safz = -fDz + std::abs(aPoint.z);
306  if (safz > safe) safe = safz;
307  if (safe < 0.0) return 0.0; // point is inside
308  if (!aAccurate) return safe;
309  double safsq = 0.0;
310  int count = 0;
311  if (safx > 0)
312  {
313  safsq += safx * safx;
314  count++;
315  }
316  if (safy > 0)
317  {
318  safsq += safy * safy;
319  count++;
320  }
321  if (safz > 0)
322  {
323  safsq += safz * safz;
324  count++;
325  }
326  if (count == 1) return safe;
327  return std::sqrt(safsq);
328 }
double x
Definition: UVector3.hh:136
double z
Definition: UVector3.hh:138
double y
Definition: UVector3.hh:137
void UBox::Set ( double  dx,
double  dy,
double  dz 
)

Definition at line 43 of file UBox.cc.

Referenced by UPolycone::Init(), and UVCSGfaceted::InitVoxels().

44 {
45  fDx = dx;
46  fDy = dy;
47  fDz = dz;
48 }
void UBox::Set ( const UVector3 vec)

Definition at line 50 of file UBox.cc.

References UVector3::x, UVector3::y, and UVector3::z.

51 {
52  fDx = vec.x;
53  fDy = vec.y;
54  fDz = vec.z;
55 }
double x
Definition: UVector3.hh:136
double z
Definition: UVector3.hh:138
double y
Definition: UVector3.hh:137
void UBox::SetXHalfLength ( double  dx)

Definition at line 488 of file UBox.cc.

References UUtils::Exception(), FatalErrorInArguments, VUSolid::fgTolerance, and VUSolid::GetName().

Referenced by G4UBox::SetXHalfLength().

489 {
490  if (dx > 2 * VUSolid::fgTolerance) // limit to thickness of surfaces
491  {
492  fDx = dx;
493  }
494  else
495  {
496  std::ostringstream message;
497  message << "Dimension X too small for solid: " << GetName() << "!"
498  << std::endl
499  << " hX = " << dx;
500  UUtils::Exception("UBox::SetXHalfLength()", "GeomSolids0002",
501  FatalErrorInArguments, 1, message.str().c_str());
502  }
503  fCubicVolume = 0.;
504  fSurfaceArea = 0.;
505 
506 }
const std::string & GetName() const
Definition: VUSolid.hh:103
static double fgTolerance
Definition: VUSolid.hh:30
void Exception(const char *originOfException, const char *exceptionCode, ExceptionSeverity severity, int level, const char *description)
Definition: UUtils.cc:177
void UBox::SetYHalfLength ( double  dy)

Definition at line 508 of file UBox.cc.

References UUtils::Exception(), FatalErrorInArguments, VUSolid::fgTolerance, and VUSolid::GetName().

Referenced by G4UBox::SetYHalfLength().

509 {
510  if (dy > 2 * VUSolid::fgTolerance) // limit to thickness of surfaces
511  {
512  fDy = dy;
513  }
514  else
515  {
516  std::ostringstream message;
517  message << "Dimension Y too small for solid: " << GetName() << "!"
518  << std::endl
519  << " hY = " << dy;
520  UUtils::Exception("UBox::SetYHalfLength()", "GeomSolids0002",
521  FatalErrorInArguments, 1, message.str().c_str());
522  }
523  fCubicVolume = 0.;
524  fSurfaceArea = 0.;
525 
526 }
const std::string & GetName() const
Definition: VUSolid.hh:103
static double fgTolerance
Definition: VUSolid.hh:30
void Exception(const char *originOfException, const char *exceptionCode, ExceptionSeverity severity, int level, const char *description)
Definition: UUtils.cc:177
void UBox::SetZHalfLength ( double  dz)

Definition at line 528 of file UBox.cc.

References UUtils::Exception(), FatalErrorInArguments, VUSolid::fgTolerance, and VUSolid::GetName().

Referenced by G4UBox::SetZHalfLength().

529 {
530  if (dz > 2 * VUSolid::fgTolerance) // limit to thickness of surfaces
531  {
532  fDz = dz;
533  }
534  else
535  {
536  std::ostringstream message;
537  message << "Dimension Z too small for solid: " << GetName() << "!"
538  << std::endl
539  << " hZ = " << dz;
540  UUtils::Exception("G4Box::SetZHalfLength()", "GeomSolids0002",
541  FatalErrorInArguments, 1, message.str().c_str());
542  }
543  fCubicVolume = 0.;
544  fSurfaceArea = 0.;
545 
546 }
const std::string & GetName() const
Definition: VUSolid.hh:103
static double fgTolerance
Definition: VUSolid.hh:30
void Exception(const char *originOfException, const char *exceptionCode, ExceptionSeverity severity, int level, const char *description)
Definition: UUtils.cc:177
std::ostream & UBox::StreamInfo ( std::ostream &  os) const
virtual

Implements VUSolid.

Definition at line 471 of file UBox.cc.

References VUSolid::GetName().

472 {
473  int oldprc = os.precision(16);
474  os << "-----------------------------------------------------------\n"
475  << " *** Dump for solid - " << GetName() << " ***\n"
476  << " ===================================================\n"
477  << " Solid type: UBox\n"
478  << " Parameters: \n"
479  << " half length X: " << fDx << " mm \n"
480  << " half length Y: " << fDy << " mm \n"
481  << " half length Z: " << fDz << " mm \n"
482  << "-----------------------------------------------------------\n";
483  os.precision(oldprc);
484 
485  return os;
486 }
const std::string & GetName() const
Definition: VUSolid.hh:103
double UBox::SurfaceArea ( )
inlinevirtual

Implements VUSolid.

Definition at line 139 of file UBox.hh.

140 {
141  if (fSurfaceArea != 0.)
142  {
143  ;
144  }
145  else
146  {
147  fSurfaceArea = 8 * (fDx * fDy + fDx * fDz + fDy * fDz);
148  }
149  return fSurfaceArea;
150 }

The documentation for this class was generated from the following files: