G4PolyhedraSide.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4PolyhedraSide.hh 67011 2013-01-29 16:17:41Z gcosmo $
00028 //
00029 // 
00030 // --------------------------------------------------------------------
00031 // GEANT 4 class header file
00032 //
00033 //
00034 // G4PolyhedraSide
00035 //
00036 // Class description:
00037 //
00038 //   Class implementing a face that represents one segmented side
00039 //   of a polyhedra:
00040 //
00041 //   G4PolyhedraSide( const G4PolyhedraSideRZ *prevRZ,
00042 //                    const G4PolyhedraSideRZ *tail,
00043 //                    const G4PolyhedraSideRZ *head,
00044 //                    const G4PolyhedraSideRZ *nextRZ,
00045 //                          G4int    numSide,
00046 //                          G4double phiStart, G4double phiTotal, 
00047 //                          G4bool phiIsOpen,  G4bool isAllBehind=false )
00048 //
00049 //   Values for r1,z1 and r2,z2 should be specified in clockwise
00050 //   order in (r,z).
00051 
00052 // Author: 
00053 //   David C. Williams (davidw@scipp.ucsc.edu)
00054 // --------------------------------------------------------------------
00055 
00056 #ifndef G4PolyhedraSide_hh
00057 #define G4PolyhedraSide_hh
00058 
00059 #include "G4VCSGface.hh"
00060 
00061 class G4IntersectingCone;
00062 
00063 struct G4PolyhedraSideRZ
00064 {
00065   G4double r, z;  // start of vector
00066 };
00067 
00068 class G4PolyhedraSide : public G4VCSGface
00069 {
00070 
00071   public:  // with description
00072 
00073     G4PolyhedraSide( const G4PolyhedraSideRZ *prevRZ,
00074                      const G4PolyhedraSideRZ *tail,
00075                      const G4PolyhedraSideRZ *head,
00076                      const G4PolyhedraSideRZ *nextRZ,
00077                            G4int    numSide,
00078                            G4double phiStart, G4double phiTotal, 
00079                            G4bool phiIsOpen,  G4bool isAllBehind=false );
00080     virtual ~G4PolyhedraSide();
00081   
00082     G4PolyhedraSide( const G4PolyhedraSide &source );
00083     G4PolyhedraSide& operator=( const G4PolyhedraSide &source );
00084   
00085     G4bool Intersect( const G4ThreeVector &p, const G4ThreeVector &v,  
00086                             G4bool outgoing, G4double surfTolerance,
00087                             G4double &distance, G4double &distFromSurface,
00088                             G4ThreeVector &normal, G4bool &allBehind );
00089 
00090     G4double Distance( const G4ThreeVector &p, G4bool outgoing );
00091   
00092     EInside Inside( const G4ThreeVector &p, G4double tolerance, 
00093                           G4double *bestDistance );
00094   
00095     G4ThreeVector Normal( const G4ThreeVector &p,  G4double *bestDistance );
00096 
00097     G4double Extent( const G4ThreeVector axis );
00098   
00099     void CalculateExtent( const EAxis axis, 
00100                           const G4VoxelLimits &voxelLimit,
00101                           const G4AffineTransform &tranform,
00102                                 G4SolidExtentList &extentList );
00103 
00104     G4VCSGface *Clone() { return new G4PolyhedraSide( *this ); }
00105 
00106   public:  // without description
00107 
00108     // Methods used for GetPointOnSurface()
00109 
00110     G4double SurfaceTriangle( G4ThreeVector p1,
00111                               G4ThreeVector p2,
00112                               G4ThreeVector p3,
00113                               G4ThreeVector *p4 );
00114     G4ThreeVector GetPointOnPlane( G4ThreeVector p0, G4ThreeVector p1, 
00115                                    G4ThreeVector p2, G4ThreeVector p3,
00116                                    G4double *Area );
00117     G4double SurfaceArea();
00118     G4ThreeVector GetPointOnFace();  
00119 
00120   public:  // without description
00121 
00122     G4PolyhedraSide(__void__&);
00123       // Fake default constructor for usage restricted to direct object
00124       // persistency for clients requiring preallocation of memory for
00125       // persistifiable objects.
00126 
00127   protected:
00128 
00129     //
00130     // A couple internal data structures
00131     //
00132     struct sG4PolyhedraSideVec;         // Secret recipe for allowing
00133     friend struct sG4PolyhedraSideVec;  // protected nested structures
00134 
00135     typedef struct sG4PolyhedraSideEdge
00136     {
00137       G4ThreeVector  normal;       // Unit normal to this edge
00138       G4ThreeVector  corner[2];    // The two corners of this phi edge
00139       G4ThreeVector  cornNorm[2];  // The normals of these corners
00140     } G4PolyhedraSideEdge;
00141   
00142     typedef struct sG4PolyhedraSideVec
00143     {
00144       G4ThreeVector  normal,   // Normal (point out of the shape)
00145                      center,   // Point in center of side
00146                      surfPhi,  // Unit vector on surface pointing along phi
00147                      surfRZ;   // Unit vector on surface pointing along R/Z
00148       G4PolyhedraSideEdge *edges[2];  // The phi boundary edges to this side 
00149                                       //     [0]=low phi [1]=high phi
00150       G4ThreeVector  edgeNorm[2];     // RZ edge normals [i] at {r[i],z[i]}
00151     } G4PolyhedraSideVec;
00152 
00153     G4bool IntersectSidePlane( const G4ThreeVector &p, const G4ThreeVector &v,
00154                                const G4PolyhedraSideVec& vec,
00155                                      G4double normSign, 
00156                                      G4double surfTolerance,
00157                                      G4double &distance,
00158                                      G4double &distFromSurface );
00159 
00160     G4int LineHitsSegments( const G4ThreeVector &p,
00161                             const G4ThreeVector &v,
00162                                   G4int *i1, G4int *i2 );
00163 
00164     G4int ClosestPhiSegment( G4double phi );
00165   
00166     G4int PhiSegment( G4double phi );
00167 
00168     G4double GetPhi( const G4ThreeVector& p );
00169 
00170     G4double DistanceToOneSide( const G4ThreeVector &p,
00171                                 const G4PolyhedraSideVec &vec,
00172                                       G4double *normDist );
00173 
00174     G4double DistanceAway( const G4ThreeVector &p,
00175                            const G4PolyhedraSideVec &vec,
00176                                  G4double *normDist );
00177              
00178     void CopyStuff( const G4PolyhedraSide &source );
00179 
00180   protected:
00181 
00182     G4int   numSide;      // Number sides
00183     G4double r[2], z[2];  // r, z parameters, in specified order
00184     G4double startPhi,    // Start phi (0 to 2pi), if phiIsOpen
00185              deltaPhi,    // Delta phi (0 to 2pi), if phiIsOpen
00186              endPhi;      // End phi (>startPhi), if phiIsOpen
00187     G4bool   phiIsOpen;   // True if there is a phi slice
00188     G4bool   allBehind;   // True if the entire solid is "behind" this face
00189   
00190     G4IntersectingCone  *cone;  // Our intersecting cone
00191   
00192     G4PolyhedraSideVec  *vecs;    // Vector set for each facet of our face
00193     G4PolyhedraSideEdge *edges;   // The edges belong to vecs
00194     G4double    lenRZ,      // RZ length of each side
00195                 lenPhi[2];  // Phi dimensions of each side
00196     G4double    edgeNorm;   // Normal in RZ/Phi space to each side
00197 
00198   private:
00199 
00200     std::pair<G4ThreeVector, G4double> fPhi;  // Cached value for phi
00201     G4double kCarTolerance;  // Geometrical surface thickness
00202     G4double fSurfaceArea;   // Surface Area 
00203 };
00204 
00205 #endif

Generated on Mon May 27 17:49:23 2013 for Geant4 by  doxygen 1.4.7