ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4TriangularFacet.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4TriangularFacet.hh
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration and of QinetiQ Ltd, *
20 // * subject to DEFCON 705 IPR conditions. *
21 // * By using, copying, modifying or distributing the software (or *
22 // * any work based on the software) you agree to acknowledge its *
23 // * use in resulting scientific publications, and indicate your *
24 // * acceptance of all terms of the Geant4 Software license. *
25 // ********************************************************************
26 //
27 // G4TriangularFacet
28 //
29 // Class description:
30 //
31 // The G4TriangularFacet class is used for the contruction of
32 // G4TessellatedSolid.
33 // It is defined by three fVertices, which shall be supplied in anti-clockwise
34 // order looking from the outsider of the solid where it belongs.
35 // Its constructor:
36 //
37 // G4TriangularFacet (const G4ThreeVector Pt0, const G4ThreeVector vt1,
38 // const G4ThreeVector vt2, G4FacetVertexType);
39 //
40 // takes 4 parameters to define the three fVertices:
41 // 1) G4FacetvertexType = "ABSOLUTE": in this case Pt0, vt1 and vt2 are
42 // the 3 fVertices in anti-clockwise order looking from the outsider.
43 // 2) G4FacetvertexType = "RELATIVE": in this case the first vertex is Pt0,
44 // the second vertex is Pt0+vt1 and the third vertex is Pt0+vt2, all
45 // in anti-clockwise order when looking from the outsider.
46 
47 // 31 October 2004, P R Truscott, QinetiQ Ltd, UK - Created.
48 // 12 October 2012, M Gayer, CERN, - Reviewed optimized implementation.
49 // --------------------------------------------------------------------
50 #ifndef G4TRIANGULARFACET_HH
51 #define G4TRIANGULARFACET_HH 1
52 
53 #include "G4VFacet.hh"
54 #include "G4Types.hh"
55 #include "G4ThreeVector.hh"
56 
57 #include <vector>
58 #include <array>
59 
61 {
62  public: // with desctiption
63 
66 
67  G4TriangularFacet (const G4ThreeVector& vt0, const G4ThreeVector& vt1,
68  const G4ThreeVector& vt2, G4FacetVertexType);
71 
74 
75  G4VFacet* GetClone ();
77 
79  G4double Distance (const G4ThreeVector& p, G4double minDist);
80  G4double Distance (const G4ThreeVector& p, G4double minDist,
81  const G4bool outgoing);
82  G4double Extent (const G4ThreeVector axis);
83  G4bool Intersect (const G4ThreeVector& p, const G4ThreeVector& v,
84  const G4bool outgoing, G4double& distance,
85  G4double& distFromSurface, G4ThreeVector& normal);
86  G4double GetArea () const;
88 
90  void SetSurfaceNormal (G4ThreeVector normal);
91 
93 
94  inline G4bool IsDefined () const;
95  inline G4int GetNumberOfVertices () const;
96  inline G4ThreeVector GetVertex (G4int i) const;
97  inline void SetVertex (G4int i, const G4ThreeVector& val);
98 
99  inline G4ThreeVector GetCircumcentre () const;
100  inline G4double GetRadius () const;
101 
102  inline G4int AllocatedMemory();
103 
104  inline G4int GetVertexIndex (G4int i) const;
105  inline void SetVertexIndex (G4int i, G4int j);
106  inline void SetVertices(std::vector<G4ThreeVector>* v);
107 
108  private:
109 
110  void CopyFrom(const G4TriangularFacet& rhs);
111  void MoveFrom(G4TriangularFacet& rhs);
112 
117  std::array<G4int, 3> fIndices;
118  std::vector<G4ThreeVector>* fVertices = nullptr;
119 
125 };
126 
127 // --------------------------------------------------------------------
128 // Inlined Methods
129 // --------------------------------------------------------------------
130 
132 {
133  return fIsDefined;
134 }
135 
137 {
138  return 3;
139 }
140 
142 {
143  G4int indice = fIndices[i];
144  return indice < 0 ? (*fVertices)[i] : (*fVertices)[indice];
145 }
146 
148 {
149  (*fVertices)[i] = val;
150 }
151 
153 {
154  return fCircumcentre;
155 }
156 
158 {
159  return fRadius;
160 }
161 
163 {
164  G4int size = sizeof(*this);
165  size += GetNumberOfVertices() * sizeof(G4ThreeVector);
166  return size;
167 }
168 
170 {
171  if (i < 3) return fIndices[i];
172  else return 999999999;
173 }
174 
176 {
177  fIndices[i] = j;
178 }
179 
180 inline void G4TriangularFacet::SetVertices(std::vector<G4ThreeVector>* v)
181 {
182  if (fIndices[0] < 0 && fVertices)
183  {
184  delete fVertices;
185  fVertices = nullptr;
186  }
187  fVertices = v;
188 }
189 
190 #endif