|
|
|||
File indexing completed on 2026-08-07 09:12:25
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 // G4UExtrudedSolid 0027 // 0028 // Class description: 0029 // 0030 // Wrapper class for G4ExtrudedSolid to make use of VecGeom ExtrudedSolid. 0031 0032 // Author: Gabriele Cosmo (CERN), 17.11.2017 0033 // -------------------------------------------------------------------- 0034 #ifndef G4UEXTRUDEDSOLID_HH 0035 #define G4UEXTRUDEDSOLID_HH 0036 0037 #include "G4UAdapter.hh" 0038 0039 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) ) 0040 0041 #include <VecGeom/volumes/UnplacedExtruded.h> 0042 #include "G4TwoVector.hh" 0043 0044 #include "G4Polyhedron.hh" 0045 0046 /** 0047 * @brief G4UExtrudedSolid is a wrapper class for G4ExtrudedSolid 0048 * to make use of VecGeom ExtrudedSolid. 0049 */ 0050 0051 class G4UExtrudedSolid : public G4UAdapter<vecgeom::UnplacedExtruded> 0052 { 0053 using Shape_t = vecgeom::UnplacedExtruded; 0054 using Base_t = G4UAdapter<vecgeom::UnplacedExtruded>; 0055 0056 public: 0057 0058 /** 0059 * Structure defining a Z section composing the solid. 0060 */ 0061 struct ZSection 0062 { 0063 ZSection() : fZ(0.), fOffset(0.,0.), fScale(1.) {} 0064 ZSection(G4double z, const G4TwoVector& offset, G4double scale) 0065 : fZ(z), fOffset(offset), fScale(scale) {} 0066 0067 G4double fZ; 0068 G4TwoVector fOffset; 0069 G4double fScale; 0070 }; 0071 0072 /** 0073 * General constructor for an extruded polygon, through contour and polyline. 0074 * @param[in] pName The solid name. 0075 * @param[in] polygon The 2D polygonal contour, i.e. the vertices of the 0076 * outlined polygon defined in clock-wise order. 0077 * @param[in] zsections The 3D polyline with scale factors, i.e. the 0078 * Z-sections defined by Z position in increasing order. 0079 */ 0080 G4UExtrudedSolid(const G4String& pName, 0081 const std::vector<G4TwoVector>& polygon, 0082 const std::vector<ZSection>& zsections); 0083 0084 /** 0085 * Special constructor for an extruded polygon with 2 Z-sections. 0086 * @param[in] pName The solid name. 0087 * @param[in] polygon The 2D polygonal contour, i.e. the vertices of the 0088 * outlined polygon defined in clock-wise order. 0089 * @param[in] halfZ Half length in Z, i.e. the distance from the origin 0090 * to the sections. 0091 * @param[in] off1 (X, Y) position of the first polygon in -halfZ. 0092 * @param[in] scale1 Scale factor at -halfZ. 0093 * @param[in] off2 (X, Y) position of the second polygon in +halfZ. 0094 * @param[in] scale2 Scale factor at +halfZ. 0095 */ 0096 G4UExtrudedSolid(const G4String& pName, 0097 const std::vector<G4TwoVector>& polygon, 0098 G4double halfZ, 0099 const G4TwoVector& off1 = G4TwoVector(0.,0.), 0100 G4double scale1 = 1., 0101 const G4TwoVector& off2 = G4TwoVector(0.,0.), 0102 G4double scale2 = 1. ); 0103 0104 /** 0105 * Default Destructor. 0106 */ 0107 ~G4UExtrudedSolid() override = default; 0108 0109 /** 0110 * Accessors. 0111 */ 0112 G4int GetNofVertices() const; 0113 G4TwoVector GetVertex(G4int index) const; 0114 std::vector<G4TwoVector> GetPolygon() const; 0115 G4int GetNofZSections() const; 0116 ZSection GetZSection(G4int index) const; 0117 std::vector<ZSection> GetZSections() const; 0118 0119 /** 0120 * Returns the type ID, "G4ExtrudedSolid" of the solid. 0121 */ 0122 inline G4GeometryType GetEntityType() const override; 0123 0124 /** 0125 * Returns true as the solid has only planar faces. 0126 */ 0127 inline G4bool IsFaceted() const override; 0128 0129 /** 0130 * Computes the bounding limits of the solid. 0131 * @param[out] pMin The minimum bounding limit point. 0132 * @param[out] pMax The maximum bounding limit point. 0133 */ 0134 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override; 0135 0136 /** 0137 * Calculates the minimum and maximum extent of the solid, when under the 0138 * specified transform, and within the specified limits. 0139 * @param[in] pAxis The axis along which compute the extent. 0140 * @param[in] pVoxelLimit The limiting space dictated by voxels. 0141 * @param[in] pTransform The internal transformation applied to the solid. 0142 * @param[out] pMin The minimum extent value. 0143 * @param[out] pMax The maximum extent value. 0144 * @returns True if the solid is intersected by the extent region. 0145 */ 0146 G4bool CalculateExtent(const EAxis pAxis, 0147 const G4VoxelLimits& pVoxelLimit, 0148 const G4AffineTransform& pTransform, 0149 G4double& pMin, G4double& pMax) const override; 0150 0151 /** 0152 * Returns a generated polyhedron as graphical representations. 0153 */ 0154 G4Polyhedron* CreatePolyhedron() const override; 0155 0156 /** 0157 * Copy constructor and assignment operator. 0158 */ 0159 G4UExtrudedSolid( const G4UExtrudedSolid& source ); 0160 G4UExtrudedSolid &operator=(const G4UExtrudedSolid& source); 0161 }; 0162 0163 // -------------------------------------------------------------------- 0164 // Inline methods 0165 // -------------------------------------------------------------------- 0166 0167 inline G4GeometryType G4UExtrudedSolid::GetEntityType() const 0168 { 0169 return "G4ExtrudedSolid"; 0170 } 0171 0172 inline G4bool G4UExtrudedSolid::IsFaceted() const 0173 { 0174 return true; 0175 } 0176 0177 #endif // G4GEOM_USE_USOLIDS 0178 0179 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|