|
|
|||
File indexing completed on 2026-09-24 09:10:16
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 // G4TriangularFacet 0028 // 0029 // Class description: 0030 // 0031 // The G4TriangularFacet class is used for the contruction of G4TessellatedSolid. 0032 // It is defined by three fVertices, which shall be supplied in anti-clockwise 0033 // order looking from the outsider of the solid where it belongs. 0034 // Its constructor: 0035 // 0036 // G4TriangularFacet (const G4ThreeVector Pt0, const G4ThreeVector vt1, 0037 // const G4ThreeVector vt2, G4FacetVertexType); 0038 // 0039 // takes 4 parameters to define the three fVertices: 0040 // 1) G4FacetvertexType = "ABSOLUTE": in this case Pt0, vt1 and vt2 are 0041 // the 3 fVertices in anti-clockwise order looking from the outsider. 0042 // 2) G4FacetvertexType = "RELATIVE": in this case the first vertex is Pt0, 0043 // the second vertex is Pt0+vt1 and the third vertex is Pt0+vt2, all 0044 // in anti-clockwise order when looking from the outsider. 0045 0046 // Author: P.R.Truscott (QinetiQ Ltd, UK), 31.10.2004 - Created 0047 // M.Gayer (CERN), 12.10.2012 - Reviewed optimised implementation 0048 // -------------------------------------------------------------------- 0049 #ifndef G4TRIANGULARFACET_HH 0050 #define G4TRIANGULARFACET_HH 0051 0052 #include "G4VFacet.hh" 0053 #include "G4Types.hh" 0054 #include "G4ThreeVector.hh" 0055 0056 #include <vector> 0057 #include <array> 0058 0059 /** 0060 * @brief G4TriangularFacet defines a facet with 3 vertices, used for the 0061 * contruction of G4TessellatedSolid. Vertices shall be supplied in 0062 * anti-clockwise order looking from the outsider of the solid where it belongs. 0063 */ 0064 0065 class G4TriangularFacet : public G4VFacet 0066 { 0067 public: 0068 0069 /** 0070 * Default Constructor. 0071 */ 0072 G4TriangularFacet (); 0073 0074 /** 0075 * Constructs a facet with 3 vertices, given its parameters. 0076 * @param[in] Pt0 The anchor point, first vertex. 0077 * @param[in] vt1 Second vertex. 0078 * @param[in] vt2 Third vertex. 0079 * @param[in] vType The positioning type for the vertices, either: 0080 * "ABSOLUTE" - vertices set in anti-clockwise order 0081 * when looking from the outsider. 0082 * "RELATIVE" - first vertex is Pt0, second is Pt0+vt1, 0083 * and the third vertex is Pt0+vt2, 0084 * still in anti-clockwise order. 0085 */ 0086 G4TriangularFacet (const G4ThreeVector& Pt0, const G4ThreeVector& vt1, 0087 const G4ThreeVector& vt2, G4FacetVertexType vType); 0088 0089 /** 0090 * Destructor. 0091 */ 0092 ~G4TriangularFacet () override; 0093 0094 /** 0095 * Copy and move constructors. 0096 */ 0097 G4TriangularFacet (const G4TriangularFacet& right); 0098 G4TriangularFacet ( G4TriangularFacet&& right) noexcept ; 0099 0100 /** 0101 * Assignment and move assignment operators. 0102 */ 0103 G4TriangularFacet& operator=(const G4TriangularFacet& right); 0104 G4TriangularFacet& operator=( G4TriangularFacet&& right) noexcept ; 0105 0106 /** 0107 * Returns a pointer to a newly allocated duplicate copy of the facet. 0108 */ 0109 G4VFacet* GetClone () override; 0110 0111 /** 0112 * Generates and returns an identical facet, but with the normal vector 0113 * pointing at 180 degrees. 0114 */ 0115 G4TriangularFacet* GetFlippedFacet (); 0116 0117 /** 0118 * Determines the vector between p and the closest point on the facet to p. 0119 */ 0120 G4ThreeVector Distance (const G4ThreeVector& p); 0121 0122 /** 0123 * Determines the closest distance between point p and the facet. 0124 */ 0125 G4double Distance (const G4ThreeVector& p, G4double minDist) override; 0126 0127 /** 0128 * Determines the distance to point 'p'. kInfinity is returned if either: 0129 * (1) outgoing is TRUE and the dot product of the normal vector to the 0130 * facet and the displacement vector from p to the triangle is negative. 0131 * (2) outgoing is FALSE and the dot product of the normal vector to the 0132 * facet and the displacement vector from p to the triangle is positive. 0133 */ 0134 G4double Distance (const G4ThreeVector& p, G4double minDist, 0135 const G4bool outgoing) override; 0136 0137 /** 0138 * Calculates the furthest the triangle extends in fA particular 0139 * direction defined by the vector axis. 0140 */ 0141 G4double Extent (const G4ThreeVector axis) override; 0142 0143 /** 0144 * Finds the next intersection when going from 'p' in the direction of 'v'. 0145 * If 'outgoing' is true, only consider the face if we are going out 0146 * through the face; otherwise, if false, only consider the face if we are 0147 * going in through the face. 0148 * @returns true if there is an intersection, false otherwise. 0149 */ 0150 G4bool Intersect (const G4ThreeVector& p, const G4ThreeVector& v, 0151 const G4bool outgoing, G4double& distance, 0152 G4double& distFromSurface, 0153 G4ThreeVector& normal) override; 0154 0155 /** 0156 * Auxiliary method for returning the surface area. 0157 */ 0158 G4double GetArea () const override; 0159 0160 /** 0161 * Auxiliary method to get a uniform random point on the facet. 0162 */ 0163 G4ThreeVector GetPointOnFace () const override; 0164 0165 /** 0166 * Returns/sets the normal vector to the facet. 0167 */ 0168 G4ThreeVector GetSurfaceNormal () const override; 0169 void SetSurfaceNormal (const G4ThreeVector& normal); 0170 0171 /** 0172 * Returns the type ID, "G4TriangularFacet" of the facet. 0173 */ 0174 G4GeometryType GetEntityType () const override; 0175 0176 /** 0177 * Returns true if the facet is defined. 0178 */ 0179 inline G4bool IsDefined () const override; 0180 0181 /** 0182 * Returns the number of vertices, i.e. 3. 0183 */ 0184 inline G4int GetNumberOfVertices () const override; 0185 0186 /** 0187 * Returns the vertex based on the index 'i'. 0188 */ 0189 inline G4ThreeVector GetVertex (G4int i) const override; 0190 0191 /** 0192 * Methods to set the vertices. 0193 */ 0194 inline void SetVertex (G4int i, const G4ThreeVector& val) override; 0195 inline void SetVertices(std::vector<G4ThreeVector>* v) override; 0196 0197 /** 0198 * Returns the radius to the anchor point and centered on the circumcentre. 0199 */ 0200 inline G4double GetRadius () const override; 0201 0202 /** 0203 * Returns the circumcentre point of the facet. 0204 */ 0205 inline G4ThreeVector GetCircumcentre () const override; 0206 0207 /** 0208 * Returns the allocated memory (sizeof) by the facet. 0209 */ 0210 inline G4int AllocatedMemory() override; 0211 0212 /** 0213 * Accessor/setter for the vertex index. 0214 */ 0215 inline G4int GetVertexIndex (G4int i) const override; 0216 inline void SetVertexIndex (G4int i, G4int j) override; 0217 0218 private: 0219 0220 /** 0221 * Utilities for copying/moving data. 0222 */ 0223 void CopyFrom(const G4TriangularFacet& rhs); 0224 void MoveFrom(G4TriangularFacet& rhs); 0225 0226 G4ThreeVector fSurfaceNormal; 0227 G4double fArea = 0.0; 0228 G4ThreeVector fCircumcentre; 0229 G4double fRadius = 0.0; 0230 std::array<G4int, 3> fIndices; 0231 std::vector<G4ThreeVector>* fVertices = nullptr; 0232 0233 G4double fA, fB, fC; 0234 G4double fDet; 0235 G4double fSqrDist = 0.0; 0236 G4ThreeVector fE1, fE2; 0237 G4bool fIsDefined = false; 0238 }; 0239 0240 // -------------------------------------------------------------------- 0241 // Inline Methods 0242 // -------------------------------------------------------------------- 0243 0244 #include "G4TriangularFacet.icc" 0245 0246 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|