Geant4  10.01.p03
UPolyhedraSide.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 // UPolyhedraSide
12 //
13 // Class description:
14 //
15 // Class implementing a face that represents one segmented side
16 // of a polyhedra:
17 //
18 // UPolyhedraSide( const UPolyhedraSideRZ *prevRZ,
19 // const UPolyhedraSideRZ *tail,
20 // const UPolyhedraSideRZ *head,
21 // const UPolyhedraSideRZ *nextRZ,
22 // int numSide,
23 // double phiStart, double phiTotal,
24 // bool phiIsOpen, bool isAllBehind=false )
25 //
26 // Values for r1,z1 and r2,z2 should be specified in clockwise
27 // order in (r,z).
28 //
29 // 19.09.13 Marek Gayer
30 // Created from original implementation in Geant4
31 // --------------------------------------------------------------------
32 
33 #ifndef UPolyhedraSide_hh
34 #define UPolyhedraSide_hh
35 
36 #include "UVCSGface.hh"
37 
38 class UIntersectingCone;
39 
41 {
42  double r, z; // start of vector
43 };
44 
45 class UPolyhedraSide : public UVCSGface
46 {
47 
48  public: // with description
49 
50  UPolyhedraSide(const UPolyhedraSideRZ* prevRZ,
51  const UPolyhedraSideRZ* tail,
52  const UPolyhedraSideRZ* head,
53  const UPolyhedraSideRZ* nextRZ,
54  int numSide,
55  double phiStart, double phiTotal,
56  bool phiIsOpen, bool isAllBehind = false);
57  virtual ~UPolyhedraSide();
58 
59  UPolyhedraSide(const UPolyhedraSide& source);
60  UPolyhedraSide& operator=(const UPolyhedraSide& source);
61 
62  bool Distance(const UVector3& p, const UVector3& v,
63  bool outgoing, double surfTolerance,
64  double& distance, double& distFromSurface,
65  UVector3& normal, bool& allBehind);
66 
67  double Safety(const UVector3& p, bool outgoing);
68 
70  double* bestDistance);
71 
72  UVector3 Normal(const UVector3& p, double* bestDistance);
73 
74  double Extent(const UVector3 axis);
75 
77  {
78  return new UPolyhedraSide(*this);
79  }
80 
81  public: // without description
82 
83  // Methods used for GetPointOnSurface()
84 
86  UVector3 p2,
87  UVector3 p3,
88  UVector3* p4);
90  UVector3 p2, UVector3 p3,
91  double* Area);
92  double SurfaceArea();
94 
95  public: // without description
96 
97  UPolyhedraSide(__void__&);
98  // Fake default constructor for usage restricted to direct object
99  // persistency for clients requiring preallocation of memory for
100  // persistifiable objects.
101 
102  protected:
103 
104  //
105  // A couple internal data structures
106  //
107  struct sUPolyhedraSideVec; // Secret recipe for allowing
108  friend struct sUPolyhedraSideVec; // protected nested structures
109 
110  typedef struct sUPolyhedraSideEdge
111  {
112  UVector3 normal; // Unit normal to this edge
113  UVector3 corner[2]; // The two corners of this phi edge
114  UVector3 cornNorm[2]; // The normals of these corners
116 
117  typedef struct sUPolyhedraSideVec
118  {
119  UVector3 normal, // Normal (point out of the shape)
120  center, // Point in center of side
121  surfPhi, // Unit vector on surface pointing along phi
122  surfRZ; // Unit vector on surface pointing along R/Z
123  UPolyhedraSideEdge* edges[2]; // The phi boundary edges to this side
124  // [0]=low phi [1]=high phi
125  UVector3 edgeNorm[2]; // RZ edge normals [i] at {r[i],z[i]}
127 
128  bool IntersectSidePlane(const UVector3& p, const UVector3& v,
129  const UPolyhedraSideVec& vec,
130  double normSign,
131  double surfTolerance,
132  double& distance,
133  double& distFromSurface);
134 
135  int LineHitsSegments(const UVector3& p,
136  const UVector3& v,
137  int* i1, int* i2);
138 
139  int ClosestPhiSegment(double phi);
140 
141  int PhiSegment(double phi);
142 
143  double GetPhi(const UVector3& p);
144 
145  double DistanceToOneSide(const UVector3& p,
146  const UPolyhedraSideVec& vec,
147  double* normDist);
148 
149  double DistanceAway(const UVector3& p,
150  const UPolyhedraSideVec& vec,
151  double* normDist);
152 
153  void CopyStuff(const UPolyhedraSide& source);
154 
155  protected:
156 
157  int numSide; // Number sides
158  double r[2], z[2]; // r, z parameters, in specified order
159  double startPhi, // Start phi (0 to 2pi), if phiIsOpen
160  deltaPhi, // Delta phi (0 to 2pi), if phiIsOpen
161  endPhi; // End phi (>startPhi), if phiIsOpen
162  bool phiIsOpen; // True if there is a phi slice
163  bool allBehind; // True if the entire solid is "behind" this face
164 
165  UIntersectingCone* cone; // Our intersecting cone
166 
167  UPolyhedraSideVec* vecs; // Vector Set for each facet of our face
168  UPolyhedraSideEdge* edges; // The edges belong to vecs
169  double lenRZ, // RZ length of each side
170  lenPhi[2]; // Phi dimensions of each side
171  double edgeNorm; // Normal in RZ/Phi space to each side
172 
173  private:
174 
175  std::pair<UVector3, double> fPhi; // Cached value for phi
176  double kCarTolerance; // Geometrical surface thickness
177  double fSurfaceArea; // Surface Area
178 };
179 
180 #endif
bool IntersectSidePlane(const UVector3 &p, const UVector3 &v, const UPolyhedraSideVec &vec, double normSign, double surfTolerance, double &distance, double &distFromSurface)
UIntersectingCone * cone
virtual ~UPolyhedraSide()
UPolyhedraSideVec * vecs
double Safety(const UVector3 &p, bool outgoing)
static const G4double tolerance
double GetPhi(const UVector3 &p)
UVector3 GetPointOnPlane(UVector3 p0, UVector3 p1, UVector3 p2, UVector3 p3, double *Area)
UPolyhedraSide(const UPolyhedraSideRZ *prevRZ, const UPolyhedraSideRZ *tail, const UPolyhedraSideRZ *head, const UPolyhedraSideRZ *nextRZ, int numSide, double phiStart, double phiTotal, bool phiIsOpen, bool isAllBehind=false)
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:77
double SurfaceTriangle(UVector3 p1, UVector3 p2, UVector3 p3, UVector3 *p4)
UVector3 Normal(const UVector3 &p, double *bestDistance)
VUSolid::EnumInside Inside(const UVector3 &p, double tolerance, double *bestDistance)
bool Distance(const UVector3 &p, const UVector3 &v, bool outgoing, double surfTolerance, double &distance, double &distFromSurface, UVector3 &normal, bool &allBehind)
int ClosestPhiSegment(double phi)
const G4double p2
const G4double p1
UPolyhedraSideEdge * edges
EnumInside
Definition: VUSolid.hh:23
double DistanceToOneSide(const UVector3 &p, const UPolyhedraSideVec &vec, double *normDist)
double Extent(const UVector3 axis)
const G4double p0
UVector3 GetPointOnFace()
UVCSGface * Clone()
struct UPolyhedraSide::sUPolyhedraSideEdge UPolyhedraSideEdge
int LineHitsSegments(const UVector3 &p, const UVector3 &v, int *i1, int *i2)
double DistanceAway(const UVector3 &p, const UPolyhedraSideVec &vec, double *normDist)
struct UPolyhedraSide::sUPolyhedraSideVec UPolyhedraSideVec
void CopyStuff(const UPolyhedraSide &source)
UPolyhedraSide & operator=(const UPolyhedraSide &source)
std::pair< UVector3, double > fPhi
int PhiSegment(double phi)