File indexing completed on 2025-01-18 09:59:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 #ifndef G4TRIANGULARFACET_HH
0051 #define G4TRIANGULARFACET_HH 1
0052
0053 #include "G4VFacet.hh"
0054 #include "G4Types.hh"
0055 #include "G4ThreeVector.hh"
0056
0057 #include <vector>
0058 #include <array>
0059
0060 class G4TriangularFacet : public G4VFacet
0061 {
0062 public:
0063
0064 G4TriangularFacet ();
0065 ~G4TriangularFacet () override;
0066
0067 G4TriangularFacet (const G4ThreeVector& vt0, const G4ThreeVector& vt1,
0068 const G4ThreeVector& vt2, G4FacetVertexType);
0069 G4TriangularFacet (const G4TriangularFacet& right);
0070 G4TriangularFacet ( G4TriangularFacet&& right) noexcept ;
0071
0072 G4TriangularFacet& operator=(const G4TriangularFacet& right);
0073 G4TriangularFacet& operator=( G4TriangularFacet&& right) noexcept ;
0074
0075 G4VFacet* GetClone () override;
0076 G4TriangularFacet* GetFlippedFacet ();
0077
0078 G4ThreeVector Distance (const G4ThreeVector& p);
0079 G4double Distance (const G4ThreeVector& p, G4double minDist) override;
0080 G4double Distance (const G4ThreeVector& p, G4double minDist,
0081 const G4bool outgoing) override;
0082 G4double Extent (const G4ThreeVector axis) override;
0083 G4bool Intersect (const G4ThreeVector& p, const G4ThreeVector& v,
0084 const G4bool outgoing, G4double& distance,
0085 G4double& distFromSurface,
0086 G4ThreeVector& normal) override;
0087 G4double GetArea () const override;
0088 G4ThreeVector GetPointOnFace () const override;
0089
0090 G4ThreeVector GetSurfaceNormal () const override;
0091 void SetSurfaceNormal (const G4ThreeVector& normal);
0092
0093 G4GeometryType GetEntityType () const override;
0094
0095 inline G4bool IsDefined () const override;
0096 inline G4int GetNumberOfVertices () const override;
0097 inline G4ThreeVector GetVertex (G4int i) const override;
0098 inline void SetVertex (G4int i, const G4ThreeVector& val) override;
0099
0100 inline G4ThreeVector GetCircumcentre () const override;
0101 inline G4double GetRadius () const override;
0102
0103 inline G4int AllocatedMemory() override;
0104
0105 inline G4int GetVertexIndex (G4int i) const override;
0106 inline void SetVertexIndex (G4int i, G4int j) override;
0107 inline void SetVertices(std::vector<G4ThreeVector>* v) override;
0108
0109 private:
0110
0111 void CopyFrom(const G4TriangularFacet& rhs);
0112 void MoveFrom(G4TriangularFacet& rhs);
0113
0114 G4ThreeVector fSurfaceNormal;
0115 G4double fArea = 0.0;
0116 G4ThreeVector fCircumcentre;
0117 G4double fRadius = 0.0;
0118 std::array<G4int, 3> fIndices;
0119 std::vector<G4ThreeVector>* fVertices = nullptr;
0120
0121 G4double fA, fB, fC;
0122 G4double fDet;
0123 G4double fSqrDist = 0.0;
0124 G4ThreeVector fE1, fE2;
0125 G4bool fIsDefined = false;
0126 };
0127
0128
0129
0130
0131
0132 inline G4bool G4TriangularFacet::IsDefined () const
0133 {
0134 return fIsDefined;
0135 }
0136
0137 inline G4int G4TriangularFacet::GetNumberOfVertices () const
0138 {
0139 return 3;
0140 }
0141
0142 inline G4ThreeVector G4TriangularFacet::GetVertex (G4int i) const
0143 {
0144 G4int indice = fIndices[i];
0145 return indice < 0 ? (*fVertices)[i] : (*fVertices)[indice];
0146 }
0147
0148 inline void G4TriangularFacet::SetVertex (G4int i, const G4ThreeVector& val)
0149 {
0150 (*fVertices)[i] = val;
0151 }
0152
0153 inline G4ThreeVector G4TriangularFacet::GetCircumcentre () const
0154 {
0155 return fCircumcentre;
0156 }
0157
0158 inline G4double G4TriangularFacet::GetRadius () const
0159 {
0160 return fRadius;
0161 }
0162
0163 inline G4int G4TriangularFacet::AllocatedMemory()
0164 {
0165 G4int size = sizeof(*this);
0166 size += GetNumberOfVertices() * sizeof(G4ThreeVector);
0167 return size;
0168 }
0169
0170 inline G4int G4TriangularFacet::GetVertexIndex (G4int i) const
0171 {
0172 if (i < 3) return fIndices[i];
0173 else return 999999999;
0174 }
0175
0176 inline void G4TriangularFacet::SetVertexIndex (G4int i, G4int j)
0177 {
0178 fIndices[i] = j;
0179 }
0180
0181 inline void G4TriangularFacet::SetVertices(std::vector<G4ThreeVector>* v)
0182 {
0183 if (fIndices[0] < 0 && (fVertices != nullptr))
0184 {
0185 delete fVertices;
0186 fVertices = nullptr;
0187 }
0188 fVertices = v;
0189 }
0190
0191 #endif