Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4QuadrangularFacet Class Reference

#include <G4QuadrangularFacet.hh>

+ Inheritance 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
 
virtual G4int GetNumberOfVertices () const =0
 
virtual G4ThreeVector GetVertex (G4int i) const =0
 
virtual void SetVertex (G4int i, const G4ThreeVector &val)=0
 
virtual G4GeometryType GetEntityType () const =0
 
virtual G4ThreeVector GetSurfaceNormal () const =0
 
virtual G4bool IsDefined () const =0
 
virtual G4ThreeVector GetCircumcentre () const =0
 
virtual G4double GetRadius () const =0
 
virtual G4VFacetGetClone ()=0
 
virtual G4double Distance (const G4ThreeVector &, G4double)=0
 
virtual G4double Distance (const G4ThreeVector &, G4double, const G4bool)=0
 
virtual G4double Extent (const G4ThreeVector)=0
 
virtual G4bool Intersect (const G4ThreeVector &, const G4ThreeVector &, const G4bool, G4double &, G4double &, G4ThreeVector &)=0
 
virtual G4double GetArea ()=0
 
virtual G4ThreeVector GetPointOnFace () const =0
 
void ApplyTranslation (const G4ThreeVector v)
 
std::ostream & StreamInfo (std::ostream &os) const
 
G4bool IsInside (const G4ThreeVector &p) const
 
virtual G4int AllocatedMemory ()=0
 
virtual void SetVertexIndex (G4int i, G4int j)=0
 
virtual G4int GetVertexIndex (G4int i) const =0
 
virtual void SetVertices (std::vector< G4ThreeVector > *vertices)=0
 

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{
60 G4ThreeVector e1, e2, e3;
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 {
97 fFacet1 = G4TriangularFacet (GetVertex(0),GetVertex(1),
99 fFacet2 = G4TriangularFacet (GetVertex(0),GetVertex(2),
101
104
105 G4ThreeVector normal12 = fFacet1.GetSurfaceNormal()
106 + fFacet2.GetSurfaceNormal();
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 G4cerr << endl;
125 G4cerr << "P0 = " << GetVertex(0) << endl;
126 G4cerr << "P1 = " << GetVertex(1) << endl;
127 G4cerr << "P2 = " << GetVertex(2) << endl;
128 G4cerr << "P3 = " << GetVertex(3) << endl;
129 G4cerr << "Side lengths = P0->P1" << length1 << endl;
130 G4cerr << "Side lengths = P1->P2" << length2 << endl;
131 G4cerr << "Side lengths = P2->P3" << length3 << endl;
132 G4cerr << "Side lengths = P3->P0" << length4 << endl;
133 G4cerr << endl;
134 fRadius = 0.0;
135 }
136}
@ JustWarning
double G4double
Definition: G4Types.hh:64
@ ABSOLUTE
Definition: G4VFacet.hh:56
G4DLLIMPORT std::ostream G4cerr
Hep3Vector unit() const
double mag2() const
Hep3Vector cross(const Hep3Vector &) const
double dot(const Hep3Vector &) const
double mag() const
void SetVertex(G4int i, const G4ThreeVector &val)
G4ThreeVector GetVertex(G4int i) const
void SetSurfaceNormal(G4ThreeVector normal)
G4ThreeVector GetSurfaceNormal() const
static const G4double kCarTolerance
Definition: G4VFacet.hh:102
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

◆ 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}

◆ ~G4QuadrangularFacet()

G4QuadrangularFacet::~G4QuadrangularFacet ( )

Definition at line 140 of file G4QuadrangularFacet.cc.

141{
142}

Member Function Documentation

◆ Distance() [1/3]

G4ThreeVector G4QuadrangularFacet::Distance ( const G4ThreeVector p)

Definition at line 181 of file G4QuadrangularFacet.cc.

182{
183 G4ThreeVector v1 = fFacet1.Distance(p);
184 G4ThreeVector v2 = fFacet2.Distance(p);
185
186 if (v1.mag2() < v2.mag2()) return v1;
187 else return v2;
188}
G4ThreeVector Distance(const G4ThreeVector &p)

Referenced by Distance().

◆ 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}
G4ThreeVector Distance(const G4ThreeVector &p)

◆ 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);
207 G4double dir = v.dot(GetSurfaceNormal());
208 if ( ((dir > dirTolerance) && (!outgoing))
209 || ((dir < -dirTolerance) && outgoing))
210 dist = kInfinity;
211 else
212 dist = v.mag();
213 return dist;
214}
G4ThreeVector GetSurfaceNormal() const
static const G4double dirTolerance
Definition: G4VFacet.hh:101

◆ 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}
int G4int
Definition: G4Types.hh:66

◆ 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}

◆ 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}

◆ 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)
258 ? fFacet1.GetPointOnFace() : fFacet2.GetPointOnFace();
259 return pr;
260}
G4ThreeVector GetPointOnFace() const

◆ 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}

Referenced by Distance().

◆ 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}
G4ThreeVector GetVertex(G4int i) const

Referenced by Extent(), G4QuadrangularFacet(), and GetClone().

◆ 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}
bool G4bool
Definition: G4Types.hh:67
void set(double x, double y, double z)
G4bool Intersect(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool outgoing, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal)

◆ IsDefined()

G4bool G4QuadrangularFacet::IsDefined ( ) const
inlinevirtual

Implements G4VFacet.

Definition at line 174 of file G4QuadrangularFacet.hh.

175{
176 return fFacet1.IsDefined();
177}
G4bool IsDefined() const

◆ 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}

◆ 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}
void SetVertex(G4int i, const G4ThreeVector &val)

Referenced by G4QuadrangularFacet().

◆ SetVertices()

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

Implements G4VFacet.

Definition at line 168 of file G4QuadrangularFacet.hh.

169{
170 fFacet1.SetVertices(v);
171 fFacet2.SetVertices(v);
172}
void SetVertices(std::vector< G4ThreeVector > *v)

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