Geant4 Cross Reference |
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 // G4Polyhedra 27 // 28 // Class description: 29 // 30 // Class implementing a CSG-like type "PGON" Geant 3.21 volume, 31 // inherited from class G4VCSGfaceted: 32 // 33 // G4Polyhedra( const G4String& name, 34 // G4double phiStart, - initial phi starting angle 35 // G4double phiTotal, - total phi angle 36 // G4int numSide, - number sides 37 // G4int numZPlanes, - number of z planes 38 // const G4double zPlane[], - position of z planes 39 // const G4double rInner[], - tangent distance to inner surface 40 // const G4double rOuter[] ) - tangent distance to outer surface 41 // 42 // G4Polyhedra( const G4String& name, 43 // G4double phiStart, - initial phi starting angle 44 // G4double phiTotal, - total phi angle 45 // G4int numSide, - number sides 46 // G4int numRZ, - number corners in r,z space 47 // const G4double r[], - r coordinate of these corners 48 // const G4double z[] ) - z coordinate of these corners 49 50 // Author: David C. Williams (davidw@scipp.ucsc.edu) 51 // -------------------------------------------------------------------- 52 #ifndef G4POLYHEDRA_HH 53 #define G4POLYHEDRA_HH 54 55 #include "G4GeomTypes.hh" 56 57 #if defined(G4GEOM_USE_USOLIDS) 58 #define G4GEOM_USE_UPOLYHEDRA 1 59 #endif 60 61 #if defined(G4GEOM_USE_UPOLYHEDRA) 62 #define G4UPolyhedra G4Polyhedra 63 #include "G4UPolyhedra.hh" 64 #else 65 66 #include "G4VCSGfaceted.hh" 67 #include "G4PolyhedraSide.hh" 68 #include "G4PolyhedraHistorical.hh" 69 #include "G4Polyhedron.hh" 70 71 class G4EnclosingCylinder; 72 class G4ReduciblePolygon; 73 74 class G4Polyhedra : public G4VCSGfaceted 75 { 76 public: 77 78 G4Polyhedra(const G4String& name, 79 G4double phiStart, // initial phi starting angle 80 G4double phiTotal, // total phi angle 81 G4int numSide, // number sides 82 G4int numZPlanes, // number of z planes 83 const G4double zPlane[], // position of z planes 84 const G4double rInner[], // tangent distance to inner surface 85 const G4double rOuter[] ); // tangent distance to outer surface 86 87 G4Polyhedra(const G4String& name, 88 G4double phiStart, // initial phi starting angle 89 G4double phiTotal, // total phi angle 90 G4int numSide, // number sides 91 G4int numRZ, // number corners in r,z space 92 const G4double r[], // r coordinate of these corners 93 const G4double z[] ); // z coordinate of these corners 94 95 ~G4Polyhedra() override; 96 97 EInside Inside( const G4ThreeVector& p ) const override; 98 G4double DistanceToIn( const G4ThreeVector& p, 99 const G4ThreeVector& v ) const override; 100 G4double DistanceToIn( const G4ThreeVector& p ) const override; 101 102 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override; 103 G4bool CalculateExtent(const EAxis pAxis, 104 const G4VoxelLimits& pVoxelLimit, 105 const G4AffineTransform& pTransform, 106 G4double& pmin, G4double& pmax) const override; 107 108 void ComputeDimensions( G4VPVParameterisation* p, 109 const G4int n, 110 const G4VPhysicalVolume* pRep) override; 111 112 G4GeometryType GetEntityType() const override; 113 114 G4bool IsFaceted () const override; 115 116 G4VSolid* Clone() const override; 117 118 G4double GetCubicVolume() override; 119 G4double GetSurfaceArea() override; 120 121 G4ThreeVector GetPointOnSurface() const override; 122 123 std::ostream& StreamInfo( std::ostream& os ) const override; 124 125 G4Polyhedron* CreatePolyhedron() const override; 126 127 G4bool Reset(); 128 129 // Accessors 130 131 inline G4int GetNumSide() const; 132 inline G4double GetStartPhi() const; 133 inline G4double GetEndPhi() const; 134 inline G4double GetSinStartPhi() const; 135 inline G4double GetCosStartPhi() const; 136 inline G4double GetSinEndPhi() const; 137 inline G4double GetCosEndPhi() const; 138 inline G4bool IsOpen() const; 139 inline G4bool IsGeneric() const; 140 inline G4int GetNumRZCorner() const; 141 inline G4PolyhedraSideRZ GetCorner( const G4int index ) const; 142 143 inline G4PolyhedraHistorical* GetOriginalParameters() const; 144 // Returns internal scaled parameters. 145 inline void SetOriginalParameters(G4PolyhedraHistorical* pars); 146 // Sets internal parameters. Parameters 'Rmin' and 'Rmax' in input must 147 // be scaled first by a factor computed as 'cos(0.5*phiTotal/theNumSide)', 148 // if not already scaled. 149 150 G4Polyhedra(__void__&); 151 // Fake default constructor for usage restricted to direct object 152 // persistency for clients requiring preallocation of memory for 153 // persistifiable objects. 154 155 G4Polyhedra( const G4Polyhedra& source ); 156 G4Polyhedra& operator=( const G4Polyhedra& source ); 157 // Copy constructor and assignment operator. 158 159 protected: 160 161 void SetOriginalParameters(G4ReduciblePolygon* rz); 162 // Sets internal parameters for the generic constructor. 163 164 void Create( G4double phiStart, // initial phi starting angle 165 G4double phiTotal, // total phi angle 166 G4int numSide, // number sides 167 G4ReduciblePolygon* rz ); // rz coordinates 168 // Generates the shape and is called by each constructor, after the 169 // conversion of the arguments 170 171 void CopyStuff( const G4Polyhedra& source ); 172 void DeleteStuff(); 173 174 // Methods for generation of random points on surface 175 176 void SetSurfaceElements() const; 177 178 protected: 179 180 G4int numSide = 0; // Number of sides 181 G4double startPhi; // Starting phi value (0 < phiStart < 2pi) 182 G4double endPhi; // end phi value (0 < endPhi-phiStart < 2pi) 183 G4bool phiIsOpen = false; // true if there is a phi segment 184 G4bool genericPgon = false; // true if created through 2nd generic ctor 185 G4int numCorner = 0; // number RZ points 186 G4PolyhedraSideRZ* corners = nullptr; // our corners 187 G4PolyhedraHistorical* original_parameters = nullptr; // original input pars 188 189 G4EnclosingCylinder* enclosingCylinder = nullptr; 190 191 struct surface_element { G4double area=0.; G4int i0=0, i1=0, i2=0; }; 192 mutable std::vector<surface_element>* fElements = nullptr; 193 }; 194 195 #include "G4Polyhedra.icc" 196 197 #endif 198 199 #endif 200