Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
78  VUSolid::EnumInside Inside(const UVector3& p, double tolerance,
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  bool PointOnCone(const UVector3& hit, double normSign,
113  const UVector3& p,
114  const UVector3& v, UVector3& normal);
115 
116  void CopyStuff(const UPolyconeSide& source);
117 
118  static void FindLineIntersect(double x1, double y1,
119  double tx1, double ty1,
120  double x2, double y2,
121  double tx2, double ty2,
122  double& x, double& y);
123 
124  double GetPhi(const UVector3& p);
125 
126  protected:
127 
128  double r[2], z[2]; // r, z parameters, in specified order
129  double startPhi, // Start phi (0 to 2pi), if phiIsOpen
130  deltaPhi; // Delta phi (0 to 2pi), if phiIsOpen
131  bool phiIsOpen; // True if there is a phi slice
132  bool allBehind; // True if the entire solid is "behind" this face
133 
134  UIntersectingCone* cone; // Our intersecting utility class
135 
136  double rNorm, zNorm; // Normal to surface in r,z space
137  double rS, zS; // Unit vector along surface in r,z space
138  double length; // Length of face in r,z space
139  double prevRS,
140  prevZS; // Unit vector along previous polyconeSide
141  double nextRS,
142  nextZS; // Unit vector along next polyconeSide
143 
144  double rNormEdge[2],
145  zNormEdge[2]; // Normal to edges
146 
147  int ncorners;
148  UVector3* corners; // The coordinates of the corners (if phiIsOpen)
149 
150  private:
151  double tolerance; // Geometrical surface thickness
152  double fSurfaceArea; // Used for surface calculation
153 };
154 
155 #endif
UVector3 GetPointOnFace()
void CopyStuff(const UPolyconeSide &source)
double DistanceAway(const UVector3 &p, bool opposite, double &distOutside2, double *rzNorm=0)
const char * p
Definition: xmltok.h:285
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
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)