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