[831] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
[850] | 27 | // $Id: G4PolyhedraSide.hh,v 1.11 2008/05/15 11:41:59 gcosmo Exp $ |
---|
| 28 | // GEANT4 tag $Name: HEAD $ |
---|
[831] | 29 | // |
---|
| 30 | // |
---|
| 31 | // -------------------------------------------------------------------- |
---|
| 32 | // GEANT 4 class header file |
---|
| 33 | // |
---|
| 34 | // |
---|
| 35 | // G4PolyhedraSide |
---|
| 36 | // |
---|
| 37 | // Class description: |
---|
| 38 | // |
---|
| 39 | // Class implementing a face that represents one segmented side |
---|
| 40 | // of a polyhedra: |
---|
| 41 | // |
---|
| 42 | // G4PolyhedraSide( const G4PolyhedraSideRZ *prevRZ, |
---|
| 43 | // const G4PolyhedraSideRZ *tail, |
---|
| 44 | // const G4PolyhedraSideRZ *head, |
---|
| 45 | // const G4PolyhedraSideRZ *nextRZ, |
---|
| 46 | // G4int numSide, |
---|
| 47 | // G4double phiStart, G4double phiTotal, |
---|
| 48 | // G4bool phiIsOpen, G4bool isAllBehind=false ) |
---|
| 49 | // |
---|
| 50 | // Values for r1,z1 and r2,z2 should be specified in clockwise |
---|
| 51 | // order in (r,z). |
---|
| 52 | |
---|
| 53 | // Author: |
---|
| 54 | // David C. Williams (davidw@scipp.ucsc.edu) |
---|
| 55 | // -------------------------------------------------------------------- |
---|
| 56 | |
---|
| 57 | #ifndef G4PolyhedraSide_hh |
---|
| 58 | #define G4PolyhedraSide_hh |
---|
| 59 | |
---|
| 60 | #include "G4VCSGface.hh" |
---|
| 61 | |
---|
| 62 | class G4IntersectingCone; |
---|
| 63 | |
---|
| 64 | struct G4PolyhedraSideRZ |
---|
| 65 | { |
---|
| 66 | G4double r, z; // start of vector |
---|
| 67 | }; |
---|
| 68 | |
---|
| 69 | class G4PolyhedraSide : public G4VCSGface |
---|
| 70 | { |
---|
| 71 | |
---|
[850] | 72 | public: // with description |
---|
[831] | 73 | |
---|
| 74 | G4PolyhedraSide( const G4PolyhedraSideRZ *prevRZ, |
---|
| 75 | const G4PolyhedraSideRZ *tail, |
---|
| 76 | const G4PolyhedraSideRZ *head, |
---|
| 77 | const G4PolyhedraSideRZ *nextRZ, |
---|
| 78 | G4int numSide, |
---|
| 79 | G4double phiStart, G4double phiTotal, |
---|
| 80 | G4bool phiIsOpen, G4bool isAllBehind=false ); |
---|
| 81 | virtual ~G4PolyhedraSide(); |
---|
| 82 | |
---|
| 83 | G4PolyhedraSide( const G4PolyhedraSide &source ); |
---|
| 84 | G4PolyhedraSide& operator=( const G4PolyhedraSide &source ); |
---|
| 85 | |
---|
| 86 | G4bool Intersect( const G4ThreeVector &p, const G4ThreeVector &v, |
---|
| 87 | G4bool outgoing, G4double surfTolerance, |
---|
| 88 | G4double &distance, G4double &distFromSurface, |
---|
| 89 | G4ThreeVector &normal, G4bool &allBehind ); |
---|
| 90 | |
---|
| 91 | G4double Distance( const G4ThreeVector &p, G4bool outgoing ); |
---|
| 92 | |
---|
| 93 | EInside Inside( const G4ThreeVector &p, G4double tolerance, |
---|
| 94 | G4double *bestDistance ); |
---|
| 95 | |
---|
| 96 | G4ThreeVector Normal( const G4ThreeVector &p, G4double *bestDistance ); |
---|
| 97 | |
---|
| 98 | G4double Extent( const G4ThreeVector axis ); |
---|
| 99 | |
---|
| 100 | void CalculateExtent( const EAxis axis, |
---|
| 101 | const G4VoxelLimits &voxelLimit, |
---|
| 102 | const G4AffineTransform &tranform, |
---|
| 103 | G4SolidExtentList &extentList ); |
---|
| 104 | |
---|
| 105 | G4VCSGface *Clone() { return new G4PolyhedraSide( *this ); } |
---|
[850] | 106 | |
---|
[831] | 107 | public: // without description |
---|
| 108 | |
---|
[850] | 109 | // Methods used for GetPointOnSurface() |
---|
| 110 | |
---|
| 111 | G4double SurfaceTriangle( G4ThreeVector p1, |
---|
| 112 | G4ThreeVector p2, |
---|
| 113 | G4ThreeVector p3, |
---|
| 114 | G4ThreeVector *p4 ); |
---|
| 115 | G4ThreeVector GetPointOnPlane( G4ThreeVector p0, G4ThreeVector p1, |
---|
| 116 | G4ThreeVector p2, G4ThreeVector p3, |
---|
| 117 | G4double *Area ); |
---|
| 118 | G4double SurfaceArea(); |
---|
| 119 | G4ThreeVector GetPointOnFace(); |
---|
| 120 | |
---|
| 121 | public: // without description |
---|
| 122 | |
---|
[831] | 123 | G4PolyhedraSide(__void__&); |
---|
| 124 | // Fake default constructor for usage restricted to direct object |
---|
| 125 | // persistency for clients requiring preallocation of memory for |
---|
| 126 | // persistifiable objects. |
---|
| 127 | |
---|
| 128 | protected: |
---|
| 129 | |
---|
| 130 | // |
---|
| 131 | // A couple internal data structures |
---|
| 132 | // |
---|
| 133 | struct sG4PolyhedraSideVec; // Secret recipe for allowing |
---|
| 134 | friend struct sG4PolyhedraSideVec; // protected nested structures |
---|
| 135 | |
---|
| 136 | typedef struct sG4PolyhedraSideEdge |
---|
| 137 | { |
---|
| 138 | G4ThreeVector normal; // Unit normal to this edge |
---|
| 139 | G4ThreeVector corner[2]; // The two corners of this phi edge |
---|
| 140 | G4ThreeVector cornNorm[2]; // The normals of these corners |
---|
| 141 | } G4PolyhedraSideEdge; |
---|
| 142 | |
---|
| 143 | typedef struct sG4PolyhedraSideVec |
---|
| 144 | { |
---|
| 145 | G4ThreeVector normal, // Normal (point out of the shape) |
---|
| 146 | center, // Point in center of side |
---|
| 147 | surfPhi, // Unit vector on surface pointing along phi |
---|
| 148 | surfRZ; // Unit vector on surface pointing along R/Z |
---|
| 149 | G4PolyhedraSideEdge *edges[2]; // The phi boundary edges to this side |
---|
| 150 | // [0]=low phi [1]=high phi |
---|
| 151 | G4ThreeVector edgeNorm[2]; // RZ edge normals [i] at {r[i],z[i]} |
---|
| 152 | } G4PolyhedraSideVec; |
---|
| 153 | |
---|
| 154 | G4bool IntersectSidePlane( const G4ThreeVector &p, const G4ThreeVector &v, |
---|
| 155 | const G4PolyhedraSideVec vec, |
---|
| 156 | G4double normSign, |
---|
| 157 | G4double surfTolerance, |
---|
| 158 | G4double &distance, |
---|
| 159 | G4double &distFromSurface ); |
---|
| 160 | |
---|
| 161 | G4int LineHitsSegments( const G4ThreeVector &p, |
---|
| 162 | const G4ThreeVector &v, |
---|
| 163 | G4int *i1, G4int *i2 ); |
---|
| 164 | |
---|
| 165 | G4int ClosestPhiSegment( G4double phi ); |
---|
| 166 | |
---|
| 167 | G4int PhiSegment( G4double phi ); |
---|
| 168 | |
---|
| 169 | G4double DistanceToOneSide( const G4ThreeVector &p, |
---|
| 170 | const G4PolyhedraSideVec &vec, |
---|
| 171 | G4double *normDist ); |
---|
| 172 | |
---|
| 173 | G4double DistanceAway( const G4ThreeVector &p, |
---|
| 174 | const G4PolyhedraSideVec &vec, |
---|
| 175 | G4double *normDist ); |
---|
| 176 | |
---|
| 177 | void CopyStuff( const G4PolyhedraSide &source ); |
---|
| 178 | |
---|
| 179 | protected: |
---|
| 180 | |
---|
| 181 | G4int numSide; // Number sides |
---|
| 182 | G4double r[2], z[2]; // r, z parameters, in specified order |
---|
| 183 | G4double startPhi, // Start phi (0 to 2pi), if phiIsOpen |
---|
| 184 | deltaPhi, // Delta phi (0 to 2pi), if phiIsOpen |
---|
| 185 | endPhi; // End phi (>startPhi), if phiIsOpen |
---|
| 186 | G4bool phiIsOpen; // True if there is a phi slice |
---|
| 187 | G4bool allBehind; // True if the entire solid is "behind" this face |
---|
| 188 | |
---|
| 189 | G4IntersectingCone *cone; // Our intersecting cone |
---|
| 190 | |
---|
| 191 | G4PolyhedraSideVec *vecs; // Vector set for each facet of our face |
---|
| 192 | G4PolyhedraSideEdge *edges; // The edges belong to vecs |
---|
| 193 | G4double lenRZ, // RZ length of each side |
---|
| 194 | lenPhi[2]; // Phi dimensions of each side |
---|
| 195 | G4double edgeNorm; // Normal in RZ/Phi space to each side |
---|
| 196 | |
---|
| 197 | private: |
---|
| 198 | |
---|
| 199 | G4double kCarTolerance; // Geometrical surface thickness |
---|
[850] | 200 | G4double fSurfaceArea; // Surface Area |
---|
[831] | 201 | }; |
---|
| 202 | |
---|
| 203 | #endif |
---|