Geant4  10.02.p03
G4QuadrangularFacet Class Reference

#include <G4QuadrangularFacet.hh>

Inheritance diagram for G4QuadrangularFacet:
Collaboration diagram for G4QuadrangularFacet:

Public Member Functions

 G4QuadrangularFacet (const G4ThreeVector &Pt0, const G4ThreeVector &vt1, const G4ThreeVector &vt2, const G4ThreeVector &vt3, G4FacetVertexType)
 
 G4QuadrangularFacet (const G4QuadrangularFacet &right)
 
 ~G4QuadrangularFacet ()
 
G4QuadrangularFacetoperator= (const G4QuadrangularFacet &right)
 
G4VFacetGetClone ()
 
G4ThreeVector Distance (const G4ThreeVector &p)
 
G4double Distance (const G4ThreeVector &p, G4double minDist)
 
G4double Distance (const G4ThreeVector &p, G4double minDist, const G4bool outgoing)
 
G4double Extent (const G4ThreeVector axis)
 
G4bool Intersect (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool outgoing, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal)
 
G4ThreeVector GetSurfaceNormal () const
 
G4double GetArea ()
 
G4ThreeVector GetPointOnFace () const
 
G4GeometryType GetEntityType () const
 
G4bool IsDefined () const
 
G4int GetNumberOfVertices () const
 
G4ThreeVector GetVertex (G4int i) const
 
void SetVertex (G4int i, const G4ThreeVector &val)
 
void SetVertices (std::vector< G4ThreeVector > *v)
 
G4double GetRadius () const
 
G4ThreeVector GetCircumcentre () const
 
- Public Member Functions inherited from G4VFacet
virtual ~G4VFacet ()
 
G4bool operator== (const G4VFacet &right) const
 
void ApplyTranslation (const G4ThreeVector v)
 
std::ostream & StreamInfo (std::ostream &os) const
 
G4bool IsInside (const G4ThreeVector &p) const
 

Private Member Functions

G4int GetVertexIndex (G4int i) const
 
void SetVertexIndex (G4int i, G4int val)
 
G4int AllocatedMemory ()
 

Private Attributes

G4double fRadius
 
G4ThreeVector fCircumcentre
 
G4TriangularFacet fFacet1
 
G4TriangularFacet fFacet2
 

Additional Inherited Members

- Static Protected Attributes inherited from G4VFacet
static const G4double dirTolerance = 1.0E-14
 
static const G4double kCarTolerance
 

Detailed Description

Definition at line 69 of file G4QuadrangularFacet.hh.

Constructor & Destructor Documentation

◆ G4QuadrangularFacet() [1/2]

G4QuadrangularFacet::G4QuadrangularFacet ( const G4ThreeVector Pt0,
const G4ThreeVector vt1,
const G4ThreeVector vt2,
const G4ThreeVector vt3,
G4FacetVertexType  vertexType 
)

Definition at line 54 of file G4QuadrangularFacet.cc.

59 {
61 
62  SetVertex(0, vt0);
63  if (vertexType == ABSOLUTE)
64  {
65  SetVertex(1, vt1);
66  SetVertex(2, vt2);
67  SetVertex(3, vt3);
68 
69  e1 = vt1 - vt0;
70  e2 = vt2 - vt0;
71  e3 = vt3 - vt0;
72  }
73  else
74  {
75  SetVertex(1, vt0 + vt1);
76  SetVertex(2, vt0 + vt2);
77  SetVertex(3, vt0 + vt3);
78 
79  e1 = vt1;
80  e2 = vt2;
81  e3 = vt3;
82  }
83  G4double length1 = e1.mag();
84  G4double length2 = (GetVertex(2)-GetVertex(1)).mag();
85  G4double length3 = (GetVertex(3)-GetVertex(2)).mag();
86  G4double length4 = e3.mag();
87 
88  G4ThreeVector normal1 = e1.cross(e2).unit();
89  G4ThreeVector normal2 = e2.cross(e3).unit();
90 
91  bool isDefined = (length1 > kCarTolerance && length2 > kCarTolerance &&
92  length3 > kCarTolerance && length4 > kCarTolerance &&
93  normal1.dot(normal2) >= 0.9999999999);
94 
95  if (isDefined)
96  {
98  GetVertex(2),ABSOLUTE);
100  GetVertex(3),ABSOLUTE);
101 
104 
107  G4ThreeVector normal34 = facet3.GetSurfaceNormal()
108  + facet4.GetSurfaceNormal();
109  G4ThreeVector normal = 0.25 * (normal12 + normal34);
110 
111  fFacet1.SetSurfaceNormal (normal);
112  fFacet2.SetSurfaceNormal (normal);
113 
114  G4ThreeVector vtmp = 0.5 * (e1 + e2);
115  fCircumcentre = GetVertex(0) + vtmp;
116  G4double radiusSqr = vtmp.mag2();
117  fRadius = std::sqrt(radiusSqr);
118  }
119  else
120  {
121  G4Exception("G4QuadrangularFacet::G4QuadrangularFacet()",
122  "GeomSolids0002", JustWarning,
123  "Length of sides of facet are too small or sides not planar.");
124  G4cout << G4endl;
125  G4cout << "P0 = " << GetVertex(0) << G4endl;
126  G4cout << "P1 = " << GetVertex(1) << G4endl;
127  G4cout << "P2 = " << GetVertex(2) << G4endl;
128  G4cout << "P3 = " << GetVertex(3) << G4endl;
129  G4cout << "Side lengths = P0->P1" << length1 << G4endl;
130  G4cout << "Side lengths = P1->P2" << length2 << G4endl;
131  G4cout << "Side lengths = P2->P3" << length3 << G4endl;
132  G4cout << "Side lengths = P3->P0" << length4 << G4endl;
133  G4cout << G4endl;
134  fRadius = 0.0;
135  }
136 }
G4TriangularFacet fFacet1
static const G4double kCarTolerance
Definition: G4VFacet.hh:102
G4ThreeVector GetSurfaceNormal() const
G4ThreeVector GetVertex(G4int i) const
static const G4double e2
double mag2() const
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:77
G4GLOB_DLL std::ostream G4cout
Hep3Vector cross(const Hep3Vector &) const
double mag() const
void SetSurfaceNormal(G4ThreeVector normal)
Hep3Vector unit() const
static const G4double e1
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double dot(const Hep3Vector &) const
void SetVertex(G4int i, const G4ThreeVector &val)
G4TriangularFacet fFacet2
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static const G4double e3
Here is the call graph for this function:
Here is the caller graph for this function:

◆ G4QuadrangularFacet() [2/2]

G4QuadrangularFacet::G4QuadrangularFacet ( const G4QuadrangularFacet right)

Definition at line 146 of file G4QuadrangularFacet.cc.

147  : G4VFacet(rhs)
148 {
149  fFacet1 = rhs.fFacet1;
150  fFacet2 = rhs.fFacet2;
151  fRadius = 0.0;
152 }
G4TriangularFacet fFacet1
G4TriangularFacet fFacet2

◆ ~G4QuadrangularFacet()

G4QuadrangularFacet::~G4QuadrangularFacet ( )

Definition at line 140 of file G4QuadrangularFacet.cc.

141 {
142 }

Member Function Documentation

◆ AllocatedMemory()

G4int G4QuadrangularFacet::AllocatedMemory ( )
inlineprivatevirtual

Implements G4VFacet.

Definition at line 206 of file G4QuadrangularFacet.hh.

207 {
208  return sizeof(*this) + fFacet1.AllocatedMemory() + fFacet2.AllocatedMemory();
209 }
G4TriangularFacet fFacet1
G4TriangularFacet fFacet2
Here is the call graph for this function:

◆ Distance() [1/3]

G4ThreeVector G4QuadrangularFacet::Distance ( const G4ThreeVector p)

Definition at line 181 of file G4QuadrangularFacet.cc.

182 {
185 
186  if (v1.mag2() < v2.mag2()) return v1;
187  else return v2;
188 }
G4TriangularFacet fFacet1
double mag2() const
G4TriangularFacet fFacet2
G4ThreeVector Distance(const G4ThreeVector &p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Distance() [2/3]

G4double G4QuadrangularFacet::Distance ( const G4ThreeVector p,
G4double  minDist 
)
virtual

Implements G4VFacet.

Definition at line 192 of file G4QuadrangularFacet.cc.

194 {
195  G4double dist = Distance(p).mag();
196  return dist;
197 }
double mag() const
double G4double
Definition: G4Types.hh:76
G4ThreeVector Distance(const G4ThreeVector &p)
Here is the call graph for this function:

◆ Distance() [3/3]

G4double G4QuadrangularFacet::Distance ( const G4ThreeVector p,
G4double  minDist,
const G4bool  outgoing 
)
virtual

Implements G4VFacet.

Definition at line 201 of file G4QuadrangularFacet.cc.

203 {
204  G4double dist;
205 
206  G4ThreeVector v = Distance(p);
208  if ( ((dir > dirTolerance) && (!outgoing))
209  || ((dir < -dirTolerance) && outgoing))
210  dist = kInfinity;
211  else
212  dist = v.mag();
213  return dist;
214 }
static const G4double kInfinity
Definition: geomdefs.hh:42
G4ThreeVector GetSurfaceNormal() const
TDirectory * dir
static const G4double dirTolerance
Definition: G4VFacet.hh:101
double mag() const
double dot(const Hep3Vector &) const
double G4double
Definition: G4Types.hh:76
G4ThreeVector Distance(const G4ThreeVector &p)
Here is the call graph for this function:

◆ Extent()

G4double G4QuadrangularFacet::Extent ( const G4ThreeVector  axis)
virtual

Implements G4VFacet.

Definition at line 218 of file G4QuadrangularFacet.cc.

219 {
220  G4double ss = 0;
221 
222  for (G4int i = 0; i <= 3; ++i)
223  {
224  G4double sp = GetVertex(i).dot(axis);
225  if (sp > ss) ss = sp;
226  }
227  return ss;
228 }
G4ThreeVector GetVertex(G4int i) const
int G4int
Definition: G4Types.hh:78
double dot(const Hep3Vector &) const
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ GetArea()

G4double G4QuadrangularFacet::GetArea ( )
virtual

Implements G4VFacet.

Definition at line 266 of file G4QuadrangularFacet.cc.

267 {
268  G4double area = fFacet1.GetArea() + fFacet2.GetArea();
269  return area;
270 }
G4TriangularFacet fFacet1
G4TriangularFacet fFacet2
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ GetCircumcentre()

G4ThreeVector G4QuadrangularFacet::GetCircumcentre ( ) const
inlinevirtual

Implements G4VFacet.

Definition at line 142 of file G4QuadrangularFacet.hh.

143 {
144  return fCircumcentre;
145 }

◆ GetClone()

G4VFacet * G4QuadrangularFacet::GetClone ( )
virtual

Implements G4VFacet.

Definition at line 171 of file G4QuadrangularFacet.cc.

172 {
174  GetVertex(2), GetVertex(3),
175  ABSOLUTE);
176  return c;
177 }
G4ThreeVector GetVertex(G4int i) const
G4QuadrangularFacet(const G4ThreeVector &Pt0, const G4ThreeVector &vt1, const G4ThreeVector &vt2, const G4ThreeVector &vt3, G4FacetVertexType)
Here is the call graph for this function:

◆ GetEntityType()

G4String G4QuadrangularFacet::GetEntityType ( ) const
virtual

Implements G4VFacet.

Definition at line 274 of file G4QuadrangularFacet.cc.

275 {
276  return "G4QuadrangularFacet";
277 }

◆ GetNumberOfVertices()

G4int G4QuadrangularFacet::GetNumberOfVertices ( ) const
inlinevirtual

Implements G4VFacet.

Definition at line 126 of file G4QuadrangularFacet.hh.

127 {
128  return 4;
129 }

◆ GetPointOnFace()

G4ThreeVector G4QuadrangularFacet::GetPointOnFace ( ) const
virtual

Implements G4VFacet.

Definition at line 255 of file G4QuadrangularFacet.cc.

256 {
257  G4ThreeVector pr = (G4RandFlat::shoot(0.,1.) < 0.5)
259  return pr;
260 }
ThreeVector shoot(const G4int Ap, const G4int Af)
G4TriangularFacet fFacet1
G4ThreeVector GetPointOnFace() const
G4TriangularFacet fFacet2
Here is the call graph for this function:

◆ GetRadius()

G4double G4QuadrangularFacet::GetRadius ( ) const
inlinevirtual

Implements G4VFacet.

Definition at line 137 of file G4QuadrangularFacet.hh.

138 {
139  return fRadius;
140 }

◆ GetSurfaceNormal()

G4ThreeVector G4QuadrangularFacet::GetSurfaceNormal ( ) const
virtual

Implements G4VFacet.

Definition at line 281 of file G4QuadrangularFacet.cc.

282 {
283  return fFacet1.GetSurfaceNormal();
284 }
G4TriangularFacet fFacet1
G4ThreeVector GetSurfaceNormal() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVertex()

G4ThreeVector G4QuadrangularFacet::GetVertex ( G4int  i) const
inlinevirtual

Implements G4VFacet.

Definition at line 131 of file G4QuadrangularFacet.hh.

132 {
133  return i == 3 ? fFacet2.GetVertex(2) : fFacet1.GetVertex(i);
134 }
G4TriangularFacet fFacet1
G4TriangularFacet fFacet2
G4ThreeVector GetVertex(G4int i) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVertexIndex()

G4int G4QuadrangularFacet::GetVertexIndex ( G4int  i) const
inlineprivatevirtual

Implements G4VFacet.

Definition at line 179 of file G4QuadrangularFacet.hh.

180 {
181  return i == 3 ? fFacet2.GetVertexIndex(2) : fFacet1.GetVertexIndex(i);
182 }
G4TriangularFacet fFacet1
G4TriangularFacet fFacet2
G4int GetVertexIndex(G4int i) const
Here is the call graph for this function:

◆ Intersect()

G4bool G4QuadrangularFacet::Intersect ( const G4ThreeVector p,
const G4ThreeVector v,
const G4bool  outgoing,
G4double distance,
G4double distFromSurface,
G4ThreeVector normal 
)
virtual

Implements G4VFacet.

Definition at line 232 of file G4QuadrangularFacet.cc.

238 {
239  G4bool intersect =
240  fFacet1.Intersect(p,v,outgoing,distance,distFromSurface,normal);
241  if (!intersect) intersect =
242  fFacet2.Intersect(p,v,outgoing,distance,distFromSurface,normal);
243  if (!intersect)
244  {
245  distance = distFromSurface = kInfinity;
246  normal.set(0,0,0);
247  }
248  return intersect;
249 }
void set(double x, double y, double z)
G4TriangularFacet fFacet1
G4bool Intersect(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool outgoing, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal)
static const G4double kInfinity
Definition: geomdefs.hh:42
bool G4bool
Definition: G4Types.hh:79
G4TriangularFacet fFacet2
Here is the call graph for this function:

◆ IsDefined()

G4bool G4QuadrangularFacet::IsDefined ( ) const
inlinevirtual

Implements G4VFacet.

Definition at line 174 of file G4QuadrangularFacet.hh.

175 {
176  return fFacet1.IsDefined();
177 }
G4TriangularFacet fFacet1
G4bool IsDefined() const
Here is the call graph for this function:

◆ operator=()

G4QuadrangularFacet & G4QuadrangularFacet::operator= ( const G4QuadrangularFacet right)

Definition at line 157 of file G4QuadrangularFacet.cc.

158 {
159  if (this == &rhs)
160  return *this;
161 
162  fFacet1 = rhs.fFacet1;
163  fFacet2 = rhs.fFacet2;
164  fRadius = 0.0;
165 
166  return *this;
167 }
G4TriangularFacet fFacet1
G4TriangularFacet fFacet2

◆ SetVertex()

void G4QuadrangularFacet::SetVertex ( G4int  i,
const G4ThreeVector val 
)
inlinevirtual

Implements G4VFacet.

Definition at line 147 of file G4QuadrangularFacet.hh.

148 {
149  switch (i)
150  {
151  case 0:
152  fFacet1.SetVertex(0, val);
153  fFacet2.SetVertex(0, val);
154  break;
155  case 1:
156  fFacet1.SetVertex(1, val);
157  break;
158  case 2:
159  fFacet1.SetVertex(2, val);
160  fFacet2.SetVertex(1, val);
161  break;
162  case 3:
163  fFacet2.SetVertex(2, val);
164  break;
165  }
166 }
G4TriangularFacet fFacet1
void SetVertex(G4int i, const G4ThreeVector &val)
G4TriangularFacet fFacet2
Here is the call graph for this function:

◆ SetVertexIndex()

void G4QuadrangularFacet::SetVertexIndex ( G4int  i,
G4int  val 
)
inlineprivatevirtual

Implements G4VFacet.

Definition at line 185 of file G4QuadrangularFacet.hh.

186 {
187  switch (i)
188  {
189  case 0:
190  fFacet1.SetVertexIndex(0, val);
191  fFacet2.SetVertexIndex(0, val);
192  break;
193  case 1:
194  fFacet1.SetVertexIndex(1, val);
195  break;
196  case 2:
197  fFacet1.SetVertexIndex(2, val);
198  fFacet2.SetVertexIndex(1, val);
199  break;
200  case 3:
201  fFacet2.SetVertexIndex(2, val);
202  break;
203  }
204 }
G4TriangularFacet fFacet1
void SetVertexIndex(G4int i, G4int j)
G4TriangularFacet fFacet2
Here is the call graph for this function:

◆ SetVertices()

void G4QuadrangularFacet::SetVertices ( std::vector< G4ThreeVector > *  v)
inlinevirtual

Implements G4VFacet.

Definition at line 168 of file G4QuadrangularFacet.hh.

169 {
172 }
G4TriangularFacet fFacet1
void SetVertices(std::vector< G4ThreeVector > *v)
G4TriangularFacet fFacet2
Here is the call graph for this function:

Member Data Documentation

◆ fCircumcentre

G4ThreeVector G4QuadrangularFacet::fCircumcentre
private

Definition at line 117 of file G4QuadrangularFacet.hh.

◆ fFacet1

G4TriangularFacet G4QuadrangularFacet::fFacet1
private

Definition at line 119 of file G4QuadrangularFacet.hh.

◆ fFacet2

G4TriangularFacet G4QuadrangularFacet::fFacet2
private

Definition at line 119 of file G4QuadrangularFacet.hh.

◆ fRadius

G4double G4QuadrangularFacet::fRadius
private

Definition at line 116 of file G4QuadrangularFacet.hh.


The documentation for this class was generated from the following files: