Geant4  10.01.p02
UPolyhedra.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 // UPolyhedra
12 //
13 // Class description:
14 //
15 // Class implementing a CSG-like type "PGON":
16 //
17 // UPolyhedra( const std::string& name,
18 // double phiStart, - initial phi starting angle
19 // double phiTotal, - total phi angle
20 // int numSide, - number sides
21 // int numZPlanes, - number of z planes
22 // const double zPlane[], - position of z planes
23 // const double rInner[], - tangent distance to inner surface
24 // const double rOuter[] ) - tangent distance to outer surface
25 //
26 // UPolyhedra( const std::string& name,
27 // double phiStart, - initial phi starting angle
28 // double phiTotal, - total phi angle
29 // int numSide, - number sides
30 // int numRZ, - number corners in r,z space
31 // const double r[], - r coordinate of these corners
32 // const double z[] ) - z coordinate of these corners
33 //
34 // 19.09.13 Marek Gayer
35 // Created from original implementation in Geant4
36 // --------------------------------------------------------------------
37 
38 #ifndef UPolyhedra_hh
39 #define UPolyhedra_hh
40 
41 #include "UVCSGfaceted.hh"
42 #include "UPolyhedraSide.hh"
43 
44 class UEnclosingCylinder;
45 class UReduciblePolygon;
47 {
48  public:
49 
54 
55  double fStartAngle;
56  double fOpeningAngle;
57  int fNumSide;
59  std::vector<double> fZValues;
60  std::vector<double> Rmin;
61  std::vector<double> Rmax;
62 };
63 
64 class UPolyhedra : public UVCSGfaceted
65 {
66  protected:
67 
68  inline UPolyhedra(const std::string& name) : UVCSGfaceted(name) {}
69 
70  public: // with description
71 
72  void Init(
73  double phiStart, // initial phi starting angle
74  double phiTotal, // total phi angle
75  int numSide, // number sides
76  int numZPlanes, // number of z planes
77  const double zPlane[], // position of z planes
78  const double rInner[], // tangent distance to inner surface
79  const double rOuter[]); // tangent distance to outer surface
80 
81  UPolyhedra(const std::string& name,
82  double phiStart, // initial phi starting angle
83  double phiTotal, // total phi angle
84  int numSide, // number sides
85  int numZPlanes, // number of z planes
86  const double zPlane[], // position of z planes
87  const double rInner[], // tangent distance to inner surface
88  const double rOuter[]); // tangent distance to outer surface
89 
90  UPolyhedra(const std::string& name,
91  double phiStart, // initial phi starting angle
92  double phiTotal, // total phi angle
93  int numSide, // number sides
94  int numRZ, // number corners in r,z space
95  const double r[], // r coordinate of these corners
96  const double z[]); // z coordinate of these corners
97 
98  virtual ~UPolyhedra();
99 
100  // Methods for solid
101 
102  void GetParametersList(int /*aNumber*/, double* /*aArray*/) const {}
103 
104  void ComputeBBox(UBBox* /*aBox*/, bool /*aStore*/)
105  {
106  // Computes bounding box.
107  std::cout << "ComputeBBox - Not implemented" << std::endl;
108  }
109 
110  VUSolid::EnumInside Inside(const UVector3& p) const;
111 
112  // double DistanceToInDelete( const UVector3 &p,
113  // const UVector3 &v ) const;
114 
115  double SafetyFromOutside(const UVector3& aPoint, bool aAccurate = false) const;
116 
118 
119  VUSolid* Clone() const;
120 
121  UVector3 GetPointOnSurface() const;
122 
123  std::ostream& StreamInfo(std::ostream& os) const;
124 
125  bool Reset();
126 
127  // Accessors
128 
129  inline int GetNumSide() const;
130  inline double GetStartPhi() const;
131  inline double GetEndPhi() const;
132  inline bool IsOpen() const;
133  inline bool IsGeneric() const;
134  inline int GetNumRZCorner() const;
135  inline UPolyhedraSideRZ GetCorner(const int index) const;
136 
138  // Returns internal scaled parameters.
139  inline void SetOriginalParameters(UPolyhedraHistorical& pars);
140  // Sets internal parameters. Parameters 'Rmin' and 'Rmax' in input must
141  // be scaled first by a factor computed as 'cos(0.5*phiTotal/theNumSide)',
142  // if not already scaled.
143 
144  public: // without description
145 
146  double DistanceToIn(const UVector3& p,
147  const UVector3& v, double aPstep = UUtils::kInfinity) const;
148 
149  UPolyhedra(const UPolyhedra& source);
150  UPolyhedra& operator=(const UPolyhedra& source);
151  // Copy constructor and assignment operator.
152 
153  void Extent(UVector3& aMin, UVector3& aMax) const;
154 
155  protected: // without description
156 
157  inline void SetOriginalParameters();
158  // Sets internal parameters for the generic constructor.
159 
160  void Create(double phiStart, // initial phi starting angle
161  double phiTotal, // total phi angle
162  int numSide, // number sides
163  UReduciblePolygon* rz); // rz coordinates
164  // Generates the shape and is called by each constructor, after the
165  // conversion of the arguments
166 
167  void CopyStuff(const UPolyhedra& source);
168  void DeleteStuff();
169 
170  // Methods for generation of random points on surface
171 
173  UVector3 p2, UVector3 p3) const;
175  UVector3 p2) const;
177 
178 
179  protected: // without description
180 
181  int fNumSides; // Number of sides
182  double fStartPhi; // Starting phi value (0 < phiStart < 2pi)
183  double fEndPhi; // end phi value (0 < endPhi-phiStart < 2pi)
184  bool fPhiIsOpen; // true if there is a phi segment
185  bool fGenericPgon; // true if created through the 2nd generic constructor
186  int fNumCorner; // number RZ points
187  UPolyhedraSideRZ* fCorners; // our corners
188  UPolyhedraHistorical fOriginalParameters; // original input parameters
190 
191 };
192 
193 #include "UPolyhedra.icc"
194 
195 #endif
bool IsGeneric() const
UPolyhedraSideRZ GetCorner(const int index) const
double fEndPhi
Definition: UPolyhedra.hh:183
bool Reset()
Definition: UPolyhedra.cc:464
void ComputeBBox(UBBox *, bool)
Definition: UPolyhedra.hh:104
std::ostream & StreamInfo(std::ostream &os) const
Definition: UPolyhedra.cc:550
int fNumCorner
Definition: UPolyhedra.hh:186
UPolyhedraHistorical * GetOriginalParameters()
bool fPhiIsOpen
Definition: UPolyhedra.hh:184
UVector3 GetPointOnPlane(UVector3 p0, UVector3 p1, UVector3 p2, UVector3 p3) const
Definition: UPolyhedra.cc:603
G4double z
Definition: TRTMaterials.hh:39
UPolyhedraHistorical & operator=(const UPolyhedraHistorical &right)
Definition: UPolyhedra.cc:908
G4String name
Definition: TRTMaterials.hh:40
double fStartPhi
Definition: UPolyhedra.hh:182
std::vector< double > fZValues
Definition: UPolyhedra.hh:59
int GetNumSide() const
void Extent(UVector3 &aMin, UVector3 &aMax) const
Definition: UPolyhedra.cc:923
void CopyStuff(const UPolyhedra &source)
Definition: UPolyhedra.cc:424
VUSolid * Clone() const
Definition: UPolyhedra.cc:541
UPolyhedra & operator=(const UPolyhedra &source)
Definition: UPolyhedra.cc:404
UVector3 GetPointOnTriangle(UVector3 p0, UVector3 p1, UVector3 p2) const
Definition: UPolyhedra.cc:635
static const double kInfinity
Definition: UUtils.hh:54
bool IsOpen() const
UVector3 GetPointOnSurface() const
Definition: UPolyhedra.cc:652
const G4double p2
const G4double p1
void GetParametersList(int, double *) const
Definition: UPolyhedra.hh:102
double DistanceToIn(const UVector3 &p, const UVector3 &v, double aPstep=UUtils::kInfinity) const
Definition: UPolyhedra.cc:935
std::vector< double > Rmin
Definition: UPolyhedra.hh:60
EnumInside
Definition: VUSolid.hh:23
double SafetyFromOutside(const UVector3 &aPoint, bool aAccurate=false) const
Definition: UPolyhedra.cc:523
UEnclosingCylinder * fEnclosingCylinder
Definition: UPolyhedra.hh:189
UGeometryType GetEntityType() const
Definition: UPolyhedra.cc:532
UPolyhedraSideRZ * fCorners
Definition: UPolyhedra.hh:187
void SetOriginalParameters()
virtual ~UPolyhedra()
Definition: UPolyhedra.cc:382
int GetNumRZCorner() const
const G4double p0
void Init(double phiStart, double phiTotal, int numSide, int numZPlanes, const double zPlane[], const double rInner[], const double rOuter[])
Definition: UPolyhedra.cc:67
UPolyhedra(const std::string &name)
Definition: UPolyhedra.hh:68
double GetStartPhi() const
void Create(double phiStart, double phiTotal, int numSide, UReduciblePolygon *rz)
Definition: UPolyhedra.cc:183
std::string UGeometryType
Definition: UTypes.hh:39
std::vector< double > Rmax
Definition: UPolyhedra.hh:61
void DeleteStuff()
double GetEndPhi() const
UPolyhedraHistorical fOriginalParameters
Definition: UPolyhedra.hh:188
bool fGenericPgon
Definition: UPolyhedra.hh:185
UVector3 GetPointOnSurfaceCorners() const
VUSolid::EnumInside Inside(const UVector3 &p) const
Definition: UPolyhedra.cc:506