Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-08 08:18:11

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 // G4UTet
0027 //
0028 // Class description:
0029 //
0030 // Wrapper class for G4Tet to make use of VecGeom Tet.
0031 
0032 // Author: Gabriele Cosmo (CERN), 01.11.2013
0033 // --------------------------------------------------------------------
0034 #ifndef G4UTET_HH
0035 #define G4UTET_HH
0036 
0037 #include "G4UAdapter.hh"
0038 
0039 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
0040 
0041 #include <VecGeom/volumes/UnplacedTet.h>
0042 
0043 #include "G4Polyhedron.hh"
0044 
0045 /**
0046  * @brief G4UTet is a wrapper class for G4Tet to make use of VecGeom Tet.
0047  */
0048 
0049 class G4UTet : public G4UAdapter<vecgeom::UnplacedTet>
0050 {
0051 
0052   using Shape_t = vecgeom::UnplacedTet;
0053   using Base_t = G4UAdapter<vecgeom::UnplacedTet>;
0054 
0055   public:
0056 
0057     /**
0058      * Constructs a tetrahedra, given its parameters.
0059      *  @param[in] pName The solid name.
0060      *  @param[in] anchor The anchor point.
0061      *  @param[in] p2 Point 2.
0062      *  @param[in] p3 Point 3.
0063      *  @param[in] p4 Point 4.
0064      *  @param[in] degeneracyFlag Flag indicating degeneracy of points.
0065      */
0066     G4UTet(const G4String& pName,
0067            const G4ThreeVector& anchor,
0068            const G4ThreeVector& p2,
0069            const G4ThreeVector& p3,
0070            const G4ThreeVector& p4,
0071                  G4bool* degeneracyFlag = nullptr);
0072 
0073     /**
0074      * Default destructor.
0075      */
0076     ~G4UTet() override = default;
0077 
0078     /**
0079      * Dispatch method for parameterisation replication mechanism and
0080      * dimension computation.
0081      */
0082     void ComputeDimensions(G4VPVParameterisation* p,
0083                            const G4int n,
0084                            const G4VPhysicalVolume* pRep) override;
0085 
0086     /**
0087      * Makes a clone of the object for use in multi-treading.
0088      *  @returns A pointer to the new cloned allocated solid.
0089      */
0090     G4VSolid* Clone() const override;
0091 
0092     /**
0093      * Returns the type ID, "G4Tet" of the solid.
0094      */
0095     inline G4GeometryType GetEntityType() const override;
0096 
0097     /**
0098      * Returns true as the solid has only planar faces.
0099      */
0100     inline G4bool IsFaceted() const override;
0101 
0102     /**
0103      * Computes the bounding limits of the solid.
0104      *  @param[out] pMin The minimum bounding limit point.
0105      *  @param[out] pMax The maximum bounding limit point.
0106      */
0107     void SetBoundingLimits(const G4ThreeVector& pMin, const G4ThreeVector& pMax);
0108     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0109 
0110     /**
0111      * Calculates the minimum and maximum extent of the solid, when under the
0112      * specified transform, and within the specified limits.
0113      *  @param[in] pAxis The axis along which compute the extent.
0114      *  @param[in] pVoxelLimit The limiting space dictated by voxels.
0115      *  @param[in] pTransform The internal transformation applied to the solid.
0116      *  @param[out] pMin The minimum extent value.
0117      *  @param[out] pMax The maximum extent value.
0118      *  @returns True if the solid is intersected by the extent region.
0119      */
0120     G4bool CalculateExtent(const EAxis pAxis,
0121                            const G4VoxelLimits& pVoxelLimit,
0122                            const G4AffineTransform& pTransform,
0123                                  G4double& pMin, G4double& pMax) const override;
0124 
0125     /**
0126      * Returns a generated polyhedron as graphical representations.
0127      */
0128     G4Polyhedron* CreatePolyhedron() const override;
0129 
0130     /**
0131      * Modifier and accessors, for the four vertices of the shape.
0132      */
0133     void SetVertices(const G4ThreeVector& anchor,
0134                      const G4ThreeVector& p1,
0135                      const G4ThreeVector& p2,
0136                      const G4ThreeVector& p3,
0137                      G4bool* degeneracyFlag = nullptr);
0138     void GetVertices(G4ThreeVector& anchor,
0139                      G4ThreeVector& p1,
0140                      G4ThreeVector& p2,
0141                      G4ThreeVector& p3) const;
0142     std::vector<G4ThreeVector> GetVertices() const;
0143 
0144     /**
0145      * Checks if the tetrahedron is degenerate. A tetrahedron is considered
0146      * as degenerate in case its minimal height is less than the degeneracy
0147      * tolerance
0148      *  @returns true if the tetrahedron is degenerate.
0149      */
0150     G4bool CheckDegeneracy(const G4ThreeVector& p0,
0151                            const G4ThreeVector& p1,
0152                            const G4ThreeVector& p2,
0153                            const G4ThreeVector& p3) const;
0154 
0155     /**
0156      * Copy constructor and assignment operator.
0157      */
0158     G4UTet(const G4UTet& rhs);
0159     G4UTet& operator=(const G4UTet& rhs);
0160 
0161   private:
0162 
0163     G4ThreeVector fBmin, fBmax; // bounding box
0164 };
0165 
0166 // --------------------------------------------------------------------
0167 // Inline methods
0168 // --------------------------------------------------------------------
0169 
0170 inline G4GeometryType G4UTet::GetEntityType() const
0171 {
0172   return "G4Tet";
0173 }
0174 
0175 inline G4bool G4UTet::IsFaceted() const
0176 {
0177   return true;
0178 }
0179 
0180 #endif  // G4GEOM_USE_USOLIDS
0181 
0182 #endif