Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 08:57:10

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 // G4ReflectedSolid
0027 //
0028 // Class description:
0029 //
0030 // A Reflected solid is a solid that has been shifted from its original
0031 // frame of reference to a new reflected one.
0032 
0033 // Author: Vladimir Grichine (CERN), 23.07.2001 - Created
0034 // --------------------------------------------------------------------
0035 #ifndef G4ReflectedSolid_hh
0036 #define G4ReflectedSolid_hh
0037 
0038 #include "G4VSolid.hh"
0039 #include "G4ThreeVector.hh"
0040 #include "G4Transform3D.hh"
0041 
0042 /**
0043  * @brief G4ReflectedSolid is a solid that has been shifted from its original
0044  * frame of reference to a new reflected one.
0045  */
0046 
0047 class G4ReflectedSolid : public G4VSolid
0048 {
0049   public:
0050 
0051     /**
0052      * Constructor for G4ReflectedSolid. For use in instantiating
0053      * a transient instance.
0054      *  @param[in] pName The solid's name.
0055      *  @param[in] pSolid The original primitive being reflected.
0056      *  @param[in] transform The associated transformation.
0057      */
0058     G4ReflectedSolid( const G4String& pName,
0059                             G4VSolid* pSolid ,
0060                       const G4Transform3D& transform ) ;
0061 
0062     /**
0063      * Destructor.
0064      */
0065     ~G4ReflectedSolid() override;
0066 
0067     // Includes all the methods that a solid requires.
0068 
0069     /**
0070      * Computes the bounding limits of the solid.
0071      *  @param[out] pMin The minimum bounding limit point.
0072      *  @param[out] pMax The maximum bounding limit point.
0073      */
0074     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0075 
0076     /**
0077      * Calculates the minimum and maximum extent of the solid, when under the
0078      * specified transform, and within the specified limits.
0079      *  @param[in] pAxis The axis along which compute the extent.
0080      *  @param[in] pVoxelLimit The limiting space dictated by voxels.
0081      *  @param[in] pTransform The internal transformation applied to the solid.
0082      *  @param[out] pMin The minimum extent value.
0083      *  @param[out] pMax The maximum extent value.
0084      *  @returns True if the solid is intersected by the extent region.
0085      */
0086     G4bool CalculateExtent( const EAxis pAxis,
0087                             const G4VoxelLimits& pVoxelLimit,
0088                             const G4AffineTransform& pTransform,
0089                                   G4double& pMin, G4double& pMax) const override;
0090 
0091     /**
0092      * Concrete implementations of the expected query interfaces for
0093      * solids, as defined in the base class G4VSolid.
0094      */
0095     EInside Inside( const G4ThreeVector& p ) const override; 
0096     G4ThreeVector SurfaceNormal( 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     G4double DistanceToOut( const G4ThreeVector& p,
0101                             const G4ThreeVector& v,
0102                             const G4bool calcNorm = false,
0103                                   G4bool* validNorm = nullptr,
0104                                   G4ThreeVector* n = nullptr ) const override;
0105     G4double DistanceToOut( const G4ThreeVector& p ) const override;
0106 
0107     /**
0108      * Dispatch method for parameterisation replication mechanism and
0109      * dimension computation.
0110      */
0111     void ComputeDimensions( G4VPVParameterisation* p,
0112                             const G4int n,
0113                             const G4VPhysicalVolume* pRep ) override;
0114 
0115     /**
0116      * Returning an estimation of the solid volume (capacity) and
0117      * surface area, in internal units.
0118      */
0119     G4double GetCubicVolume() override;
0120     G4double GetSurfaceArea() override;
0121 
0122     /**
0123      * Returns a random point located and uniformly distributed on the
0124      * surface of the solid.
0125      */
0126     G4ThreeVector GetPointOnSurface() const override;
0127 
0128     /**
0129      * Returns the number of constituent solids (in case Boolean).
0130      */
0131     G4int GetNumOfConstituents() const override;
0132 
0133     /**
0134      * Returns true as the solid has only planar faces.
0135      */
0136     G4bool IsFaceted() const override;
0137 
0138     /**
0139      * Makes a clone of the object for use in multi-treading.
0140      *  @returns A pointer to the new cloned allocated solid.
0141      */
0142     G4VSolid* Clone() const override;
0143 
0144     /**
0145      * Returns a random point located and uniformly distributed on the
0146      * surface of the solid.
0147      */
0148     G4GeometryType  GetEntityType() const override;
0149 
0150     /**
0151      * If the Solid is a G4ReflectedSolid, return a self pointer else
0152      * return nullptr.
0153      */
0154     virtual const G4ReflectedSolid* GetReflectedSolidPtr() const;
0155     virtual G4ReflectedSolid* GetReflectedSolidPtr();
0156 
0157     /**
0158      * Returns a pointer to the original solid primitive.
0159      */
0160     G4VSolid* GetConstituentMovedSolid() const;
0161 
0162     /**
0163      * Accessors and modifier for the transformation.
0164      */
0165     G4Transform3D GetTransform3D() const; 
0166     G4Transform3D GetDirectTransform3D() const; 
0167     void SetDirectTransform3D(G4Transform3D&);
0168 
0169     /**
0170      * Streams the object contents to an output stream.
0171      */
0172     std::ostream& StreamInfo(std::ostream& os) const override;
0173 
0174     /**
0175      * Copy constructor and assignment operator.
0176      */
0177     G4ReflectedSolid(const G4ReflectedSolid& rhs);
0178     G4ReflectedSolid& operator=(const G4ReflectedSolid& rhs);
0179 
0180     /**
0181      * Methods for creating graphical representations (i.e. for visualisation).
0182      */
0183     void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
0184     G4Polyhedron* CreatePolyhedron() const override;
0185     G4Polyhedron* GetPolyhedron() const override;
0186 
0187   protected:
0188 
0189     G4VSolid*          fPtrSolid = nullptr;
0190     G4Transform3D*     fDirectTransform3D = nullptr;
0191 
0192     /** Caches for the reflected G4Polyhedron. */
0193     mutable G4bool fRebuildPolyhedron = false;
0194     mutable G4Polyhedron* fpPolyhedron = nullptr;
0195 };
0196 
0197 #endif