Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:57

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4Polyhedra
0027 //
0028 // Class description:
0029 //
0030 //   Class implementing a CSG-like type "PGON" Geant 3.21 volume,
0031 //   inherited from class G4VCSGfaceted:
0032 //
0033 //   G4Polyhedra( const G4String& name,
0034 //                G4double phiStart,         - initial phi starting angle
0035 //                G4double phiTotal,         - total phi angle
0036 //                G4int numSide,             - number sides
0037 //                G4int numZPlanes,          - number of z planes
0038 //                const G4double zPlane[],   - position of z planes
0039 //                const G4double rInner[],   - tangent distance to inner surface
0040 //                const G4double rOuter[]  ) - tangent distance to outer surface
0041 //
0042 //   G4Polyhedra( const G4String& name,
0043 //                G4double phiStart,    - initial phi starting angle
0044 //                G4double phiTotal,    - total phi angle
0045 //                G4int    numSide,     - number sides
0046 //                G4int    numRZ,       - number corners in r,z space
0047 //                const G4double r[],   - r coordinate of these corners
0048 //                const G4double z[] )  - z coordinate of these corners
0049 
0050 // Author: David C. Williams (davidw@scipp.ucsc.edu)
0051 // --------------------------------------------------------------------
0052 #ifndef G4POLYHEDRA_HH
0053 #define G4POLYHEDRA_HH
0054 
0055 #include "G4GeomTypes.hh"
0056 
0057 #if defined(G4GEOM_USE_USOLIDS)
0058 #define G4GEOM_USE_UPOLYHEDRA 1
0059 #endif
0060 
0061 #if defined(G4GEOM_USE_UPOLYHEDRA)
0062   #define G4UPolyhedra G4Polyhedra
0063   #include "G4UPolyhedra.hh"
0064 #else
0065 
0066 #include "G4VCSGfaceted.hh"
0067 #include "G4PolyhedraSide.hh"
0068 #include "G4PolyhedraHistorical.hh"
0069 #include "G4Polyhedron.hh"
0070 
0071 class G4EnclosingCylinder;
0072 class G4ReduciblePolygon;
0073 
0074 class G4Polyhedra : public G4VCSGfaceted
0075 {
0076   public:
0077 
0078     G4Polyhedra(const G4String& name,
0079                       G4double phiStart,   // initial phi starting angle
0080                       G4double phiTotal,   // total phi angle
0081                       G4int numSide,       // number sides
0082                       G4int numZPlanes,    // number of z planes
0083                 const G4double zPlane[],   // position of z planes
0084                 const G4double rInner[],   // tangent distance to inner surface
0085                 const G4double rOuter[] ); // tangent distance to outer surface
0086 
0087     G4Polyhedra(const G4String& name,
0088                       G4double phiStart,   // initial phi starting angle
0089                       G4double phiTotal,   // total phi angle
0090                       G4int    numSide,    // number sides
0091                       G4int    numRZ,      // number corners in r,z space
0092                 const G4double r[],        // r coordinate of these corners
0093                 const G4double z[] );      // z coordinate of these corners
0094 
0095     ~G4Polyhedra() override;
0096 
0097     EInside Inside( const G4ThreeVector& p ) const override;
0098     G4double DistanceToIn( const G4ThreeVector& p,
0099                            const G4ThreeVector& v ) const override;
0100     G4double DistanceToIn( const G4ThreeVector& p ) const override;
0101 
0102     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0103     G4bool CalculateExtent(const EAxis pAxis,
0104                            const G4VoxelLimits& pVoxelLimit,
0105                            const G4AffineTransform& pTransform,
0106                                  G4double& pmin, G4double& pmax) const override;
0107 
0108     void ComputeDimensions(       G4VPVParameterisation* p,
0109                             const G4int n,
0110                             const G4VPhysicalVolume* pRep) override;
0111 
0112     G4GeometryType  GetEntityType() const override;
0113 
0114     G4VSolid* Clone() const override;
0115 
0116     G4double GetCubicVolume() override;
0117     G4double GetSurfaceArea() override;
0118 
0119     G4ThreeVector GetPointOnSurface() const override;
0120 
0121     std::ostream& StreamInfo( std::ostream& os ) const override;
0122 
0123     G4Polyhedron* CreatePolyhedron() const override;
0124 
0125     G4bool Reset();
0126 
0127     // Accessors
0128 
0129     inline G4int GetNumSide()        const;
0130     inline G4double GetStartPhi()    const;
0131     inline G4double GetEndPhi()      const;
0132     inline G4double GetSinStartPhi() const;
0133     inline G4double GetCosStartPhi() const;
0134     inline G4double GetSinEndPhi()   const;
0135     inline G4double GetCosEndPhi()   const;
0136     inline G4bool IsOpen()           const;
0137     inline G4bool IsGeneric()        const;
0138     inline G4int GetNumRZCorner()    const;
0139     inline G4PolyhedraSideRZ GetCorner( const G4int index ) const;
0140 
0141     inline G4PolyhedraHistorical* GetOriginalParameters() const;
0142       // Returns internal scaled parameters.
0143     inline void SetOriginalParameters(G4PolyhedraHistorical* pars);
0144       // Sets internal parameters. Parameters 'Rmin' and 'Rmax' in input must
0145       // be scaled first by a factor computed as 'cos(0.5*phiTotal/theNumSide)',
0146       // if not already scaled.
0147 
0148     G4Polyhedra(__void__&);
0149       // Fake default constructor for usage restricted to direct object
0150       // persistency for clients requiring preallocation of memory for
0151       // persistifiable objects.
0152 
0153     G4Polyhedra( const G4Polyhedra& source );
0154     G4Polyhedra& operator=( const G4Polyhedra& source );
0155       // Copy constructor and assignment operator.
0156 
0157   protected:
0158 
0159     void SetOriginalParameters(G4ReduciblePolygon* rz);
0160       // Sets internal parameters for the generic constructor.
0161 
0162     void Create( G4double phiStart,           // initial phi starting angle
0163                  G4double phiTotal,           // total phi angle
0164                  G4int    numSide,            // number sides
0165                  G4ReduciblePolygon* rz );    // rz coordinates
0166       // Generates the shape and is called by each constructor, after the
0167       // conversion of the arguments
0168 
0169     void CopyStuff( const G4Polyhedra& source );
0170     void DeleteStuff();
0171 
0172     // Methods for generation of random points on surface
0173 
0174     void SetSurfaceElements() const;
0175 
0176   protected:
0177 
0178     G4int numSide = 0;    // Number of sides
0179     G4double startPhi;    // Starting phi value (0 < phiStart < 2pi)
0180     G4double endPhi;      // end phi value (0 < endPhi-phiStart < 2pi)
0181     G4bool phiIsOpen = false;   // true if there is a phi segment
0182     G4bool genericPgon = false; // true if created through 2nd generic ctor
0183     G4int numCorner = 0;  // number RZ points
0184     G4PolyhedraSideRZ* corners = nullptr;  // our corners
0185     G4PolyhedraHistorical* original_parameters = nullptr; // original input pars
0186 
0187     G4EnclosingCylinder* enclosingCylinder = nullptr;
0188 
0189     struct surface_element { G4double area=0.; G4int i0=0, i1=0, i2=0; };
0190     mutable std::vector<surface_element>* fElements = nullptr;
0191 };
0192 
0193 #include "G4Polyhedra.icc"
0194 
0195 #endif
0196 
0197 #endif