Geant4  10.01.p03
UTubs.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 // UTubs
12 //
13 // Class description:
14 //
15 // A tube or tube segment with curved sides parallel to
16 // the z-axis. The tube has a specified half-length along
17 // the z-axis, about which it is centered, and a given
18 // minimum and maximum radius. A minimum radius of 0
19 // corresponds to filled tube /cylinder. The tube segment is
20 // specified by starting and delta angles for phi, with 0
21 // being the +x axis, PI/2 the +y axis.
22 // A delta angle of 2PI signifies a complete, unsegmented
23 // tube/cylinder.
24 //
25 // Member Data:
26 //
27 // fRMin Inner radius
28 // fRMax Outer radius
29 // fDz half length in z
30 //
31 // fSPhi The starting phi angle in radians,
32 // adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI
33 //
34 // fDPhi Delta angle of the segment.
35 //
36 // fPhiFullTube Boolean variable used for indicate the Phi Section
37 //
38 // 19.10.12 Marek Gayer
39 // Created from original implementation in Geant4
40 // --------------------------------------------------------------------
41 
42 #ifndef UTUBS_HH
43 #define UTUBS_HH
44 
45 #include "VUSolid.hh"
46 #include <sstream>
47 
48 class UTubs : public VUSolid
49 {
50  public:
51 
52  UTubs(const std::string& pName,
53  double pRMin,
54  double pRMax,
55  double pDz,
56  double pSPhi,
57  double pDPhi);
58  //
59  // Constructs a tubs with the given name and dimensions
60 
61  virtual ~UTubs();
62  //
63  // Destructor
64 
65  // Accessors
66 
67  inline double GetInnerRadius() const;
68  inline double GetOuterRadius() const;
69  inline double GetZHalfLength() const;
70  inline double GetStartPhiAngle() const;
71  inline double GetDeltaPhiAngle() const;
72 
73  // Modifiers
74 
75  inline void SetInnerRadius(double newRMin);
76  inline void SetOuterRadius(double newRMax);
77  inline void SetZHalfLength(double newDz);
78  inline void SetStartPhiAngle(double newSPhi, bool trig = true);
79  inline void SetDeltaPhiAngle(double newDPhi);
80 
81  // Methods for solid
82 
83  inline double Capacity();
84  inline double SurfaceArea();
85 
86  VUSolid::EnumInside Inside(const UVector3& p) const;
87 
88  bool Normal(const UVector3& p, UVector3& normal) const;
89 
90  double DistanceToIn(const UVector3& p, const UVector3& v,
91  double aPstep = UUtils::kInfinity) const;
92  double SafetyFromInside(const UVector3& p, bool precise = false) const;
93  double DistanceToOut(const UVector3& p, const UVector3& v, UVector3& n,
94  bool& validNorm, double aPstep=UUtils::kInfinity) const;
95  double SafetyFromOutside(const UVector3& p, bool precise = false ) const;
96 
97  inline double SafetyFromInsideR(const UVector3& p, const double rho,
98  bool precise = false) const;
99  inline double SafetyFromOutsideR(const UVector3& p, const double rho,
100  bool precise = false) const;
102 
103  UVector3 GetPointOnSurface() const;
104 
105  VUSolid* Clone() const;
106 
107  std::ostream& StreamInfo(std::ostream& os) const;
108 
109  void Extent(UVector3& aMin, UVector3& aMax) const;
110 
111  virtual void GetParametersList(int /*aNumber*/, double* /*aArray*/) const;
112  virtual void ComputeBBox(UBBox* /*aBox*/, bool /*aStore = false*/) {}
113 
114  public:
115 
116  UTubs();
117  //
118  // Fake default constructor for usage restricted to direct object
119  // persistency for clients requiring preallocation of memory for
120  // persistifiable objects.
121 
122  UTubs(const UTubs& rhs);
123  UTubs& operator=(const UTubs& rhs);
124  // Copy constructor and assignment operator.
125 
126  inline double GetRMin() const;
127  inline double GetRMax() const;
128  inline double GetDz() const;
129  inline double GetSPhi() const;
130  inline double GetDPhi() const;
131 
132  protected:
133 
134  // UVector3List*
135  // CreateRotatedVertices( const UAffineTransform& pTransform ) const;
136  //
137  // Creates the List of transformed vertices in the format required
138  // for VUSolid:: ClipCrossSection and ClipBetweenSections
139 
140  inline void Initialize();
141  //
142  // Reset relevant values to zero
143 
144  inline void CheckSPhiAngle(double sPhi);
145  inline void CheckDPhiAngle(double dPhi);
146  inline void CheckPhiAngles(double sPhi, double dPhi);
147  //
148  // Reset relevant flags and angle values
149 
150  inline void InitializeTrigonometry();
151  //
152  // Recompute relevant trigonometric values and cache them
153 
154  virtual UVector3 ApproxSurfaceNormal(const UVector3& p) const;
155  //
156  // Algorithm for SurfaceNormal() following the original
157  // specification for points not on the surface
158 
159  inline double SafetyToPhi(const UVector3& p, const double rho, bool& outside) const;
160 
161  protected:
162 
164  // Used by distanceToOut
165  //
167 
168  // Used by normal
169  //
171 
173  //
174  // Radial and angular tolerances
175 
176  double fRMin, fRMax, fDz, fSPhi, fDPhi;
177  //
178  // Radial and angular dimensions
179 
182  //
183  // Cached trigonometric values
184 
186  //
187  // Flag for identification of section or full tube
188 };
189 
190 #include "UTubs.icc"
191 
192 #endif
double fCosSPhiDPhi
Definition: UTubs.hh:180
Definition: UTubs.hh:48
double fCosEPhi
Definition: UTubs.hh:180
double GetRMin() const
double fSinSPhiDPhi
Definition: UTubs.hh:180
double GetStartPhiAngle() const
double fCosHDPhiIT
Definition: UTubs.hh:180
double GetZHalfLength() const
double SafetyFromOutside(const UVector3 &p, bool precise=false) const
Definition: UTubs.cc:1032
double fSPhi
Definition: UTubs.hh:176
double SafetyFromInside(const UVector3 &p, bool precise=false) const
Definition: UTubs.cc:1536
virtual void GetParametersList(int, double *) const
Definition: UTubs.cc:1692
double GetInnerRadius() const
void SetInnerRadius(double newRMin)
VUSolid::EnumInside Inside(const UVector3 &p) const
Definition: UTubs.cc:155
double fSinCPhi
Definition: UTubs.hh:180
void InitializeTrigonometry()
VUSolid * Clone() const
Definition: UTubs.cc:1585
double GetRMax() const
void CheckSPhiAngle(double sPhi)
virtual void ComputeBBox(UBBox *, bool)
Definition: UTubs.hh:112
void CheckDPhiAngle(double dPhi)
double fDPhi
Definition: UTubs.hh:176
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:77
void SetOuterRadius(double newRMax)
void CheckPhiAngles(double sPhi, double dPhi)
double fDz
Definition: UTubs.hh:176
static const double kInfinity
Definition: UUtils.hh:54
double DistanceToOut(const UVector3 &p, const UVector3 &v, UVector3 &n, bool &validNorm, double aPstep=UUtils::kInfinity) const
Definition: UTubs.cc:1097
double GetDeltaPhiAngle() const
UGeometryType GetEntityType() const
Definition: UTubs.cc:1576
double fCosSPhi
Definition: UTubs.hh:180
double GetDPhi() const
bool Normal(const UVector3 &p, UVector3 &normal) const
Definition: UTubs.cc:358
virtual UVector3 ApproxSurfaceNormal(const UVector3 &p) const
Definition: UTubs.cc:475
UTubs & operator=(const UTubs &rhs)
Definition: UTubs.cc:110
double SafetyFromOutsideR(const UVector3 &p, const double rho, bool precise=false) const
double Capacity()
double GetDz() const
double fRMin
Definition: UTubs.hh:176
double fSinSPhi
Definition: UTubs.hh:180
bool fPhiFullTube
Definition: UTubs.hh:185
double kAngTolerance
Definition: UTubs.hh:172
double fCubicVolume
Definition: UTubs.hh:163
ENorm
Definition: UTubs.hh:170
EnumInside
Definition: VUSolid.hh:23
const G4int n
void SetDeltaPhiAngle(double newDPhi)
UVector3 GetPointOnSurface() const
Definition: UTubs.cc:1617
void Extent(UVector3 &aMin, UVector3 &aMax) const
Definition: UTubs.cc:1686
virtual ~UTubs()
Definition: UTubs.cc:83
std::ostream & StreamInfo(std::ostream &os) const
Definition: UTubs.cc:1594
double fRMax
Definition: UTubs.hh:176
double SurfaceArea()
void SetStartPhiAngle(double newSPhi, bool trig=true)
double GetOuterRadius() const
std::string UGeometryType
Definition: UTypes.hh:39
double kRadTolerance
Definition: UTubs.hh:172
UTubs()
Definition: UTubs.cc:68
ESide
Definition: UTubs.hh:166
double fCosCPhi
Definition: UTubs.hh:180
double SafetyToPhi(const UVector3 &p, const double rho, bool &outside) const
double fSinEPhi
Definition: UTubs.hh:180
void SetZHalfLength(double newDz)
double DistanceToIn(const UVector3 &p, const UVector3 &v, double aPstep=UUtils::kInfinity) const
Definition: UTubs.cc:616
double SafetyFromInsideR(const UVector3 &p, const double rho, bool precise=false) const
double GetSPhi() const
double fSurfaceArea
Definition: UTubs.hh:163
void Initialize()
double fCosHDPhiOT
Definition: UTubs.hh:180