Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:11:39

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 and of QinetiQ Ltd,   *
0020 // * subject to DEFCON 705 IPR conditions.                            *
0021 // * By using,  copying,  modifying or  distributing the software (or *
0022 // * any work based  on the software)  you  agree  to acknowledge its *
0023 // * use  in  resulting  scientific  publications,  and indicate your *
0024 // * acceptance of all terms of the Geant4 Software license.          *
0025 // ********************************************************************
0026 //
0027 // G4QuadrangularFacet
0028 //
0029 // Class description:
0030 //
0031 // The G4QuadrangularFacet class is used for the contruction of
0032 // G4TessellatedSolid.
0033 // It is defined by four fVertices, which shall be in the same plane and be
0034 // supplied in anti-clockwise order looking from the outsider of the solid
0035 // where it belongs. Its constructor:
0036 //   
0037 //   G4QuadrangularFacet (const G4ThreeVector& Pt0, const G4ThreeVector& vt1,
0038 //                        const G4ThreeVector& vt2, const G4ThreeVector& vt3,
0039 //                        G4FacetVertexType);
0040 //
0041 // takes 5 parameters to define the four fVertices:
0042 //   1) G4FacetvertexType = "ABSOLUTE": in this case Pt0, vt1, vt2 and vt3
0043 //      are the four fVertices required in anti-clockwise order when looking
0044 //      from the outsider.
0045 //   2) G4FacetvertexType = "RELATIVE": in this case the first vertex is Pt0,
0046 //      the second vertex is Pt0+vt1, the third vertex is Pt0+vt2 and 
0047 //      the fourth vertex is Pt0+vt3, in anti-clockwise order when looking 
0048 //      from the outsider.
0049 
0050 // Author: P.R.Truscott (QinetiQ Ltd, UK), 31.10.2004 - Created
0051 //         M.Gayer (CERN), 12.10.2012 - Reviewed optimised implementation
0052 // --------------------------------------------------------------------
0053 #ifndef G4QUADRANGULARFACET_HH
0054 #define G4QUADRANGULARFACET_HH
0055 
0056 #include "G4VFacet.hh"
0057 #include "G4Types.hh"
0058 #include "G4ThreeVector.hh"
0059 #include "G4TriangularFacet.hh"
0060 
0061 /**
0062  * @brief G4QuadrangularFacet defines a facet with 4 vertices, used for the
0063  * contruction of G4TessellatedSolid. Vertices shall be in the same plane and
0064  * be supplied in anti-clockwise order looking from the outsider of the solid
0065  * where it belongs.
0066  */
0067 
0068 class G4QuadrangularFacet : public G4VFacet
0069 {
0070   public:
0071 
0072     /**
0073      * Constructs a facet with 4 vertices, given its parameters.
0074      *  @param[in] Pt0 The anchor point, first vertex.
0075      *  @param[in] vt1 Second vertex.
0076      *  @param[in] vt2 Third vertex.
0077      *  @param[in] vt3 Fourth vertex.
0078      *  @param[in] vType The positioning type for the vertices, either:
0079      *             "ABSOLUTE" - vertices set in anti-clockwise order
0080      *                          when looking from the outsider.
0081      *             "RELATIVE" - first vertex is Pt0, second is Pt0+vt1,
0082      *                          third vertex is Pt0+vt2 and fourth is Pt0+vt3,
0083      *                          still in anti-clockwise order.
0084      */
0085     G4QuadrangularFacet (const G4ThreeVector& Pt0, const G4ThreeVector& vt1,
0086                          const G4ThreeVector& vt2, const G4ThreeVector& vt3,
0087                                G4FacetVertexType vType);
0088 
0089     /**
0090      * Default Destructor.
0091      */
0092     ~G4QuadrangularFacet () override = default;
0093 
0094     /**
0095      * Copy constructor and assignment operator.
0096      */
0097     G4QuadrangularFacet (const G4QuadrangularFacet& right);
0098     G4QuadrangularFacet& operator=(const G4QuadrangularFacet& right);    
0099 
0100     /**
0101      * Returns a pointer to a newly allocated duplicate copy of the facet.
0102      */
0103     G4VFacet* GetClone () override;
0104 
0105     /**
0106      * Determines the vector between p and the closest point on the facet to p.
0107      */
0108     G4ThreeVector Distance (const G4ThreeVector& p);
0109 
0110     /**
0111      * Determines the closest distance between point p and the facet.
0112      */
0113     G4double Distance (const G4ThreeVector& p, G4double minDist) override;
0114 
0115     /**
0116      * Determines the distance to point 'p'. kInfinity is returned if either:
0117      * (1) outgoing is TRUE and the dot product of the normal vector to the
0118      * facet and the displacement vector from p to the triangle is negative.
0119      * (2) outgoing is FALSE and the dot product of the normal vector to the
0120      * facet and the displacement vector from p to the triangle is positive.
0121      */
0122     G4double Distance (const G4ThreeVector& p, G4double minDist,
0123                        const G4bool outgoing) override;
0124 
0125     /**
0126      * Calculates the furthest the quadrangle extends in fA particular
0127      * direction defined by the vector axis.
0128      */
0129     G4double Extent (const G4ThreeVector axis) override;
0130 
0131     /**
0132      * Finds the next intersection when going from 'p' in the direction of 'v'.
0133      * If 'outgoing' is true, only consider the face if we are going out
0134      * through the face; otherwise, if false, only consider the face if we are
0135      * going in through the face.
0136      *  @returns true if there is an intersection, false otherwise.
0137      */
0138     G4bool Intersect  (const G4ThreeVector& p, const G4ThreeVector& v,
0139                        const G4bool outgoing, G4double& distance,
0140                              G4double& distFromSurface,
0141                              G4ThreeVector& normal) override;
0142     /**
0143      * Returns the normal vector to the face.
0144      */
0145     G4ThreeVector GetSurfaceNormal () const override;
0146 
0147     /**
0148      * Auxiliary method for returning the surface area.
0149      */
0150     G4double GetArea () const override;
0151 
0152     /**
0153      * Auxiliary method to get a uniform random point on the facet.
0154      */
0155     G4ThreeVector GetPointOnFace () const override;
0156 
0157     /**
0158      * Returns the type ID, "G4QuadrangularFacet" of the facet.
0159      */
0160     G4GeometryType GetEntityType () const override;
0161 
0162     /**
0163      * Returns true if the facet is defined.
0164      */
0165     inline G4bool IsDefined () const override;
0166 
0167     /**
0168      * Returns the number of vertices, i.e. 4.
0169      */
0170     inline G4int GetNumberOfVertices () const override;
0171 
0172     /**
0173      * Returns the vertex based on the index 'i'.
0174      */
0175     inline G4ThreeVector GetVertex (G4int i) const override;
0176 
0177     /**
0178      * Methods to set the vertices.
0179      */
0180     inline void SetVertex (G4int i, const G4ThreeVector& val) override;
0181     inline void SetVertices(std::vector<G4ThreeVector>* v) override;
0182 
0183     /**
0184      * Returns the radius to the anchor point and centered on the circumcentre.
0185      */
0186     inline G4double GetRadius () const override;
0187 
0188     /**
0189      * Returns the circumcentre point of the facet.
0190      */
0191     inline G4ThreeVector GetCircumcentre () const override;
0192 
0193   private:
0194 
0195     /**
0196      * Private accessor/setter for the vertex index.
0197      */
0198     inline G4int GetVertexIndex (G4int i) const override;
0199     inline void SetVertexIndex (G4int i, G4int val) override;
0200 
0201     /**
0202      * Returns the allocated memory (sizeof) by the facet.
0203      */
0204     inline G4int AllocatedMemory() override;
0205 
0206   private:
0207 
0208     G4double fRadius = 0.0;
0209 
0210     G4ThreeVector fCircumcentre;
0211 
0212     G4TriangularFacet fFacet1, fFacet2;
0213 };
0214 
0215 // --------------------------------------------------------------------
0216 // Inline Methods
0217 // --------------------------------------------------------------------
0218 
0219 #include "G4QuadrangularFacet.icc"
0220 
0221 #endif