Geant4_10
UBox.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * This Software is part of the AIDA Unified Solids Library package *
4 // * See: https://aidasoft.web.cern.ch/USolids *
5 // ********************************************************************
6 //
7 // $Id:$
8 //
9 // --------------------------------------------------------------------
10 //
11 // UBox
12 //
13 // Class description:
14 //
15 // A simple box defined by half-lengths on the three axis.
16 // The center of the box matches the origin of the local reference frame.
17 //
18 // 10.06.11 J.Apostolakis, G.Cosmo, A.Gheata
19 // Created from original implementation in Geant4 and ROOT
20 // --------------------------------------------------------------------
21 
22 #ifndef USOLIDS_UBox
23 #define USOLIDS_UBox
24 
25 #ifndef USOLIDS_VUSolid
26 #include "VUSolid.hh"
27 #endif
28 
29 #ifndef USOLIDS_UUtils
30 #include "UUtils.hh"
31 #endif
32 
33 class UBox : public VUSolid
34 {
35 
36  public:
37  UBox() : VUSolid(), fDx(0), fDy(0), fDz(0),fCubicVolume(0.), fSurfaceArea(0.) {}
38  UBox(const std::string& name, double dx, double dy, double dz);
39  virtual ~UBox();
40 
41  UBox(const UBox& rhs);
42  UBox& operator=(const UBox& rhs);
43 
44  // Copy constructor and assignment operator
45 
46  void Set(double dx, double dy, double dz);
47  void Set(const UVector3& vec);
48 
49  // Accessors and modifiers
50 
51 
52 
53  inline double GetXHalfLength() const;
54  inline double GetYHalfLength() const;
55  inline double GetZHalfLength() const;
56 
57  void SetXHalfLength(double dx);
58  void SetYHalfLength(double dy);
59  void SetZHalfLength(double dz);
60 
61 
62  // Navigation methods
63  EnumInside Inside(const UVector3& aPoint) const;
64 
65  double SafetyFromInside(const UVector3& aPoint,
66  bool aAccurate = false) const;
67  double SafetyFromOutside(const UVector3& aPoint,
68  bool aAccurate = false) const;
69  double DistanceToIn(const UVector3& aPoint,
70  const UVector3& aDirection,
71  // UVector3 &aNormalVector,
72 
73  double aPstep = UUtils::kInfinity) const;
74 
75  double DistanceToOut(const UVector3& aPoint,
76  const UVector3& aDirection,
77  UVector3& aNormalVector,
78  bool& aConvex,
79  double aPstep = UUtils::kInfinity) const;
80  bool Normal(const UVector3& aPoint, UVector3& aNormal) const;
81 // void Extent ( EAxisType aAxis, double &aMin, double &aMax ) const;
82  void Extent(UVector3& aMin, UVector3& aMax) const;
83  inline double Capacity();
84  inline double SurfaceArea();
85  VUSolid* Clone() const
86  {
87  return new UBox(GetName(), fDx, fDy, fDz);
88  }
90 
91  void ComputeBBox(UBBox* /*aBox*/, bool /*aStore = false*/) {}
92 
93  //G4Visualisation
94  void GetParametersList(int, double* aArray) const
95  {
96  aArray[0] = GetXHalfLength();
97  aArray[1] = GetYHalfLength();
98  aArray[2] = GetZHalfLength();
99  }
100 
101  UVector3 GetPointOnSurface() const;
102 
103  std::ostream& StreamInfo(std::ostream& os) const;
104 
105 
106  private:
107  double fDx; // Half-length on X
108  double fDy; // Half-length on Y
109  double fDz; // Half-length on Z
110  double fCubicVolume; // Cubic Volume
111  double fSurfaceArea; // Surface Area
112 
113 };
114 
115 
116 inline double UBox::GetXHalfLength() const
117 {
118  return fDx;
119 }
120 inline double UBox::GetYHalfLength() const
121 {
122  return fDy;
123 }
124 inline double UBox::GetZHalfLength() const
125 {
126  return fDz;
127 }
128 
129 inline double UBox::Capacity()
130 {
131  if (fCubicVolume != 0.)
132  {
133  ;
134  }
135  else
136  {
137  fCubicVolume = 8 * fDx * fDy * fDz;
138  }
139  return fCubicVolume;
140 }
141 
142 inline double UBox::SurfaceArea()
143 {
144  if (fSurfaceArea != 0.)
145  {
146  ;
147  }
148  else
149  {
150  fSurfaceArea = 8 * (fDx * fDy + fDx * fDz + fDy * fDz);
151  }
152  return fSurfaceArea;
153 }
154 
155 
156 #endif
double GetXHalfLength() const
Definition: UBox.hh:116
bool Normal(const UVector3 &aPoint, UVector3 &aNormal) const
Definition: UBox.cc:331
UVector3 GetPointOnSurface() const
Definition: UBox.cc:418
std::ostream & StreamInfo(std::ostream &os) const
Definition: UBox.cc:471
const std::string & GetName() const
Definition: VUSolid.hh:103
double GetYHalfLength() const
Definition: UBox.hh:120
double DistanceToOut(const UVector3 &aPoint, const UVector3 &aDirection, UVector3 &aNormalVector, bool &aConvex, double aPstep=UUtils::kInfinity) const
Definition: UBox.cc:218
UGeometryType GetEntityType() const
Definition: UBox.cc:547
double Capacity()
Definition: UBox.hh:129
const XML_Char * name
Definition: expat.h:151
Definition: UBox.hh:33
virtual ~UBox()
Definition: UBox.cc:57
UBox()
Definition: UBox.hh:37
VUSolid * Clone() const
Definition: UBox.hh:85
double SurfaceArea()
Definition: UBox.hh:142
EnumInside
Definition: VUSolid.hh:23
void SetXHalfLength(double dx)
Definition: UBox.cc:488
double DistanceToIn(const UVector3 &aPoint, const UVector3 &aDirection, double aPstep=UUtils::kInfinity) const
Definition: UBox.cc:117
double SafetyFromInside(const UVector3 &aPoint, bool aAccurate=false) const
Definition: UBox.cc:279
double GetZHalfLength() const
Definition: UBox.hh:124
UBox & operator=(const UBox &rhs)
Definition: UBox.cc:72
void Set(double dx, double dy, double dz)
Definition: UBox.cc:43
std::string UGeometryType
Definition: UTypes.hh:70
double SafetyFromOutside(const UVector3 &aPoint, bool aAccurate=false) const
Definition: UBox.cc:295
EnumInside Inside(const UVector3 &aPoint) const
Definition: UBox.cc:97
void GetParametersList(int, double *aArray) const
Definition: UBox.hh:94
void SetYHalfLength(double dy)
Definition: UBox.cc:508
void Extent(UVector3 &aMin, UVector3 &aMax) const
Definition: UBox.cc:400
void SetZHalfLength(double dz)
Definition: UBox.cc:528
void ComputeBBox(UBBox *, bool)
Definition: UBox.hh:91