Geant4  10.01
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;
87 
88  void ComputeBBox(UBBox* /*aBox*/, bool /*aStore = false*/) {}
89 
90  // Visualisation
91  void GetParametersList(int, double* aArray) const
92  {
93  aArray[0] = GetXHalfLength();
94  aArray[1] = GetYHalfLength();
95  aArray[2] = GetZHalfLength();
96  }
97 
99 
100  std::ostream& StreamInfo(std::ostream& os) const;
101 
102 
103  private:
104  double fDx; // Half-length on X
105  double fDy; // Half-length on Y
106  double fDz; // Half-length on Z
107  double fCubicVolume; // Cubic Volume
108  double fSurfaceArea; // Surface Area
109 
110 };
111 
112 
113 inline double UBox::GetXHalfLength() const
114 {
115  return fDx;
116 }
117 inline double UBox::GetYHalfLength() const
118 {
119  return fDy;
120 }
121 inline double UBox::GetZHalfLength() const
122 {
123  return fDz;
124 }
125 
126 inline double UBox::Capacity()
127 {
128  if (fCubicVolume != 0.)
129  {
130  ;
131  }
132  else
133  {
134  fCubicVolume = 8 * fDx * fDy * fDz;
135  }
136  return fCubicVolume;
137 }
138 
139 inline double UBox::SurfaceArea()
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 }
151 
152 
153 #endif
double GetXHalfLength() const
Definition: UBox.hh:113
bool Normal(const UVector3 &aPoint, UVector3 &aNormal) const
Definition: UBox.cc:328
UVector3 GetPointOnSurface() const
Definition: UBox.cc:415
std::ostream & StreamInfo(std::ostream &os) const
Definition: UBox.cc:468
double fDz
Definition: UBox.hh:106
double fDx
Definition: UBox.hh:104
G4String name
Definition: TRTMaterials.hh:40
double GetYHalfLength() const
Definition: UBox.hh:117
double DistanceToOut(const UVector3 &aPoint, const UVector3 &aDirection, UVector3 &aNormalVector, bool &aConvex, double aPstep=UUtils::kInfinity) const
Definition: UBox.cc:215
UGeometryType GetEntityType() const
Definition: UBox.cc:545
double Capacity()
Definition: UBox.hh:126
Definition: UBox.hh:33
virtual ~UBox()
Definition: UBox.cc:57
UBox()
Definition: UBox.hh:37
static const double kInfinity
Definition: UUtils.hh:53
double SurfaceArea()
Definition: UBox.hh:139
EnumInside
Definition: VUSolid.hh:23
void SetXHalfLength(double dx)
Definition: UBox.cc:485
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:276
double GetZHalfLength() const
Definition: UBox.hh:121
VUSolid * Clone() const
Definition: UBox.cc:550
UBox & operator=(const UBox &rhs)
Definition: UBox.cc:72
double fDy
Definition: UBox.hh:105
double fCubicVolume
Definition: UBox.hh:107
void Set(double dx, double dy, double dz)
Definition: UBox.cc:43
std::string UGeometryType
Definition: UTypes.hh:39
double SafetyFromOutside(const UVector3 &aPoint, bool aAccurate=false) const
Definition: UBox.cc:292
EnumInside Inside(const UVector3 &aPoint) const
Definition: UBox.cc:97
void GetParametersList(int, double *aArray) const
Definition: UBox.hh:91
void SetYHalfLength(double dy)
Definition: UBox.cc:505
void Extent(UVector3 &aMin, UVector3 &aMax) const
Definition: UBox.cc:397
void SetZHalfLength(double dz)
Definition: UBox.cc:525
void ComputeBBox(UBBox *, bool)
Definition: UBox.hh:88
double fSurfaceArea
Definition: UBox.hh:108