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 // G4Polycone
0027 //
0028 // Class description:
0029 //
0030 //   Class implementing a CSG-like type "PCON" Geant 3.21 volume,
0031 //   inherited from  class G4VCSGfaceted:
0032 //
0033 //   G4Polycone( const G4String& name,
0034 //               G4double phiStart,     // initial phi starting angle
0035 //               G4double phiTotal,     // total phi angle
0036 //               G4int numZPlanes,      // number of z planes
0037 //               const G4double zPlane[],  // position of z planes
0038 //               const G4double rInner[],  // tangent distance to inner surface
0039 //               const G4double rOuter[])  // tangent distance to outer surface
0040 //
0041 //   Alternative constructor, but limited to increasing-only Z sections:
0042 //
0043 //   G4Polycone( const G4String& name,
0044 //               G4double phiStart,   // initial phi starting angle
0045 //               G4double phiTotal,   // total phi angle
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 G4POLYCONE_HH
0053 #define G4POLYCONE_HH
0054 
0055 #include "G4GeomTypes.hh"
0056 
0057 #if defined(G4GEOM_USE_USOLIDS)
0058 #define G4GEOM_USE_UPOLYCONE 1
0059 #endif
0060 
0061 #if defined(G4GEOM_USE_UPOLYCONE)
0062   #define G4UPolycone G4Polycone
0063   #include "G4UPolycone.hh"
0064 #else
0065 
0066 #include "G4VCSGfaceted.hh"
0067 #include "G4PolyconeSide.hh"
0068 #include "G4PolyconeHistorical.hh"
0069 #include "G4Polyhedron.hh"
0070 
0071 class G4EnclosingCylinder;
0072 class G4ReduciblePolygon;
0073 class G4VCSGface;
0074 
0075 class G4Polycone : public G4VCSGfaceted
0076 {
0077   public:
0078 
0079     G4Polycone( const G4String& name,
0080                       G4double phiStart,    // initial phi starting angle
0081                       G4double phiTotal,    // total phi angle
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     G4Polycone( const G4String& name,
0088                       G4double phiStart,    // initial phi starting angle
0089                       G4double phiTotal,    // total phi angle
0090                       G4int    numRZ,       // number corners in r,z space
0091                 const G4double r[],         // r coordinate of these corners
0092                 const G4double z[]       ); // z coordinate of these corners
0093 
0094     ~G4Polycone() override;
0095 
0096     EInside Inside( const G4ThreeVector& p ) const override;
0097     G4double DistanceToIn( const G4ThreeVector& p,
0098                            const G4ThreeVector& v ) const override;
0099     G4double DistanceToIn( const G4ThreeVector& p ) const override;
0100 
0101     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0102     G4bool CalculateExtent(const EAxis pAxis,
0103                            const G4VoxelLimits& pVoxelLimit,
0104                            const G4AffineTransform& pTransform,
0105                                  G4double& pmin, G4double& pmax) const override;
0106 
0107     G4double GetCubicVolume() override;
0108     G4double GetSurfaceArea() override;
0109 
0110     G4ThreeVector GetPointOnSurface() const override;
0111 
0112     void ComputeDimensions(       G4VPVParameterisation* p,
0113                             const G4int n,
0114                             const G4VPhysicalVolume* pRep ) override;
0115 
0116     G4GeometryType GetEntityType() const override;
0117 
0118     G4VSolid* Clone() const override;
0119 
0120     std::ostream& StreamInfo(std::ostream& os) const override;
0121 
0122     G4Polyhedron* CreatePolyhedron() const override;
0123 
0124     G4bool Reset();
0125 
0126     // Accessors
0127 
0128     inline G4double GetStartPhi()    const;
0129     inline G4double GetEndPhi()      const;
0130     inline G4double GetSinStartPhi() const;
0131     inline G4double GetCosStartPhi() const;
0132     inline G4double GetSinEndPhi()   const;
0133     inline G4double GetCosEndPhi()   const;
0134     inline G4bool IsOpen()           const;
0135     inline G4int  GetNumRZCorner()   const;
0136     inline G4PolyconeSideRZ GetCorner(G4int index) const;
0137     inline G4PolyconeHistorical* GetOriginalParameters() const;
0138     inline void SetOriginalParameters(G4PolyconeHistorical* pars);
0139 
0140     G4Polycone(__void__&);
0141       // Fake default constructor for usage restricted to direct object
0142       // persistency for clients requiring preallocation of memory for
0143       // persistifiable objects.
0144 
0145     G4Polycone( const G4Polycone& source );
0146     G4Polycone &operator=( const G4Polycone& source );
0147       // Copy constructor and assignment operator.
0148 
0149   protected:
0150 
0151     // Generic initializer, called by all constructors
0152 
0153     G4bool SetOriginalParameters(G4ReduciblePolygon* rz);
0154 
0155     void Create( G4double phiStart,        // initial phi starting angle
0156                  G4double phiTotal,        // total phi angle
0157                  G4ReduciblePolygon* rz ); // r/z coordinate of these corners
0158 
0159     void CopyStuff( const G4Polycone& source );
0160 
0161     // Methods for random point generation
0162 
0163     void SetSurfaceElements() const;
0164 
0165   protected:
0166 
0167     // Here are our parameters
0168 
0169     G4double startPhi;        // Starting phi value (0 < phiStart < 2pi)
0170     G4double endPhi;          // End phi value (0 < endPhi-phiStart < 2pi)
0171     G4bool phiIsOpen = false; // True if there is a phi segment
0172     G4int numCorner;          // Number RZ points
0173     G4PolyconeSideRZ* corners = nullptr; // Corner r,z points
0174     G4PolyconeHistorical* original_parameters = nullptr; // Original input pars
0175 
0176     G4EnclosingCylinder* enclosingCylinder = nullptr; // Our quick test
0177 
0178     struct surface_element { G4double area = 0.; G4int i0 = 0, i1 = 0, i2 = 0; };
0179     mutable std::vector<surface_element>* fElements = nullptr;
0180 };
0181 
0182 #include "G4Polycone.icc"
0183 
0184 #endif
0185 
0186 #endif