File indexing completed on 2025-01-18 09:58:21
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 #ifndef G4GENERICTRAP_HH
0059 #define G4GENERICTRAP_HH
0060
0061 #include "G4GeomTypes.hh"
0062
0063 #if defined(G4GEOM_USE_USOLIDS)
0064 #define G4GEOM_USE_UGENERICTRAP 1
0065 #endif
0066
0067 #if defined(G4GEOM_USE_UGENERICTRAP)
0068 #define G4UGenericTrap G4GenericTrap
0069 #include "G4UGenericTrap.hh"
0070 #else
0071
0072 #include <vector>
0073
0074 #include "globals.hh"
0075 #include "G4TwoVector.hh"
0076 #include "G4VSolid.hh"
0077 #include "G4TessellatedSolid.hh"
0078
0079 class G4GenericTrap : public G4VSolid
0080 {
0081 public:
0082
0083 G4GenericTrap( const G4String& name, G4double halfZ,
0084 const std::vector<G4TwoVector>& vertices );
0085
0086
0087 ~G4GenericTrap() override;
0088
0089
0090
0091
0092 inline G4double GetZHalfLength() const;
0093 inline G4int GetNofVertices() const;
0094 inline G4TwoVector GetVertex(G4int index) const;
0095 inline const std::vector<G4TwoVector>& GetVertices() const;
0096 inline G4double GetTwistAngle(G4int index) const;
0097 inline G4bool IsTwisted() const;
0098 inline G4int GetVisSubdivisions() const;
0099 inline void SetVisSubdivisions(G4int subdiv);
0100
0101
0102
0103 EInside Inside(const G4ThreeVector& p) const override;
0104 G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
0105 G4double DistanceToIn(const G4ThreeVector& p,
0106 const G4ThreeVector& v) const override;
0107 G4double DistanceToIn(const G4ThreeVector& p) const override;
0108 G4double DistanceToOut(const G4ThreeVector& p,
0109 const G4ThreeVector& v,
0110 const G4bool calcNorm = false,
0111 G4bool* validNorm = nullptr,
0112 G4ThreeVector* n = nullptr) const override;
0113 G4double DistanceToOut(const G4ThreeVector& p) const override;
0114 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0115 G4bool CalculateExtent(const EAxis pAxis,
0116 const G4VoxelLimits& pVoxelLimit,
0117 const G4AffineTransform& pTransform,
0118 G4double& pmin, G4double& pmax) const override;
0119
0120 G4GeometryType GetEntityType() const override;
0121
0122 G4VSolid* Clone() const override;
0123
0124 std::ostream& StreamInfo(std::ostream& os) const override;
0125
0126 G4ThreeVector GetPointOnSurface() const override ;
0127
0128 G4double GetCubicVolume() override;
0129 G4double GetSurfaceArea() override;
0130
0131
0132
0133 G4Polyhedron* GetPolyhedron () const override;
0134 void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
0135 G4VisExtent GetExtent() const override;
0136 G4Polyhedron* CreatePolyhedron() const override;
0137
0138 G4GenericTrap(__void__&);
0139
0140
0141
0142
0143 G4GenericTrap(const G4GenericTrap& rhs);
0144 G4GenericTrap& operator=(const G4GenericTrap& rhs);
0145
0146
0147 private:
0148
0149
0150
0151 inline void SetTwistAngle(G4int index, G4double twist);
0152 G4bool ComputeIsTwisted() ;
0153 G4bool CheckOrder(const std::vector<G4TwoVector>& vertices) const;
0154 G4bool IsSegCrossing(const G4TwoVector& a, const G4TwoVector& b,
0155 const G4TwoVector& c, const G4TwoVector& d) const;
0156 G4bool IsSegCrossingZ(const G4TwoVector& a, const G4TwoVector& b,
0157 const G4TwoVector& c, const G4TwoVector& d) const;
0158 void ReorderVertices(std::vector<G4ThreeVector>& vertices) const;
0159 void ComputeBBox();
0160 inline G4ThreeVector GetMinimumBBox() const;
0161 inline G4ThreeVector GetMaximumBBox() const;
0162
0163 G4VFacet* MakeDownFacet(const std::vector<G4ThreeVector>& fromVertices,
0164 G4int ind1, G4int ind2, G4int ind3) const;
0165 G4VFacet* MakeUpFacet(const std::vector<G4ThreeVector>& fromVertices,
0166 G4int ind1, G4int ind2, G4int ind3) const;
0167 G4VFacet* MakeSideFacet(const G4ThreeVector& downVertex0,
0168 const G4ThreeVector& downVertex1,
0169 const G4ThreeVector& upVertex1,
0170 const G4ThreeVector& upVertex0) const;
0171 G4TessellatedSolid* CreateTessellatedSolid() const;
0172
0173 EInside InsidePolygone(const G4ThreeVector& p,
0174 const std::vector<G4TwoVector>& poly) const;
0175 G4double DistToPlane(const G4ThreeVector& p,
0176 const G4ThreeVector& v, const G4int ipl) const ;
0177 G4double DistToTriangle(const G4ThreeVector& p,
0178 const G4ThreeVector& v, const G4int ipl) const;
0179 G4ThreeVector NormalToPlane(const G4ThreeVector& p,
0180 const G4int ipl) const;
0181 G4double SafetyToFace(const G4ThreeVector& p, const G4int iseg) const;
0182 G4double GetLateralFaceArea(G4int iface) const;
0183
0184 protected:
0185
0186 mutable G4bool fRebuildPolyhedron = false;
0187 mutable G4Polyhedron* fpPolyhedron = nullptr;
0188
0189 private:
0190
0191
0192
0193 static const G4int fgkNofVertices;
0194 static const G4double fgkTolerance;
0195
0196 G4double halfCarTolerance;
0197
0198
0199
0200 G4double fDz;
0201 std::vector<G4TwoVector> fVertices;
0202 G4bool fIsTwisted = false;
0203 G4double fTwist[4];
0204 G4TessellatedSolid* fTessellatedSolid = nullptr;
0205 G4ThreeVector fMinBBoxVector;
0206 G4ThreeVector fMaxBBoxVector;
0207 G4int fVisSubdivisions = 0;
0208
0209 enum ESide {kUndef,kXY0,kXY1,kXY2,kXY3,kMZ,kPZ};
0210
0211
0212 G4double fSurfaceArea = 0.0;
0213 G4double fCubicVolume = 0.0;
0214
0215 };
0216
0217 #include "G4GenericTrap.icc"
0218
0219 #endif
0220
0221 #endif