Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/solids/specific/src/G4QuadrangularFacet.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/solids/specific/src/G4QuadrangularFacet.cc (Version 11.3.0) and /geometry/solids/specific/src/G4QuadrangularFacet.cc (Version 10.3.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration and of QinetiQ Ltd,   *
 20 // * subject to DEFCON 705 IPR conditions.         20 // * subject to DEFCON 705 IPR conditions.                            *
 21 // * By using,  copying,  modifying or  distri     21 // * By using,  copying,  modifying or  distributing the software (or *
 22 // * any work based  on the software)  you  ag     22 // * any work based  on the software)  you  agree  to acknowledge its *
 23 // * use  in  resulting  scientific  publicati     23 // * use  in  resulting  scientific  publications,  and indicate your *
 24 // * acceptance of all terms of the Geant4 Sof     24 // * acceptance of all terms of the Geant4 Software license.          *
 25 // *******************************************     25 // ********************************************************************
 26 //                                                 26 //
 27 // G4QuadrangularFacet class implementation.   << 
 28 //                                                 27 //
 29 // 31 October 2004 P R Truscott, QinetiQ Ltd,  <<  28 // $Id: G4QuadrangularFacet.cc 95945 2016-03-03 09:54:38Z gcosmo $
 30 // 12 October 2012 M Gayer, CERN               <<  29 //
 31 //                 New implementation reducing <<  30 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 32 //                 and considerable CPU speedu <<  31 //
 33 //                 implementation of G4Tessell <<  32 // CHANGE HISTORY
                                                   >>  33 // --------------
                                                   >>  34 //
                                                   >>  35 // 31 October 2004  P R Truscott, QinetiQ Ltd, UK - Created.
                                                   >>  36 //
                                                   >>  37 // 12 October 2012  M Gayer, CERN
                                                   >>  38 //                  New implementation reducing memory requirements by 50%,
                                                   >>  39 //                  and considerable CPU speedup together with the new
                                                   >>  40 //                  implementation of G4TessellatedSolid.
                                                   >>  41 //
 34 // 29 February 2016 E Tcherniaev, CERN             42 // 29 February 2016 E Tcherniaev, CERN
 35 //                 Added exhaustive tests to c <<  43 //                  Added exhaustive tests to catch various problems with a
 36 //                 quadrangular facet: colline <<  44 //                  quadrangular facet: collinear vertices, non planar surface,
 37 //                 degenerate, concave or self <<  45 //                  degenerate, concave or self intersecting quadrilateral.
 38 // ------------------------------------------- <<  46 //
                                                   >>  47 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 39                                                    48 
 40 #include "G4QuadrangularFacet.hh"                  49 #include "G4QuadrangularFacet.hh"
 41 #include "geomdefs.hh"                             50 #include "geomdefs.hh"
 42 #include "Randomize.hh"                            51 #include "Randomize.hh"
 43                                                    52  
 44 using namespace std;                               53 using namespace std;
 45                                                    54 
 46 //////////////////////////////////////////////     55 ///////////////////////////////////////////////////////////////////////////////
 47 //                                                 56 //
 48 // Constructing two adjacent G4TriangularFacet <<  57 // !!!THIS IS A FUDGE!!!  IT'S TWO ADJACENT G4TRIANGULARFACETS
 49 // Not efficient, but practical...             <<  58 // --- NOT EFFICIENT BUT PRACTICAL.
 50 //                                                 59 //
 51 G4QuadrangularFacet::G4QuadrangularFacet (cons <<  60 G4QuadrangularFacet::G4QuadrangularFacet (const G4ThreeVector &vt0,
 52                                           cons <<  61                                           const G4ThreeVector &vt1,
 53                                           cons <<  62                                           const G4ThreeVector &vt2,
 54                                           cons <<  63                                           const G4ThreeVector &vt3,
 55                                                    64                                                 G4FacetVertexType vertexType)
 56 {                                                  65 {
 57   G4double delta   =  1.0 * kCarTolerance; //      66   G4double delta   =  1.0 * kCarTolerance; // dimension tolerance
 58   G4double epsilon = 0.01 * kCarTolerance; //      67   G4double epsilon = 0.01 * kCarTolerance; // planarity tolerance
 59                                                    68 
                                                   >>  69   fRadius = 0.0;
                                                   >>  70 
 60   G4ThreeVector e1, e2, e3;                        71   G4ThreeVector e1, e2, e3;
 61   SetVertex(0, vt0);                               72   SetVertex(0, vt0);
 62   if (vertexType == ABSOLUTE)                      73   if (vertexType == ABSOLUTE)
 63   {                                                74   {
 64     SetVertex(1, vt1);                             75     SetVertex(1, vt1);
 65     SetVertex(2, vt2);                             76     SetVertex(2, vt2);
 66     SetVertex(3, vt3);                             77     SetVertex(3, vt3);
 67                                                    78 
 68     e1 = vt1 - vt0;                                79     e1 = vt1 - vt0;
 69     e2 = vt2 - vt0;                                80     e2 = vt2 - vt0;
 70     e3 = vt3 - vt0;                                81     e3 = vt3 - vt0;
 71   }                                                82   }
 72   else                                             83   else
 73   {                                                84   {
 74     SetVertex(1, vt0 + vt1);                       85     SetVertex(1, vt0 + vt1);
 75     SetVertex(2, vt0 + vt2);                       86     SetVertex(2, vt0 + vt2);
 76     SetVertex(3, vt0 + vt3);                       87     SetVertex(3, vt0 + vt3);
 77                                                    88 
 78     e1 = vt1;                                      89     e1 = vt1;
 79     e2 = vt2;                                      90     e2 = vt2;
 80     e3 = vt3;                                      91     e3 = vt3;
 81   }                                                92   }
 82                                                    93 
 83   // Check length of sides and diagonals           94   // Check length of sides and diagonals
 84   //                                               95   //
 85   G4double leng1 = e1.mag();                       96   G4double leng1 = e1.mag();
 86   G4double leng2 = (e2-e1).mag();                  97   G4double leng2 = (e2-e1).mag();
 87   G4double leng3 = (e3-e2).mag();                  98   G4double leng3 = (e3-e2).mag();
 88   G4double leng4 = e3.mag();                       99   G4double leng4 = e3.mag();
 89                                                   100 
 90   G4double diag1 = e2.mag();                      101   G4double diag1 = e2.mag();
 91   G4double diag2 = (e3-e1).mag();                 102   G4double diag2 = (e3-e1).mag();
 92                                                   103 
 93   if (leng1 <= delta || leng2 <= delta || leng    104   if (leng1 <= delta || leng2 <= delta || leng3 <= delta || leng4 <= delta ||
 94       diag1 <= delta || diag2 <= delta)           105       diag1 <= delta || diag2 <= delta)
 95   {                                               106   {
 96     ostringstream message;                        107     ostringstream message;
 97     message << "Sides/diagonals of facet are t    108     message << "Sides/diagonals of facet are too small." << G4endl
 98             << "P0 = " << GetVertex(0) << G4en    109             << "P0 = " << GetVertex(0) << G4endl
 99             << "P1 = " << GetVertex(1) << G4en    110             << "P1 = " << GetVertex(1) << G4endl
100             << "P2 = " << GetVertex(2) << G4en    111             << "P2 = " << GetVertex(2) << G4endl
101             << "P3 = " << GetVertex(3) << G4en    112             << "P3 = " << GetVertex(3) << G4endl
102             << "Side1 length (P0->P1) = " << l    113             << "Side1 length (P0->P1) = " << leng1 << G4endl
103             << "Side2 length (P1->P2) = " << l    114             << "Side2 length (P1->P2) = " << leng2 << G4endl
104             << "Side3 length (P2->P3) = " << l    115             << "Side3 length (P2->P3) = " << leng3 << G4endl
105             << "Side4 length (P3->P0) = " << l    116             << "Side4 length (P3->P0) = " << leng4 << G4endl
106             << "Diagonal1 length (P0->P2) = "     117             << "Diagonal1 length (P0->P2) = " << diag1 << G4endl
107             << "Diagonal2 length (P1->P3) = "     118             << "Diagonal2 length (P1->P3) = " << diag2;
108     G4Exception("G4QuadrangularFacet::G4Quadra    119     G4Exception("G4QuadrangularFacet::G4QuadrangularFacet()",
109                 "GeomSolids1001", JustWarning,    120                 "GeomSolids1001", JustWarning, message);
110     return;                                       121     return;
111   }                                               122   }
112                                                   123 
113   // Check that vertices are not collinear        124   // Check that vertices are not collinear
114   //                                              125   //
115   G4double s1 = (e1.cross(e2)).mag()*0.5;         126   G4double s1 = (e1.cross(e2)).mag()*0.5;
116   G4double s2 = ((e2-e1).cross(e3-e2)).mag()*0    127   G4double s2 = ((e2-e1).cross(e3-e2)).mag()*0.5;
117   G4double s3 = (e2.cross(e3)).mag()*0.5;         128   G4double s3 = (e2.cross(e3)).mag()*0.5;
118   G4double s4 = (e1.cross(e3)).mag()*0.5;         129   G4double s4 = (e1.cross(e3)).mag()*0.5;
119                                                   130 
120   G4double h1 = 2.*s1 / std::max(std::max(leng    131   G4double h1 = 2.*s1 / std::max(std::max(leng1,leng2),diag1);
121   G4double h2 = 2.*s2 / std::max(std::max(leng    132   G4double h2 = 2.*s2 / std::max(std::max(leng2,leng3),diag2);
122   G4double h3 = 2.*s3 / std::max(std::max(leng    133   G4double h3 = 2.*s3 / std::max(std::max(leng3,leng4),diag1);
123   G4double h4 = 2.*s4 / std::max(std::max(leng    134   G4double h4 = 2.*s4 / std::max(std::max(leng4,leng1),diag2);
124                                                   135    
125   if (h1 <= delta || h2 <= delta || h3 <= delt    136   if (h1 <= delta || h2 <= delta || h3 <= delta || h4 <= delta )
126   {                                               137   {
127     ostringstream message;                        138     ostringstream message;
128     message << "Facet has three or more collin    139     message << "Facet has three or more collinear vertices." << G4endl
129             << "P0 = " << GetVertex(0) << G4en    140             << "P0 = " << GetVertex(0) << G4endl
130             << "P1 = " << GetVertex(1) << G4en    141             << "P1 = " << GetVertex(1) << G4endl
131             << "P2 = " << GetVertex(2) << G4en    142             << "P2 = " << GetVertex(2) << G4endl
132             << "P3 = " << GetVertex(3) << G4en    143             << "P3 = " << GetVertex(3) << G4endl
133             << "Smallest heights:" << G4endl   << 144             << "Height in P0-P1-P2 = " << h1 << G4endl
134             << "  in triangle P0-P1-P2 = " <<  << 145             << "Height in P1-P2-P3 = " << h2 << G4endl
135             << "  in triangle P1-P2-P3 = " <<  << 146             << "Height in P2-P3-P4 = " << h3 << G4endl
136             << "  in triangle P2-P3-P0 = " <<  << 147             << "Height in P4-P0-P1 = " << h4;
137             << "  in triangle P3-P0-P1 = " <<  << 
138     G4Exception("G4QuadrangularFacet::G4Quadra    148     G4Exception("G4QuadrangularFacet::G4QuadrangularFacet()",
139           "GeomSolids1001", JustWarning, messa    149           "GeomSolids1001", JustWarning, message);
140     return;                                       150     return;
141   }                                               151   }
142                                                   152 
143   // Check that vertices are coplanar by compu    153   // Check that vertices are coplanar by computing minimal
144   // height of tetrahedron comprising of verti    154   // height of tetrahedron comprising of vertices
145   //                                              155   //
146   G4double smax = std::max( std::max(s1,s2), s    156   G4double smax = std::max( std::max(s1,s2), std::max(s3,s4) ); 
147   G4double hmin = 0.5 * std::fabs( e1.dot(e2.c    157   G4double hmin = 0.5 * std::fabs( e1.dot(e2.cross(e3)) ) / smax;
148   if (hmin >= epsilon)                            158   if (hmin >= epsilon)
149   {                                               159   {
150     ostringstream message;                        160     ostringstream message;
151     message << "Facet is not planar." << G4end    161     message << "Facet is not planar." << G4endl
152             << "Disrepancy = " << hmin << G4en    162             << "Disrepancy = " << hmin << G4endl
153             << "P0 = " << GetVertex(0) << G4en    163             << "P0 = " << GetVertex(0) << G4endl
154             << "P1 = " << GetVertex(1) << G4en    164             << "P1 = " << GetVertex(1) << G4endl
155             << "P2 = " << GetVertex(2) << G4en    165             << "P2 = " << GetVertex(2) << G4endl
156             << "P3 = " << GetVertex(3);           166             << "P3 = " << GetVertex(3);
157     G4Exception("G4QuadrangularFacet::G4Quadra    167     G4Exception("G4QuadrangularFacet::G4QuadrangularFacet()",
158           "GeomSolids1001", JustWarning, messa    168           "GeomSolids1001", JustWarning, message);
159     return;                                       169     return;
160   }                                               170   }
161                                                   171   
162   // Check that facet is convex by computing c    172   // Check that facet is convex by computing crosspoint 
163   // of diagonals                                 173   // of diagonals
164   //                                              174   //
165   G4ThreeVector normal = e2.cross(e3-e1);         175   G4ThreeVector normal = e2.cross(e3-e1);
166   G4double s = kInfinity, t = kInfinity, magni    176   G4double s = kInfinity, t = kInfinity, magnitude2 = normal.mag2();
167   if (magnitude2 > delta*delta) // check: magn    177   if (magnitude2 > delta*delta) // check: magnitude2 != 0.
168   {                                               178   {
169     s = normal.dot(e1.cross(e3-e1)) / magnitud    179     s = normal.dot(e1.cross(e3-e1)) / magnitude2;
170     t = normal.dot(e1.cross(e2))    / magnitud    180     t = normal.dot(e1.cross(e2))    / magnitude2;
171   }                                               181   }
172   if (s <= 0. || s >= 1. || t <= 0. || t >= 1.    182   if (s <= 0. || s >= 1. || t <= 0. || t >= 1.)
173   {                                               183   {
174     ostringstream message;                        184     ostringstream message;
175     message << "Facet is not convex." << G4end    185     message << "Facet is not convex." << G4endl
176             << "Parameters of crosspoint of di    186             << "Parameters of crosspoint of diagonals: "
177             << s << " and " << t << G4endl        187             << s << " and " << t << G4endl
178             << "should both be within (0,1) ra    188             << "should both be within (0,1) range" << G4endl
179       << "P0 = " << GetVertex(0) << G4endl        189       << "P0 = " << GetVertex(0) << G4endl
180       << "P1 = " << GetVertex(1) << G4endl        190       << "P1 = " << GetVertex(1) << G4endl
181       << "P2 = " << GetVertex(2) << G4endl        191       << "P2 = " << GetVertex(2) << G4endl
182       << "P3 = " << GetVertex(3);                 192       << "P3 = " << GetVertex(3);
183     G4Exception("G4QuadrangularFacet::G4Quadra    193     G4Exception("G4QuadrangularFacet::G4QuadrangularFacet()",
184           "GeomSolids1001", JustWarning, messa    194           "GeomSolids1001", JustWarning, message);
185     return;                                       195     return;
186   }                                               196   }
187                                                   197 
188   // Define facet                                 198   // Define facet
189   //                                              199   //
190   fFacet1 = G4TriangularFacet(GetVertex(0),Get    200   fFacet1 = G4TriangularFacet(GetVertex(0),GetVertex(1),GetVertex(2),ABSOLUTE);
191   fFacet2 = G4TriangularFacet(GetVertex(0),Get    201   fFacet2 = G4TriangularFacet(GetVertex(0),GetVertex(2),GetVertex(3),ABSOLUTE);
192                                                   202 
193   normal = normal.unit();                         203   normal = normal.unit();
194   fFacet1.SetSurfaceNormal(normal);               204   fFacet1.SetSurfaceNormal(normal);
195   fFacet2.SetSurfaceNormal(normal);               205   fFacet2.SetSurfaceNormal(normal);
196                                                   206   
197   G4ThreeVector vtmp = 0.5 * (e1 + e2);           207   G4ThreeVector vtmp = 0.5 * (e1 + e2);
198   fCircumcentre = GetVertex(0) + vtmp;            208   fCircumcentre = GetVertex(0) + vtmp;
199   G4double radiusSqr = vtmp.mag2();               209   G4double radiusSqr = vtmp.mag2();
200   fRadius = std::sqrt(radiusSqr);                 210   fRadius = std::sqrt(radiusSqr);
201   // 29.02.2016 Remark by E.Tcherniaev: comput    211   // 29.02.2016 Remark by E.Tcherniaev: computation
202   // of fCircumcenter and fRadius is wrong, ho    212   // of fCircumcenter and fRadius is wrong, however
203   // it did not create any problem till now.      213   // it did not create any problem till now.
204   // Bizarre! Need to investigate!                214   // Bizarre! Need to investigate!
205 }                                                 215 }
206                                                   216 
207 //////////////////////////////////////////////    217 ///////////////////////////////////////////////////////////////////////////////
208 //                                                218 //
209 G4QuadrangularFacet::~G4QuadrangularFacet () = << 219 G4QuadrangularFacet::~G4QuadrangularFacet ()
                                                   >> 220 {
                                                   >> 221 }
210                                                   222 
211 //////////////////////////////////////////////    223 ///////////////////////////////////////////////////////////////////////////////
212 //                                                224 //
213 G4QuadrangularFacet::G4QuadrangularFacet (cons << 225 G4QuadrangularFacet::G4QuadrangularFacet (const G4QuadrangularFacet &rhs)
214   : G4VFacet(rhs)                                 226   : G4VFacet(rhs)
215 {                                                 227 {
216   fFacet1 = rhs.fFacet1;                          228   fFacet1 = rhs.fFacet1;
217   fFacet2 = rhs.fFacet2;                          229   fFacet2 = rhs.fFacet2;
218   fRadius = 0.0;                                  230   fRadius = 0.0;
219 }                                                 231 }
220                                                   232 
221 //////////////////////////////////////////////    233 ///////////////////////////////////////////////////////////////////////////////
222 //                                                234 //
223 G4QuadrangularFacet &                             235 G4QuadrangularFacet &
224 G4QuadrangularFacet::operator=(const G4Quadran << 236 G4QuadrangularFacet::operator=(const G4QuadrangularFacet &rhs)
225 {                                                 237 {
226   if (this == &rhs)  return *this;             << 238   if (this == &rhs)
                                                   >> 239     return *this;
227                                                   240 
228   fFacet1 = rhs.fFacet1;                          241   fFacet1 = rhs.fFacet1;
229   fFacet2 = rhs.fFacet2;                          242   fFacet2 = rhs.fFacet2;
230   fRadius = 0.0;                                  243   fRadius = 0.0;
231                                                   244 
232   return *this;                                   245   return *this;
233 }                                                 246 }
234                                                   247 
235 //////////////////////////////////////////////    248 ///////////////////////////////////////////////////////////////////////////////
236 //                                                249 //
237 G4VFacet* G4QuadrangularFacet::GetClone ()     << 250 G4VFacet *G4QuadrangularFacet::GetClone ()
238 {                                                 251 {
239   auto c = new G4QuadrangularFacet (GetVertex( << 252   G4QuadrangularFacet *c = new G4QuadrangularFacet (GetVertex(0), GetVertex(1),
240                                     GetVertex( << 253                                                     GetVertex(2), GetVertex(3),
                                                   >> 254                                                     ABSOLUTE);
241   return c;                                       255   return c;
242 }                                                 256 }
243                                                   257 
244 //////////////////////////////////////////////    258 ///////////////////////////////////////////////////////////////////////////////
245 //                                                259 //
246 G4ThreeVector G4QuadrangularFacet::Distance (c << 260 G4ThreeVector G4QuadrangularFacet::Distance (const G4ThreeVector &p)
247 {                                                 261 {
248   G4ThreeVector v1 = fFacet1.Distance(p);         262   G4ThreeVector v1 = fFacet1.Distance(p);
249   G4ThreeVector v2 = fFacet2.Distance(p);         263   G4ThreeVector v2 = fFacet2.Distance(p);
250                                                   264 
251   if (v1.mag2() < v2.mag2()) return v1;           265   if (v1.mag2() < v2.mag2()) return v1;
252   else return v2;                                 266   else return v2;
253 }                                                 267 }
254                                                   268 
255 //////////////////////////////////////////////    269 ///////////////////////////////////////////////////////////////////////////////
256 //                                                270 //
257 G4double G4QuadrangularFacet::Distance (const  << 271 G4double G4QuadrangularFacet::Distance (const G4ThreeVector &p,
258                                                   272                                               G4double)
259 {                                                 273 {  
260   G4double dist = Distance(p).mag();              274   G4double dist = Distance(p).mag();
261   return dist;                                    275   return dist;
262 }                                                 276 }
263                                                   277 
264 //////////////////////////////////////////////    278 ///////////////////////////////////////////////////////////////////////////////
265 //                                                279 //
266 G4double G4QuadrangularFacet::Distance (const  << 280 G4double G4QuadrangularFacet::Distance (const G4ThreeVector &p, G4double,
267                                         const     281                                         const G4bool outgoing)
268 {                                                 282 {
269   G4double dist;                                  283   G4double dist;
270                                                   284 
271   G4ThreeVector v = Distance(p);                  285   G4ThreeVector v = Distance(p);
272   G4double dir = v.dot(GetSurfaceNormal());       286   G4double dir = v.dot(GetSurfaceNormal());
273   if ( ((dir > dirTolerance) && (!outgoing))      287   if ( ((dir > dirTolerance) && (!outgoing))
274     || ((dir < -dirTolerance) && outgoing))       288     || ((dir < -dirTolerance) && outgoing))
275     dist = kInfinity;                             289     dist = kInfinity;
276   else                                            290   else 
277     dist = v.mag();                               291     dist = v.mag();
278   return dist;                                    292   return dist;
279 }                                                 293 }
280                                                   294 
281 //////////////////////////////////////////////    295 ///////////////////////////////////////////////////////////////////////////////
282 //                                                296 //
283 G4double G4QuadrangularFacet::Extent (const G4    297 G4double G4QuadrangularFacet::Extent (const G4ThreeVector axis)
284 {                                                 298 {
285   G4double ss  = 0;                               299   G4double ss  = 0;
286                                                   300 
287   for (G4int i = 0; i <= 3; ++i)                  301   for (G4int i = 0; i <= 3; ++i)
288   {                                               302   {
289     G4double sp = GetVertex(i).dot(axis);         303     G4double sp = GetVertex(i).dot(axis);
290     if (sp > ss) ss = sp;                         304     if (sp > ss) ss = sp;
291   }                                               305   }
292   return ss;                                      306   return ss;
293 }                                                 307 }
294                                                   308 
295 //////////////////////////////////////////////    309 ///////////////////////////////////////////////////////////////////////////////
296 //                                                310 //
297 G4bool G4QuadrangularFacet::Intersect (const G << 311 G4bool G4QuadrangularFacet::Intersect (const G4ThreeVector &p,
298                                        const G << 312                                        const G4ThreeVector &v,
299                                              G    313                                              G4bool outgoing,
300                                              G << 314                                              G4double &distance,
301                                              G << 315                                              G4double &distFromSurface,
302                                              G << 316                                              G4ThreeVector &normal)
303 {                                                 317 {
304   G4bool intersect =                              318   G4bool intersect =
305     fFacet1.Intersect(p,v,outgoing,distance,di    319     fFacet1.Intersect(p,v,outgoing,distance,distFromSurface,normal);
306   if (!intersect) intersect =                     320   if (!intersect) intersect =
307     fFacet2.Intersect(p,v,outgoing,distance,di    321     fFacet2.Intersect(p,v,outgoing,distance,distFromSurface,normal);
308   if (!intersect)                                 322   if (!intersect)
309   {                                               323   {
310     distance = distFromSurface = kInfinity;       324     distance = distFromSurface = kInfinity;
311     normal.set(0,0,0);                            325     normal.set(0,0,0);
312   }                                               326   }
313   return intersect;                               327   return intersect;
314 }                                                 328 }
315                                                   329 
316 //////////////////////////////////////////////    330 ///////////////////////////////////////////////////////////////////////////////
317 //                                                331 //
318 // Auxiliary method to get a uniform random po    332 // Auxiliary method to get a uniform random point on the facet
319 //                                                333 //
320 G4ThreeVector G4QuadrangularFacet::GetPointOnF    334 G4ThreeVector G4QuadrangularFacet::GetPointOnFace() const
321 {                                                 335 {
322   G4double s1 = fFacet1.GetArea();                336   G4double s1 = fFacet1.GetArea();
323   G4double s2 = fFacet2.GetArea();                337   G4double s2 = fFacet2.GetArea();
324   return ((s1+s2)*G4UniformRand() < s1) ?         338   return ((s1+s2)*G4UniformRand() < s1) ?
325     fFacet1.GetPointOnFace() : fFacet2.GetPoin    339     fFacet1.GetPointOnFace() : fFacet2.GetPointOnFace();
326 }                                                 340 }
327                                                   341 
328 //////////////////////////////////////////////    342 ///////////////////////////////////////////////////////////////////////////////
329 //                                                343 //
330 // Auxiliary method for returning the surface     344 // Auxiliary method for returning the surface area
331 //                                                345 //
332 G4double G4QuadrangularFacet::GetArea() const     346 G4double G4QuadrangularFacet::GetArea() const
333 {                                                 347 {
334   G4double area = fFacet1.GetArea() + fFacet2.    348   G4double area = fFacet1.GetArea() + fFacet2.GetArea();
335   return area;                                    349   return area;
336 }                                                 350 }
337                                                   351 
338 //////////////////////////////////////////////    352 ///////////////////////////////////////////////////////////////////////////////
339 //                                                353 //
340 G4String G4QuadrangularFacet::GetEntityType ()    354 G4String G4QuadrangularFacet::GetEntityType () const
341 {                                                 355 {
342   return "G4QuadrangularFacet";                   356   return "G4QuadrangularFacet";
343 }                                                 357 }
344                                                   358 
345 //////////////////////////////////////////////    359 ///////////////////////////////////////////////////////////////////////////////
346 //                                                360 //
347 G4ThreeVector G4QuadrangularFacet::GetSurfaceN    361 G4ThreeVector G4QuadrangularFacet::GetSurfaceNormal () const
348 {                                                 362 {
349   return fFacet1.GetSurfaceNormal();              363   return fFacet1.GetSurfaceNormal();
350 }                                                 364 }
351                                                   365