Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // >> 23 // >> 24 // $Id: G4PolyPhiFace.hh,v 1.4 2001/07/11 10:00:14 gunter Exp $ >> 25 // GEANT4 tag $Name: geant4-04-01 $ >> 26 // >> 27 // >> 28 // -------------------------------------------------------------------- >> 29 // GEANT 4 class header file >> 30 // >> 31 // 26 // G4PolyPhiFace 32 // G4PolyPhiFace 27 // 33 // 28 // Class description: 34 // Class description: 29 // 35 // 30 // Definition of a face that bounds a polyco 36 // Definition of a face that bounds a polycone or polyhedra when 31 // it has a phi opening: 37 // it has a phi opening: 32 // 38 // 33 // G4PolyPhiFace( const G4ReduciblePolygon* << 39 // G4PolyPhiFace( const G4ReduciblePolygon *rz, 34 // G4double phi, 40 // G4double phi, 35 // G4double deltaPhi, 41 // G4double deltaPhi, 36 // G4double phiOther ) 42 // G4double phiOther ) 37 // 43 // 38 // Specifically: a face that lies on a plane 44 // Specifically: a face that lies on a plane that passes through 39 // the z axis. It has boundaries that are st 45 // the z axis. It has boundaries that are straight lines of arbitrary 40 // length and direction, but with corners aw 46 // length and direction, but with corners aways on the same side of 41 // the z axis. 47 // the z axis. 42 48 43 // Author: David C. Williams (davidw@scipp.ucs << 49 // Author: >> 50 // David C. Williams (davidw@scipp.ucsc.edu) 44 // ------------------------------------------- 51 // -------------------------------------------------------------------- 45 #ifndef G4POLYPHIFACE_HH << 52 46 #define G4POLYPHIFACE_HH 1 << 53 #ifndef G4PolyPhiFace_hh >> 54 #define G4PolyPhiFace_hh 47 55 48 #include "G4VCSGface.hh" 56 #include "G4VCSGface.hh" 49 #include "G4TwoVector.hh" << 50 57 51 class G4ReduciblePolygon; 58 class G4ReduciblePolygon; 52 59 53 struct G4PolyPhiFaceVertex << 60 typedef struct { 54 { << 61 G4double x, y, r, z; // position 55 G4double x, y, r, z; // position << 62 G4double rNorm, 56 G4double rNorm, << 63 zNorm; // r/z normal 57 zNorm; // r/z normal << 64 G4ThreeVector norm3D; // 3D normal 58 G4ThreeVector norm3D; // 3D normal << 65 } G4PolyPhiFaceVertex; 59 << 66 60 // Needed for Triangulation Algorithm << 67 typedef struct { 61 // << 68 G4PolyPhiFaceVertex *v0, *v1; // Corners 62 G4bool ear; << 69 G4double tr, tz, // Unit vector along edge 63 G4PolyPhiFaceVertex *next,*prev; << 70 length; // Length of edge 64 }; << 71 G4ThreeVector norm3D; // 3D edge normal vector 65 << 72 } G4PolyPhiFaceEdge; 66 struct G4PolyPhiFaceEdge << 67 { << 68 G4PolyPhiFaceEdge() = default; << 69 G4PolyPhiFaceVertex *v0{nullptr}, *v1{nullp << 70 G4double tr{.0}, tz{0.}, // Unit vect << 71 length{0.}; // Length of << 72 G4ThreeVector norm3D; // 3D edge n << 73 }; << 74 73 75 class G4PolyPhiFace : public G4VCSGface 74 class G4PolyPhiFace : public G4VCSGface 76 { 75 { 77 76 78 public: << 77 public: // with description 79 78 80 G4PolyPhiFace( const G4ReduciblePolygon* r << 79 G4PolyPhiFace( const G4ReduciblePolygon *rz, 81 G4double phi, G4doubl << 80 G4double phi, G4double deltaPhi, G4double phiOther ); 82 // Constructor. << 81 // Constructor. 83 // Points r,z should be supplied in cloc << 82 // Points r,z should be supplied in clockwise order in r,z. 84 // For example: << 83 // For example: 85 // [1]---------[2] << 84 // [1]---------[2] ^ R 86 // | | << 85 // | | | 87 // | | << 86 // | | +--> z 88 // [0]---------[3] << 87 // [0]---------[3] 89 << 88 90 ~G4PolyPhiFace() override; << 89 virtual ~G4PolyPhiFace(); 91 // Destructor. Removes edges and corners << 90 // Destructor. Removes edges and corners. 92 << 91 93 G4PolyPhiFace( const G4PolyPhiFace &source << 92 G4PolyPhiFace( const G4PolyPhiFace &source ); 94 G4PolyPhiFace& operator=( const G4PolyPhiF << 93 G4PolyPhiFace& operator=( const G4PolyPhiFace &source ); 95 // Copy constructor and assgnment operat << 94 // Copy constructor and assgnment operator. 96 << 95 97 G4bool Intersect( const G4ThreeVector& p, << 96 G4bool Intersect( const G4ThreeVector &p, const G4ThreeVector &v, 98 G4bool outgoing, G << 97 G4bool outgoing, G4double surfTolerance, 99 G4double& distance << 98 G4double &distance, G4double &distFromSurface, 100 G4ThreeVector& nor << 99 G4ThreeVector &normal, G4bool &allBehind ); 101 << 100 102 G4double Distance( const G4ThreeVector& p, << 101 G4double Distance( const G4ThreeVector &p, G4bool outgoing ); 103 << 102 104 EInside Inside( const G4ThreeVector& p, G4 << 103 EInside Inside( const G4ThreeVector &p, G4double tolerance, 105 G4double* bestDistan << 104 G4double *bestDistance ); 106 << 105 107 G4ThreeVector Normal( const G4ThreeVector& << 106 G4ThreeVector Normal( const G4ThreeVector &p, G4double *bestDistance ); 108 G4double* best << 107 109 << 108 G4double Extent( const G4ThreeVector axis ); 110 G4double Extent( const G4ThreeVector axis << 109 111 << 110 void CalculateExtent( const EAxis axis, 112 void CalculateExtent( const EAxis axis, << 111 const G4VoxelLimits &voxelLimit, 113 const G4VoxelLimits << 112 const G4AffineTransform &tranform, 114 const G4AffineTransf << 113 G4SolidExtentList &extentList ); 115 G4SolidExtentL << 114 116 << 115 inline G4VCSGface *Clone(); 117 inline G4VCSGface* Clone() override; << 116 // Allocates on the heap a clone of this face. 118 // Allocates on the heap a clone of this << 117 119 << 118 public: // without description 120 G4double SurfaceArea() override; << 119 121 G4double SurfaceTriangle( const G4ThreeVec << 120 void Diagnose( G4VSolid *solid ); 122 const G4ThreeVec << 121 // Throw an exception if something is found inconsistent with 123 G4ThreeVector GetPointOnFace() override; << 122 // the solid. For debugging purposes only 124 // Auxiliary methods for determination o << 125 << 126 G4PolyPhiFace(__void__&); << 127 // Fake default constructor for usage re << 128 // persistency for clients requiring pre << 129 // persistifiable objects. << 130 << 131 void Diagnose( G4VSolid* solid ); << 132 // Throw an exception if something is fo << 133 // the solid. For debugging purposes onl << 134 123 135 protected: << 136 << 137 G4bool InsideEdgesExact( G4double r, G4dou << 138 const G4ThreeVect << 139 // Decide if the point in r,z is inside << 140 // **but** do so consistently with other << 141 << 142 G4bool InsideEdges( G4double r, G4double z << 143 G4bool InsideEdges( G4double r, G4double z << 144 G4PolyPhiFaceVertex** << 145 G4ThreeVector** head3D << 146 // Decide if the point in r,z is inside << 147 << 148 inline G4double ExactZOrder( G4double z, << 149 G4double qx, << 150 const G4ThreeVector << 151 G4double norm << 152 const G4PolyPhiFace << 153 // Decide precisely whether a trajectory << 154 // or exactly passes through the z posit << 155 << 156 void CopyStuff( const G4PolyPhiFace& sourc << 157 << 158 // Functions used for Triangulation in Cas << 159 // The triangulation is used for GetPointO << 160 << 161 G4double Area2( const G4TwoVector& a, cons << 162 // Calculation of 2*Area of Triangle wit << 163 << 164 G4bool Left( const G4TwoVector& a, const G << 165 G4bool LeftOn( const G4TwoVector& a, const << 166 G4bool Collinear( const G4TwoVector& a, co << 167 // Boolean functions for sign of Surface << 168 << 169 G4bool IntersectProp( const G4TwoVector& a << 170 const G4TwoVector& c << 171 // Boolean function for finding proper i << 172 // line segments (a,b) and (c,d). << 173 << 174 G4bool Between( const G4TwoVector& a, cons << 175 // Boolean function for determining if p << 176 // where the three points (a,b,c) are on << 177 << 178 G4bool Intersect( const G4TwoVector& a, co << 179 const G4TwoVector& c, co << 180 // Boolean function for finding proper i << 181 // of two line segments (a,b) and (c,d). << 182 << 183 G4bool Diagonalie( G4PolyPhiFaceVertex* a, << 184 // Boolean Diagonalie help to determine << 185 // of segment (a,b) is convex or reflex. << 186 << 187 G4bool InCone( G4PolyPhiFaceVertex *a, G4P << 188 // Boolean function for determining if b << 189 // where a is the center of the cone. << 190 << 191 G4bool Diagonal( G4PolyPhiFaceVertex* a, G << 192 // Boolean function for determining if D << 193 // inside Polycone or PolyHedra. << 194 << 195 void EarInit(); << 196 // Initialisation for Triangulisation by << 197 // For details see "Computational Geomet << 198 << 199 void Triangulate(); << 200 // Triangularisation by ear tips for Pol << 201 // For details see "Computational Geomet << 202 // NOTE: a copy of the shape is made and << 203 // order to have a list of triangl << 204 // method GetPointOnFace(). << 205 124 206 protected: 125 protected: 207 126 208 G4int numEdges = 0; // Number of edges << 127 G4PolyPhiFaceEdge *edges; // The edges of the face 209 G4PolyPhiFaceEdge* edges = nullptr; << 128 G4PolyPhiFaceVertex *corners; // And the corners 210 G4PolyPhiFaceVertex* corners = nullptr; << 129 G4int numEdges; // Number of edges 211 G4ThreeVector normal; // Normal uni << 130 G4ThreeVector normal; // Normal unit vector 212 G4ThreeVector radial; // Unit vecto << 131 G4ThreeVector radial; // Unit vector along radial direction 213 G4ThreeVector surface; // Point on s << 132 G4ThreeVector surface; // Point on surface 214 G4ThreeVector surface_point; // Auxiliary << 133 G4double rMin, rMax, // Extent in r 215 // method Get << 134 zMin, zMax; // Extent in z 216 G4double rMin, rMax, // Extent in r << 135 G4bool allBehind; // True if the polycone/polyhedra 217 zMin, zMax; // Extent in z << 136 // is behind the place of this face 218 G4bool allBehind = false; // True if the p << 137 219 // is behind the << 138 G4bool InsideEdgesExact( G4double r, G4double z, G4double normSign, 220 G4double kCarTolerance; // Surface th << 139 const G4ThreeVector &p, const G4ThreeVector &v ); 221 G4double fSurfaceArea = 0.0; // Surface Ar << 140 // Decide if the point in r,z is inside the edges of our face, 222 G4PolyPhiFaceVertex* triangles = nullptr; << 141 // **but** do so consistently with other faces. 223 // Auxiliary pointer to 'corners' used f << 142 224 // Copy structure, changing the structur << 143 G4bool InsideEdges( G4double r, G4double z ); >> 144 G4bool InsideEdges( G4double r, G4double z, G4double *distRZ2, >> 145 G4PolyPhiFaceVertex **base3Dnorm=0, >> 146 G4ThreeVector **head3Dnorm=0 ); >> 147 // Decide if the point in r,z is inside the edges of our face. >> 148 >> 149 inline G4double ExactZOrder( G4double z, >> 150 G4double qx, G4double qy, G4double qz, >> 151 const G4ThreeVector &v, >> 152 G4double normSign, >> 153 const G4PolyPhiFaceVertex *vert ) const; >> 154 // Decide precisely whether a trajectory passes to the left, right, >> 155 // or exactly passes through the z position of a vertex point in face. >> 156 >> 157 void CopyStuff( const G4PolyPhiFace &source ); 225 }; 158 }; 226 159 227 #include "G4PolyPhiFace.icc" 160 #include "G4PolyPhiFace.icc" 228 161 229 #endif 162 #endif 230 163