File indexing completed on 2025-09-13 08:57:26
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
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 #ifndef G4GENERICTRAP_HH
0061 #define G4GENERICTRAP_HH
0062
0063 #include "G4GeomTypes.hh"
0064
0065 #if defined(G4GEOM_USE_USOLIDS)
0066 #define G4GEOM_USE_UGENERICTRAP 1
0067 #endif
0068
0069 #if defined(G4GEOM_USE_UGENERICTRAP)
0070 #define G4UGenericTrap G4GenericTrap
0071 #include "G4UGenericTrap.hh"
0072 #else
0073
0074 #include <vector>
0075
0076 #include "globals.hh"
0077 #include "G4TwoVector.hh"
0078 #include "G4VSolid.hh"
0079
0080 class G4GenericTrap : public G4VSolid
0081 {
0082 public:
0083
0084
0085 G4GenericTrap(const G4String& name, G4double halfZ,
0086 const std::vector<G4TwoVector>& vertices);
0087
0088
0089
0090
0091 G4GenericTrap(__void__&);
0092
0093
0094 G4GenericTrap(const G4GenericTrap& rhs);
0095 G4GenericTrap& operator=(const G4GenericTrap& rhs);
0096
0097
0098 ~G4GenericTrap() override;
0099
0100
0101 inline G4double GetZHalfLength() const;
0102 inline G4int GetNofVertices() const;
0103 inline G4TwoVector GetVertex(G4int index) const;
0104 inline const std::vector<G4TwoVector>& GetVertices() const;
0105 inline G4double GetTwistAngle(G4int index) const;
0106 inline G4bool IsTwisted() const;
0107 inline G4int GetVisSubdivisions() const;
0108 inline void SetVisSubdivisions(G4int subdiv);
0109
0110
0111 EInside Inside(const G4ThreeVector& p) const override;
0112 G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
0113 G4double DistanceToIn(const G4ThreeVector& p,
0114 const G4ThreeVector& v) const override;
0115 G4double DistanceToIn(const G4ThreeVector& p) const override;
0116 G4double DistanceToOut(const G4ThreeVector& p,
0117 const G4ThreeVector& v,
0118 const G4bool calcNorm = false,
0119 G4bool* validNorm = nullptr,
0120 G4ThreeVector* n = nullptr) const override;
0121 G4double DistanceToOut(const G4ThreeVector& p) const override;
0122 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0123 G4bool CalculateExtent(const EAxis pAxis,
0124 const G4VoxelLimits& pVoxelLimit,
0125 const G4AffineTransform& pTransform,
0126 G4double& pmin, G4double& pmax) const override;
0127
0128 G4GeometryType GetEntityType() const override;
0129
0130 G4bool IsFaceted () const override;
0131
0132 G4VSolid* Clone() const override;
0133
0134 std::ostream& StreamInfo(std::ostream& os) const override;
0135
0136 G4ThreeVector GetPointOnSurface() const override ;
0137
0138 G4double GetCubicVolume() override;
0139 G4double GetSurfaceArea() override;
0140
0141
0142 void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
0143 G4VisExtent GetExtent() const override;
0144 G4Polyhedron* CreatePolyhedron() const override;
0145 G4Polyhedron* GetPolyhedron () const override;
0146
0147 private:
0148
0149
0150 void CheckParameters(G4double halfZ, const std::vector<G4TwoVector>& vertices);
0151 void ComputeLateralSurfaces();
0152 void ComputeBoundingBox();
0153 void ComputeScratchLength();
0154 G4double GetLateralFaceArea(G4int iface) const;
0155 G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
0156
0157 void WarningSignA(const G4String& method, const G4String& icase, G4double A,
0158 const G4ThreeVector& p, const G4ThreeVector& v) const;
0159 void WarningSignB(const G4String& method, const G4String& icase, G4double f, G4double B,
0160 const G4ThreeVector& p, const G4ThreeVector& v) const;
0161 void WarningDistanceToIn(G4int k, const G4ThreeVector& p, const G4ThreeVector& v,
0162 G4double tmin, G4double tmax,
0163 const G4double ttin[2], const G4double ttout[2]) const;
0164 void WarningDistanceToOut(const G4ThreeVector& p,
0165 const G4ThreeVector& v,
0166 G4double tout) const;
0167
0168 private:
0169
0170 struct G4GenericTrapPlane
0171 {
0172 G4double A = 0.;
0173 G4double B = 0.;
0174 G4double C = 0.;
0175 G4double D = 0.;
0176 };
0177 struct G4GenericTrapSurface
0178 {
0179 G4double A = 0.;
0180 G4double B = 0.;
0181 G4double C = 0.;
0182 G4double D = 0.;
0183 G4double E = 0.;
0184 G4double F = 0.;
0185 G4double G = 0.;
0186 };
0187
0188
0189 G4double halfTolerance = 0.;
0190 G4double fScratch = 0.;
0191 G4double fDz = 0.;
0192 std::vector<G4TwoVector> fVertices = {0.,0.,0.,0.,0.,0.,0.,0.};
0193 G4TwoVector fDelta[4];
0194 G4bool fIsTwisted = false;
0195 G4double fTwist[5] = {0.};
0196 G4ThreeVector fMinBBox{0.};
0197 G4ThreeVector fMaxBBox{0.};
0198 G4int fVisSubdivisions = 0;
0199 G4GenericTrapPlane fPlane[8];
0200 G4GenericTrapSurface fSurf[4];
0201 mutable G4double fArea[4] = {0.};
0202 mutable G4bool fRebuildPolyhedron = false;
0203 mutable G4Polyhedron* fpPolyhedron = nullptr;
0204
0205
0206 G4double fSurfaceArea = 0.;
0207 G4double fCubicVolume = 0.;
0208 };
0209
0210 #include "G4GenericTrap.icc"
0211
0212 #endif
0213
0214 #endif