Geant4  10.01.p03
UTriangularFacet.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 // UTriangularFacet
12 //
13 // Class description:
14 //
15 // The UTriangularFacet class is used for the contruction of
16 // UTessellatedSolid.
17 // It is defined by three fVertices, which shall be supplied in anti-clockwise
18 // order looking from the outsider of the solid where it belongs.
19 // Its constructor:
20 //
21 // UTriangularFacet (const UVector3 Pt0, const UVector3 vt1,
22 // const UVector3 vt2, UFacetVertexType);
23 //
24 // takes 4 parameters to define the three fVertices:
25 // 1) UFacetvertexType = "ABSOLUTE": in this case Pt0, vt1 and vt2 are
26 // the 3 fVertices in anti-clockwise order looking from the outsider.
27 // 2) UFacetvertexType = "RELATIVE": in this case the first vertex is Pt0,
28 // the second vertex is Pt0+vt1 and the third vertex is Pt0+vt2, all
29 // in anti-clockwise order when looking from the outsider.
30 //
31 // 22.08.12 Marek Gayer
32 // Created from original implementation in Geant4
33 // --------------------------------------------------------------------
34 
35 #ifndef UTriangularFacet_hh
36 #define UTriangularFacet_hh 1
37 
38 #include "VUFacet.hh"
39 #include "UVector3.hh"
41 
42 class UTriangularFacet : public VUFacet
43 {
44 
45  public:
46 
47  UTriangularFacet(const UVector3& vt0, const UVector3& vt1, const UVector3& vt2, UFacetVertexType);
48 
50 
52 
54 
56 
57  VUFacet* GetClone();
59 
60  UVector3 Distance(const UVector3& p);
61  double Distance(const UVector3& p, const double minDist);
62  double Distance(const UVector3& p, const double minDist, const bool outgoing);
63  double Extent(const UVector3 axis);
64  bool Intersect(const UVector3& p, const UVector3& v, const bool outgoing, double& distance, double& distFromSurface, UVector3& normal);
65  double GetArea();
66  UVector3 GetPointOnFace() const;
67 
68  UVector3 GetSurfaceNormal() const;
69 
70  inline bool IsDefined() const
71  {
72  return fIsDefined;
73  }
74 
76 
77  inline int GetNumberOfVertices() const
78  {
79  return 3;
80  }
81 
82  UVector3 GetVertex(int i) const
83  {
84  int indice = fIndices[i];
85  return indice < 0 ? (*fVertices)[i] : (*fVertices)[indice];
86  }
87 
88  inline void SetVertex(int i, const UVector3& val)
89  {
90  (*fVertices)[i] = val;
91  }
92 
93  inline UVector3 GetCircumcentre() const
94  {
95  return fCircumcentre;
96  }
97 
98  inline double GetRadius() const
99  {
100  return fRadius;
101  }
102 
103  void SetSurfaceNormal(UVector3 normal);
104 
106  {
107  int size = sizeof(*this);
108  // size += geometryType.length();
109  // size += GetNumberOfVertices() * sizeof(UVector3);
110  //7 size += E.size() * sizeof(UVector3);
111  return size;
112  }
113 
114  inline int GetVertexIndex(int i) const
115  {
116  return fIndices[i];
117  }
118 
119  inline void SetVertexIndex(int i, int j)
120  {
121  fIndices[i] = j;
122  }
123 
124  inline void SetVertices(std::vector<UVector3>* v)
125  {
126  if (fIndices[0] < 0 && fVertices) delete fVertices;
127  fVertices = v;
128  }
129 
130  private:
131 
133  double fArea;
135  double fRadius;
136  int fIndices[3];
137 
138  std::vector<UVector3>* fVertices;
139 
140  void CopyFrom(const UTriangularFacet& rhs);
141 
142  private:
143 
144  double fA, fB, fC;
145  double fDet;
146  double fSqrDist;
149 };
150 
151 #endif
UTriangularFacet & operator=(const UTriangularFacet &right)
void SetVertexIndex(int i, int j)
UVector3 GetPointOnFace() const
UVector3 GetSurfaceNormal() const
void SetSurfaceNormal(UVector3 normal)
UVector3 GetCircumcentre() const
bool IsDefined() const
double GetRadius() const
UFacetVertexType
Definition: VUFacet.hh:49
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:77
void CopyFrom(const UTriangularFacet &rhs)
void SetVertex(int i, const UVector3 &val)
int GetVertexIndex(int i) const
int GetNumberOfVertices() const
UTriangularFacet * GetFlippedFacet()
UVector3 GetVertex(int i) const
std::vector< UVector3 > * fVertices
std::string UGeometryType
Definition: UTypes.hh:39
double Extent(const UVector3 axis)
bool Intersect(const UVector3 &p, const UVector3 &v, const bool outgoing, double &distance, double &distFromSurface, UVector3 &normal)
UGeometryType GetEntityType() const
void SetVertices(std::vector< UVector3 > *v)
UVector3 Distance(const UVector3 &p)