G4Trap.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: G4Trap.hh 69788 2013-05-15 12:06:57Z gcosmo $
00028 //
00029 // 
00030 // --------------------------------------------------------------------
00031 // GEANT 4 class header file
00032 //
00033 // G4Trap
00034 //
00035 // Class description:
00036 //
00037 //   A G4Trap is a general trapezoid: The faces perpendicular to the
00038 //   z planes are trapezia, and their centres are not necessarily on
00039 //   a line parallel to the z axis.
00040 //
00041 //   Note that of the 11 parameters described below, only 9 are really
00042 //   independent - a check for planarity is made in the calculation of the
00043 //   equation for each plane. If the planes are not parallel, a call to
00044 //   G4Exception is made.
00045 //
00046 //      pDz     Half-length along the z-axis
00047 //      pTheta  Polar angle of the line joining the centres of the faces
00048 //              at -/+pDz
00049 //      pPhi    Azimuthal angle of the line joing the centre of the face at
00050 //              -pDz to the centre of the face at +pDz
00051 //      pDy1    Half-length along y of the face at -pDz
00052 //      pDx1    Half-length along x of the side at y=-pDy1 of the face at -pDz
00053 //      pDx2    Half-length along x of the side at y=+pDy1 of the face at -pDz
00054 //      pAlp1   Angle with respect to the y axis from the centre of the side
00055 //              at y=-pDy1 to the centre at y=+pDy1 of the face at -pDz
00056 //
00057 //      pDy2    Half-length along y of the face at +pDz
00058 //      pDx3    Half-length along x of the side at y=-pDy2 of the face at +pDz
00059 //      pDx4    Half-length along x of the side at y=+pDy2 of the face at +pDz
00060 //      pAlp2   Angle with respect to the y axis from the centre of the side
00061 //              at y=-pDy2 to the centre at y=+pDy2 of the face at +pDz
00062 //
00063 //
00064 //   Member Data:
00065 //
00066 //      fDz     Half-length along the z axis
00067 //      fTthetaCphi = std::tan(pTheta)*std::cos(pPhi)
00068 //      fTthetaSphi = std::tan(pTheta)*std::sin(pPhi)
00069 //      These combinations are suitable for creation of the trapezoid corners
00070 //
00071 //      fDy1    Half-length along y of the face at -fDz
00072 //      fDx1    Half-length along x of the side at y=-fDy1 of the face at -fDz
00073 //      fDx2    Half-length along x of the side at y=+fDy1 of the face at -fDz
00074 //      fTalpha1   Tan of Angle with respect to the y axis from the centre of
00075 //                 the side at y=-fDy1 to the centre at y=+fDy1 of the face
00076 //                 at -fDz
00077 //
00078 //      fDy2    Half-length along y of the face at +fDz
00079 //      fDx3    Half-length along x of the side at y=-fDy2 of the face at +fDz
00080 //      fDx4    Half-length along x of the side at y=+fDy2 of the face at +fDz
00081 //      fTalpha2   Tan of Angle with respect to the y axis from the centre of
00082 //                 the side at y=-fDy2 to the centre at y=+fDy2 of the face
00083 //                 at +fDz
00084 //
00085 //      TrapSidePlane fPlanes[4]   Plane equations of the faces not at +/-fDz
00086 //                                 NOTE: order is important !!!
00087 
00088 // History:
00089 //
00090 // 23.3.94 P.Kent: Old C++ code converted to tolerant geometry
00091 // 9.9.96  V.Grichine: Final modifications before to commit 
00092 // 1.11.96 V.Grichine: Costructors for Right Angular Wedge from STEP, G4Trd/Para
00093 // 8.12.97 J.Allison: Added "nominal" contructor and method SetAllParameters.
00094 // --------------------------------------------------------------------
00095 
00096 #ifndef G4Trap_HH
00097 #define G4Trap_HH
00098 
00099 #include "G4CSGSolid.hh"
00100 
00101 struct TrapSidePlane
00102 {
00103     G4double a,b,c,d;    // Normal unit vector (a,b,c)  and offset (d)
00104         // => Ax+By+Cz+D=0  
00105 };
00106 
00107 class G4Trap : public G4CSGSolid
00108 {
00109 
00110   public:  // with description
00111 
00112     G4Trap( const G4String& pName,
00113                   G4double pDz,
00114                   G4double pTheta, G4double pPhi,
00115                   G4double pDy1, G4double pDx1, G4double pDx2,
00116                   G4double pAlp1,
00117                   G4double pDy2, G4double pDx3, G4double pDx4,
00118                   G4double pAlp2 );
00119       //
00120       // The most general constructor for G4Trap which prepares plane
00121       // equations and corner coordinates from parameters
00122 
00123     G4Trap( const G4String& pName,
00124             const G4ThreeVector pt[8] ) ;
00125       //
00126       // Prepares plane equations and parameters from corner coordinates
00127 
00128     G4Trap( const G4String& pName,
00129                   G4double pZ,
00130                   G4double pY,
00131                   G4double pX, G4double pLTX );
00132       //
00133       // Constructor for Right Angular Wedge from STEP (assumes pLTX<=pX)
00134 
00135     G4Trap( const G4String& pName,
00136                   G4double pDx1,  G4double pDx2,
00137                   G4double pDy1,  G4double pDy2,
00138                   G4double pDz );
00139       //
00140       // Constructor for G4Trd       
00141 
00142      G4Trap(const G4String& pName,
00143                   G4double pDx, G4double pDy, G4double pDz,
00144                   G4double pAlpha, G4double pTheta, G4double pPhi );
00145       //
00146       // Constructor for G4Para
00147 
00148      G4Trap( const G4String& pName );
00149        //
00150        // Constructor for "nominal" G4Trap whose parameters are to be set
00151        // by a G4VPVParamaterisation later
00152 
00153      virtual ~G4Trap() ;
00154        //
00155        // Destructor
00156 
00157   // Accessors
00158 
00159     inline G4double GetZHalfLength()  const;
00160     inline G4double GetYHalfLength1() const;
00161     inline G4double GetXHalfLength1() const;
00162     inline G4double GetXHalfLength2() const;
00163     inline G4double GetTanAlpha1()    const;
00164     inline G4double GetYHalfLength2() const;
00165     inline G4double GetXHalfLength3() const;
00166     inline G4double GetXHalfLength4() const;
00167     inline G4double GetTanAlpha2()    const;
00168       //
00169       // Returns coordinates of unit vector along straight
00170       // line joining centers of -/+fDz planes   
00171 
00172     inline TrapSidePlane GetSidePlane( G4int n ) const;
00173     inline G4ThreeVector GetSymAxis() const;
00174 
00175   // Modifiers
00176 
00177     void SetAllParameters ( G4double pDz,
00178                             G4double pTheta,
00179                             G4double pPhi,
00180                             G4double pDy1,
00181                             G4double pDx1,
00182                             G4double pDx2,
00183                             G4double pAlp1,
00184                             G4double pDy2,
00185                             G4double pDx3,
00186                             G4double pDx4,
00187                             G4double pAlp2 );
00188                                 
00189   // Methods for solid
00190     
00191     inline G4double GetCubicVolume();
00192     inline G4double GetSurfaceArea();
00193 
00194     void ComputeDimensions(       G4VPVParameterisation* p,
00195                             const G4int n,
00196                             const G4VPhysicalVolume* pRep );
00197 
00198     G4bool CalculateExtent( const EAxis pAxis,
00199                             const G4VoxelLimits& pVoxelLimit,
00200                             const G4AffineTransform& pTransform,
00201                                   G4double& pMin, G4double& pMax ) const;    
00202         
00203     EInside Inside( const G4ThreeVector& p ) const;
00204     
00205     G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const;
00206 
00207     G4double DistanceToIn(const G4ThreeVector& p, const G4ThreeVector& v) const;
00208     
00209     G4double DistanceToIn( const G4ThreeVector& p ) const;
00210     
00211     G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
00212                            const G4bool calcNorm=false,
00213                                  G4bool *validNorm=0, G4ThreeVector *n=0) const;
00214          
00215     G4double DistanceToOut( const G4ThreeVector& p ) const;
00216 
00217     G4GeometryType GetEntityType() const;
00218 
00219     G4ThreeVector GetPointOnSurface() const;
00220 
00221     G4VSolid* Clone() const;
00222 
00223     std::ostream& StreamInfo( std::ostream& os ) const;
00224 
00225   // Visualisation functions
00226 
00227     void          DescribeYourselfTo ( G4VGraphicsScene& scene  ) const;
00228     G4Polyhedron* CreatePolyhedron   () const;
00229     G4NURBS*      CreateNURBS        () const;
00230 
00231   public:  // without description
00232 
00233     G4Trap(__void__&);
00234       // Fake default constructor for usage restricted to direct object
00235       // persistency for clients requiring preallocation of memory for
00236       // persistifiable objects.
00237 
00238     G4Trap(const G4Trap& rhs);
00239     G4Trap& operator=(const G4Trap& rhs); 
00240       // Copy constructor and assignment operator.
00241 
00242   protected:  // with description
00243 
00244     G4bool MakePlanes();
00245     G4bool MakePlane( const G4ThreeVector& p1,
00246                       const G4ThreeVector& p2,
00247                       const G4ThreeVector& p3, 
00248                       const G4ThreeVector& p4,
00249                             TrapSidePlane& plane ) ;
00250 
00251     G4ThreeVectorList*
00252     CreateRotatedVertices( const G4AffineTransform& pTransform ) const;
00253       //
00254       // Creates the List of transformed vertices in the format required
00255       // for G4CSGSolid:: ClipCrossSection and ClipBetweenSections
00256 
00257   private:
00258 
00259     G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
00260       // Algorithm for SurfaceNormal() following the original
00261       // specification for points not on the surface
00262 
00263     inline G4double GetFaceArea(const G4ThreeVector& p1,
00264                                 const G4ThreeVector& p2, 
00265                                 const G4ThreeVector& p3,
00266                                 const G4ThreeVector& p4);
00267       //
00268       // Provided four corners of plane in clockwise fashion,
00269       // it returns the area of finite face
00270 
00271     G4ThreeVector GetPointOnPlane(G4ThreeVector p0, G4ThreeVector p1, 
00272                                   G4ThreeVector p2, G4ThreeVector p3, 
00273                                   G4double& area) const;
00274       //
00275       // Returns a random point on the surface of one of the faces
00276 
00277   private:
00278 
00279     G4double fDz,fTthetaCphi,fTthetaSphi;
00280     G4double fDy1,fDx1,fDx2,fTalpha1;
00281     G4double fDy2,fDx3,fDx4,fTalpha2;
00282     TrapSidePlane fPlanes[4];
00283 
00284 };
00285 
00286 #include "G4Trap.icc"
00287 
00288 #endif

Generated on Mon May 27 17:50:03 2013 for Geant4 by  doxygen 1.4.7