File indexing completed on 2025-09-17 08:58: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 #ifndef G4EXTRUDEDSOLID_HH
0053 #define G4EXTRUDEDSOLID_HH
0054
0055 #include "G4GeomTypes.hh"
0056
0057 #if defined(G4GEOM_USE_USOLIDS)
0058 #define G4GEOM_USE_UEXTRUDEDSOLID 1
0059 #endif
0060
0061 #if defined(G4GEOM_USE_UEXTRUDEDSOLID)
0062 #define G4UExtrudedSolid G4ExtrudedSolid
0063 #include "G4UExtrudedSolid.hh"
0064 #else
0065
0066 #include <vector>
0067
0068 #include "G4TwoVector.hh"
0069 #include "G4TessellatedSolid.hh"
0070
0071 class G4ExtrudedSolid : public G4TessellatedSolid
0072 {
0073
0074 public:
0075
0076 struct ZSection
0077 {
0078 ZSection() : fZ(0.), fOffset(0.,0.), fScale(1.) {}
0079 ZSection(G4double z, const G4TwoVector& offset, G4double scale)
0080 : fZ(z), fOffset(offset), fScale(scale) {}
0081
0082 G4double fZ;
0083 G4TwoVector fOffset;
0084 G4double fScale;
0085 };
0086
0087 G4ExtrudedSolid( const G4String& pName,
0088 const std::vector<G4TwoVector>& polygon,
0089 const std::vector<ZSection>& zsections);
0090
0091
0092 G4ExtrudedSolid( const G4String& pName,
0093 const std::vector<G4TwoVector>& polygon,
0094 G4double halfZ,
0095 const G4TwoVector& off1 = G4TwoVector(0.,0.),
0096 G4double scale1 = 1.,
0097 const G4TwoVector& off2 = G4TwoVector(0.,0.),
0098 G4double scale2 = 1. );
0099
0100
0101 ~G4ExtrudedSolid() override;
0102
0103
0104
0105
0106 inline G4int GetNofVertices() const;
0107 inline G4TwoVector GetVertex(G4int index) const;
0108 inline std::vector<G4TwoVector> GetPolygon() const;
0109
0110 inline G4int GetNofZSections() const;
0111 inline ZSection GetZSection(G4int index) const;
0112 inline std::vector<ZSection> GetZSections() const;
0113
0114
0115
0116 EInside Inside(const G4ThreeVector& p) const override;
0117 G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
0118 G4double DistanceToIn(const G4ThreeVector& p,
0119 const G4ThreeVector& v) const override;
0120 G4double DistanceToIn(const G4ThreeVector& p ) const override;
0121 G4double DistanceToOut(const G4ThreeVector& p,
0122 const G4ThreeVector& v,
0123 const G4bool calcNorm = false,
0124 G4bool* validNorm = nullptr,
0125 G4ThreeVector* n = nullptr) const override;
0126 G4double DistanceToOut(const G4ThreeVector& p) const override;
0127
0128 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0129 G4bool CalculateExtent(const EAxis pAxis,
0130 const G4VoxelLimits& pVoxelLimit,
0131 const G4AffineTransform& pTransform,
0132 G4double& pMin, G4double& pMax) const override;
0133 G4GeometryType GetEntityType () const override;
0134 G4bool IsFaceted () const override;
0135 G4VSolid* Clone() const override;
0136
0137 std::ostream& StreamInfo(std::ostream& os) const override;
0138
0139 G4ExtrudedSolid(__void__&);
0140
0141
0142
0143
0144 G4ExtrudedSolid(const G4ExtrudedSolid& rhs);
0145 G4ExtrudedSolid& operator=(const G4ExtrudedSolid& rhs);
0146
0147
0148 private:
0149
0150 void ComputeProjectionParameters();
0151 void ComputeLateralPlanes();
0152 inline G4bool PointInPolygon(const G4ThreeVector& p) const;
0153 inline G4double DistanceToPolygonSqr(const G4ThreeVector& p) const;
0154 G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
0155
0156 G4ThreeVector GetVertex(G4int iz, G4int ind) const;
0157 G4TwoVector ProjectPoint(const G4ThreeVector& point) const;
0158
0159 G4bool IsSameLine(const G4TwoVector& p,
0160 const G4TwoVector& l1,
0161 const G4TwoVector& l2) const;
0162 G4bool IsSameLineSegment(const G4TwoVector& p,
0163 const G4TwoVector& l1,
0164 const G4TwoVector& l2) const;
0165 G4bool IsSameSide(const G4TwoVector& p1,
0166 const G4TwoVector& p2,
0167 const G4TwoVector& l1,
0168 const G4TwoVector& l2) const;
0169 G4bool IsPointInside(const G4TwoVector& a,
0170 const G4TwoVector& b,
0171 const G4TwoVector& c,
0172 const G4TwoVector& p) const;
0173 G4double GetAngle(const G4TwoVector& p0,
0174 const G4TwoVector& pa,
0175 const G4TwoVector& pb) const;
0176
0177 G4VFacet* MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const;
0178 G4VFacet* MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const;
0179
0180 G4bool AddGeneralPolygonFacets();
0181 G4bool MakeFacets();
0182
0183 private:
0184
0185 std::size_t fNv;
0186 std::size_t fNz;
0187 std::vector<G4TwoVector> fPolygon;
0188 std::vector<ZSection> fZSections;
0189 std::vector< std::vector<G4int> > fTriangles;
0190 G4bool fIsConvex = false;
0191 G4GeometryType fGeometryType;
0192
0193 G4int fSolidType = 0;
0194 struct plane { G4double a,b,c,d; };
0195 std::vector<plane> fPlanes;
0196 struct line { G4double k,m; };
0197 std::vector<line> fLines;
0198 std::vector<G4double> fLengths;
0199
0200 std::vector<G4double> fKScales;
0201 std::vector<G4double> fScale0s;
0202 std::vector<G4TwoVector> fKOffsets;
0203 std::vector<G4TwoVector> fOffset0s;
0204 };
0205
0206 #include "G4ExtrudedSolid.icc"
0207
0208 #endif
0209
0210 #endif