Geant4  10.01.p01
UQuadrangularFacet.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 // UQuadrangularFacet
12 //
13 // Class description:
14 //
15 // The UQuadrangularFacet class is used for the contruction of
16 // UTessellatedSolid.
17 // It is defined by four fVertices, which shall be in the same plane and be
18 // supplied in anti-clockwise order looking from the outsider of the solid
19 // where it belongs. Its constructor
20 //
21 // UQuadrangularFacet (const UVector3 Pt0, const UVector3 vt1,
22 // const UVector3 vt2, const UVector3 vt3,
23 // UFacetVertexType);
24 //
25 // takes 5 parameters to define the four fVertices:
26 // 1) UFacetvertexType = "ABSOLUTE": in this case Pt0, vt1, vt2 and vt3
27 // are the four fVertices required in anti-clockwise order when looking
28 // from the outsider.
29 // 2) UFacetvertexType = "RELATIVE": in this case the first vertex is Pt0,
30 // the second vertex is Pt0+vt, the third vertex is Pt0+vt2 and
31 // the fourth vertex is Pt0+vt3, in anti-clockwise order when looking
32 // from the outsider.
33 //
34 // 17.10.12 Marek Gayer
35 // Created from original implementation in Geant4
36 // --------------------------------------------------------------------
37 
38 #ifndef UQuadrangularFacet_HH
39 #define UQuadrangularFacet_HH 1
40 
41 #include "VUFacet.hh"
42 #include "UTriangularFacet.hh"
43 #include "UVector3.hh"
44 
46 {
47  public: // with description
48 
49  UQuadrangularFacet(const UVector3& Pt0, const UVector3& vt1,
50  const UVector3& vt2, const UVector3& vt3,
52  virtual ~UQuadrangularFacet();
53 
56 
57  VUFacet* GetClone();
58 
59  UVector3 Distance(const UVector3& p);
60  double Distance(const UVector3& p, const double minDist);
61  double Distance(const UVector3& p, const double minDist,
62  const bool outgoing);
63  double Extent(const UVector3 axis);
64  bool Intersect(const UVector3& p, const UVector3& v,
65  const bool outgoing, double& distance,
66  double& distFromSurface, UVector3& normal);
67 
68  double GetArea();
69  UVector3 GetPointOnFace() const;
70 
71  virtual UGeometryType GetEntityType() const;
72 
73  inline int GetNumberOfVertices() const
74  {
75  return 4;
76  }
77 
78  UVector3 GetVertex(int i) const
79  {
80  return i == 3 ? fFacet2.GetVertex(2) : fFacet1.GetVertex(i);
81  }
82 
83  UVector3 GetSurfaceNormal() const;
84 
85  inline double GetRadius() const
86  {
87  return fRadius;
88  }
89 
90  inline UVector3 GetCircumcentre() const
91  {
92  return fCircumcentre;
93  }
94 
95  inline void SetVertex(int i, const UVector3& val)
96  {
97  switch (i)
98  {
99  case 0:
100  fFacet1.SetVertex(0, val);
101  fFacet2.SetVertex(0, val);
102  break;
103  case 1:
104  fFacet1.SetVertex(1, val);
105  break;
106  case 2:
107  fFacet1.SetVertex(2, val);
108  fFacet2.SetVertex(1, val);
109  break;
110  case 3:
111  fFacet2.SetVertex(2, val);
112  break;
113  }
114  }
115 
116  inline void SetVertices(std::vector<UVector3>* v)
117  {
118  fFacet1.SetVertices(v);
119  fFacet2.SetVertices(v);
120  }
121 
122  inline bool IsDefined() const
123  {
124  return fFacet1.IsDefined();
125  }
126 
127  protected:
128  private:
129 
130  inline int GetVertexIndex(int i) const
131  {
132  return i == 3 ? fFacet2.GetVertexIndex(2) : fFacet1.GetVertexIndex(i);
133  }
134 
135  inline void SetVertexIndex(int i, int val)
136  {
137  switch (i)
138  {
139  case 0:
140  fFacet1.SetVertexIndex(0, val);
141  fFacet2.SetVertexIndex(0, val);
142  break;
143  case 1:
144  fFacet1.SetVertexIndex(1, val);
145  break;
146  case 2:
147  fFacet1.SetVertexIndex(2, val);
148  fFacet2.SetVertexIndex(1, val);
149  break;
150  case 3:
151  fFacet2.SetVertexIndex(2, val);
152  break;
153  }
154  }
155 
156  double fRadius;
157 
159 
161  {
162  return sizeof(*this) + fFacet1.AllocatedMemory() + fFacet2.AllocatedMemory();
163  }
164 
166 };
167 
168 #endif
UTriangularFacet fFacet1
double GetRadius() const
void SetVertexIndex(int i, int j)
virtual UGeometryType GetEntityType() const
UVector3 Distance(const UVector3 &p)
bool IsDefined() const
int GetVertexIndex(int i) const
UQuadrangularFacet & operator=(const UQuadrangularFacet &right)
UFacetVertexType
Definition: VUFacet.hh:49
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:77
UQuadrangularFacet(const UVector3 &Pt0, const UVector3 &vt1, const UVector3 &vt2, const UVector3 &vt3, UFacetVertexType)
void SetVertex(int i, const UVector3 &val)
double Extent(const UVector3 axis)
int GetVertexIndex(int i) const
void SetVertexIndex(int i, int val)
UVector3 GetVertex(int i) const
void SetVertices(std::vector< UVector3 > *v)
UVector3 GetCircumcentre() const
UTriangularFacet fFacet2
UVector3 GetPointOnFace() const
UVector3 GetVertex(int i) const
std::string UGeometryType
Definition: UTypes.hh:39
int GetNumberOfVertices() const
void SetVertices(std::vector< UVector3 > *v)
UVector3 GetSurfaceNormal() const
bool Intersect(const UVector3 &p, const UVector3 &v, const bool outgoing, double &distance, double &distFromSurface, UVector3 &normal)
void SetVertex(int i, const UVector3 &val)