Geant4  10.01.p01
UPolyconeSide.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 // UPolyconeSide
12 //
13 // Class description:
14 //
15 // Class implmenting a face that represents one conical side
16 // of a polycone:
17 //
18 // UPolyconeSide( const UPolyconeSideRZ *prevRZ,
19 // const UPolyconeSideRZ *tail,
20 // const UPolyconeSideRZ *head,
21 // const UPolyconeSideRZ *nextRZ,
22 // double phiStart, double deltaPhi,
23 // bool phiIsOpen, bool isAllBehind=false )
24 //
25 // Values for r1,z1 and r2,z2 should be specified in clockwise
26 // order in (r,z).
27 //
28 // 19.04.13 Marek Gayer
29 // Created from original implementation in Geant4
30 // --------------------------------------------------------------------
31 
32 #ifndef UPolyconeSide_hh
33 #define UPolyconeSide_hh
34 
35 #include "UVCSGface.hh"
36 
37 class UIntersectingCone;
38 
40 {
41  double r, z; // start of vector
42 };
43 
45 {
46  public:
47  std::pair<UVector3, double> fPhi; // Cached value for phi
48 
49  void initialize()
50  {
51  fPhi.first = UVector3(0, 0, 0);
52  fPhi.second = 0.0;
53  };
54 };
55 
56 class UPolyconeSide : public UVCSGface
57 {
58  public:
59 
60  UPolyconeSide(const UPolyconeSideRZ* prevRZ,
61  const UPolyconeSideRZ* tail,
62  const UPolyconeSideRZ* head,
63  const UPolyconeSideRZ* nextRZ,
64  double phiStart, double deltaPhi,
65  bool phiIsOpen, bool isAllBehind = false);
66  virtual ~UPolyconeSide();
67 
68  UPolyconeSide(const UPolyconeSide& source);
69  UPolyconeSide& operator=(const UPolyconeSide& source);
70 
71  bool Distance(const UVector3& p, const UVector3& v,
72  bool outgoing, double surfTolerance,
73  double& distance, double& distFromSurface,
74  UVector3& normal, bool& isAllBehind);
75 
76  double Safety(const UVector3& p, bool outgoing);
77 
79  double* bestDistance);
80 
81  UVector3 Normal(const UVector3& p, double* bestDistance);
82 
83  double Extent(const UVector3 axis);
84 
85  /*
86  void CalculateExtent( const EAxisType axis,
87  const UVoxelLimits &voxelLimit,
88  const UAffineTransform &tranform,
89  USolidExtentList &extentList );
90  */
91 
93  {
94  return new UPolyconeSide(*this);
95  }
96 
97  double SurfaceArea();
99 
100  public: // without description
101 
102  UPolyconeSide(__void__&);
103  // Fake default constructor for usage restricted to direct object
104  // persistency for clients requiring preallocation of memory for
105  // persistifiable objects.
106 
107  protected:
108 
109  double DistanceAway(const UVector3& p, bool opposite,
110  double& distOutside2, double* rzNorm = 0);
111 
112  double DistanceAway(const UVector3& p,
113  double& distOutside2, double* edgeRZnorm);
114 
115  bool PointOnCone(const UVector3& hit, double normSign,
116  const UVector3& p,
117  const UVector3& v, UVector3& normal);
118 
119  void CopyStuff(const UPolyconeSide& source);
120 
121  static void FindLineIntersect(double x1, double y1,
122  double tx1, double ty1,
123  double x2, double y2,
124  double tx2, double ty2,
125  double& x, double& y);
126 
127  double GetPhi(const UVector3& p);
128 
129  protected:
130 
131  double r[2], z[2]; // r, z parameters, in specified order
132  double startPhi, // Start phi (0 to 2pi), if phiIsOpen
133  deltaPhi; // Delta phi (0 to 2pi), if phiIsOpen
134  bool phiIsOpen; // True if there is a phi slice
135  bool allBehind; // True if the entire solid is "behind" this face
136 
137  UIntersectingCone* cone; // Our intersecting utility class
138 
139  double rNorm, zNorm; // Normal to surface in r,z space
140  double rS, zS; // Unit vector along surface in r,z space
141  double length; // Length of face in r,z space
142  double prevRS,
143  prevZS; // Unit vector along previous polyconeSide
144  double nextRS,
145  nextZS; // Unit vector along next polyconeSide
146 
147  double rNormEdge[2],
148  zNormEdge[2]; // Normal to edges
149 
150  int ncorners;
151  UVector3* corners; // The coordinates of the corners (if phiIsOpen)
152 
153  private:
154  double tolerance; // Geometrical surface thickness
155  double fSurfaceArea; // Used for surface calculation
156 };
157 
158 #endif
UVector3 GetPointOnFace()
void CopyStuff(const UPolyconeSide &source)
double DistanceAway(const UVector3 &p, bool opposite, double &distOutside2, double *rzNorm=0)
double Extent(const UVector3 axis)
double zNormEdge[2]
UPolyconeSide & operator=(const UPolyconeSide &source)
VUSolid::EnumInside Inside(const UVector3 &p, double tolerance, double *bestDistance)
double GetPhi(const UVector3 &p)
std::pair< UVector3, double > fPhi
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:77
UVector3 Normal(const UVector3 &p, double *bestDistance)
UVCSGface * Clone()
double SurfaceArea()
EnumInside
Definition: VUSolid.hh:23
UIntersectingCone * cone
double Safety(const UVector3 &p, bool outgoing)
virtual ~UPolyconeSide()
UPolyconeSide(const UPolyconeSideRZ *prevRZ, const UPolyconeSideRZ *tail, const UPolyconeSideRZ *head, const UPolyconeSideRZ *nextRZ, double phiStart, double deltaPhi, bool phiIsOpen, bool isAllBehind=false)
UVector3 * corners
bool Distance(const UVector3 &p, const UVector3 &v, bool outgoing, double surfTolerance, double &distance, double &distFromSurface, UVector3 &normal, bool &isAllBehind)
static void FindLineIntersect(double x1, double y1, double tx1, double ty1, double x2, double y2, double tx2, double ty2, double &x, double &y)
double rNormEdge[2]
bool PointOnCone(const UVector3 &hit, double normSign, const UVector3 &p, const UVector3 &v, UVector3 &normal)