Geant4  10.01.p03
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  UVector3 GetPointOnEdge() const;
100 
101  std::ostream& StreamInfo(std::ostream& os) const;
102 
103 
104  private:
105  double fDx; // Half-length on X
106  double fDy; // Half-length on Y
107  double fDz; // Half-length on Z
108  double fCubicVolume; // Cubic Volume
109  double fSurfaceArea; // Surface Area
110 
111 };
112 
113 
114 inline double UBox::GetXHalfLength() const
115 {
116  return fDx;
117 }
118 inline double UBox::GetYHalfLength() const
119 {
120  return fDy;
121 }
122 inline double UBox::GetZHalfLength() const
123 {
124  return fDz;
125 }
126 
127 inline double UBox::Capacity()
128 {
129  if (fCubicVolume != 0.)
130  {
131  ;
132  }
133  else
134  {
135  fCubicVolume = 8 * fDx * fDy * fDz;
136  }
137  return fCubicVolume;
138 }
139 
140 inline double UBox::SurfaceArea()
141 {
142  if (fSurfaceArea != 0.)
143  {
144  ;
145  }
146  else
147  {
148  fSurfaceArea = 8 * (fDx * fDy + fDx * fDz + fDy * fDz);
149  }
150  return fSurfaceArea;
151 }
152 
153 
154 #endif
double GetXHalfLength() const
Definition: UBox.hh:114
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:511
double fDz
Definition: UBox.hh:107
double fDx
Definition: UBox.hh:105
G4String name
Definition: TRTMaterials.hh:40
double GetYHalfLength() const
Definition: UBox.hh:118
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:588
double Capacity()
Definition: UBox.hh:127
Definition: UBox.hh:33
virtual ~UBox()
Definition: UBox.cc:57
UBox()
Definition: UBox.hh:37
static const double kInfinity
Definition: UUtils.hh:54
UVector3 GetPointOnEdge() const
Definition: UBox.cc:475
double SurfaceArea()
Definition: UBox.hh:140
EnumInside
Definition: VUSolid.hh:23
void SetXHalfLength(double dx)
Definition: UBox.cc:528
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:122
VUSolid * Clone() const
Definition: UBox.cc:593
UBox & operator=(const UBox &rhs)
Definition: UBox.cc:72
double fDy
Definition: UBox.hh:106
double fCubicVolume
Definition: UBox.hh:108
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:548
void Extent(UVector3 &aMin, UVector3 &aMax) const
Definition: UBox.cc:397
void SetZHalfLength(double dz)
Definition: UBox.cc:568
void ComputeBBox(UBBox *, bool)
Definition: UBox.hh:88
double fSurfaceArea
Definition: UBox.hh:109