Warning, file /include/Geant4/G4ExtrudedSolid.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 G4VSolid* Clone() const override;
0135
0136 std::ostream& StreamInfo(std::ostream& os) const override;
0137
0138 G4ExtrudedSolid(__void__&);
0139
0140
0141
0142
0143 G4ExtrudedSolid(const G4ExtrudedSolid& rhs);
0144 G4ExtrudedSolid& operator=(const G4ExtrudedSolid& rhs);
0145
0146
0147 private:
0148
0149 void ComputeProjectionParameters();
0150 void ComputeLateralPlanes();
0151 inline G4bool PointInPolygon(const G4ThreeVector& p) const;
0152 inline G4double DistanceToPolygonSqr(const G4ThreeVector& p) const;
0153 G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
0154
0155 G4ThreeVector GetVertex(G4int iz, G4int ind) const;
0156 G4TwoVector ProjectPoint(const G4ThreeVector& point) const;
0157
0158 G4bool IsSameLine(const G4TwoVector& p,
0159 const G4TwoVector& l1,
0160 const G4TwoVector& l2) const;
0161 G4bool IsSameLineSegment(const G4TwoVector& p,
0162 const G4TwoVector& l1,
0163 const G4TwoVector& l2) const;
0164 G4bool IsSameSide(const G4TwoVector& p1,
0165 const G4TwoVector& p2,
0166 const G4TwoVector& l1,
0167 const G4TwoVector& l2) const;
0168 G4bool IsPointInside(const G4TwoVector& a,
0169 const G4TwoVector& b,
0170 const G4TwoVector& c,
0171 const G4TwoVector& p) const;
0172 G4double GetAngle(const G4TwoVector& p0,
0173 const G4TwoVector& pa,
0174 const G4TwoVector& pb) const;
0175
0176 G4VFacet* MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const;
0177 G4VFacet* MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const;
0178
0179 G4bool AddGeneralPolygonFacets();
0180 G4bool MakeFacets();
0181
0182 private:
0183
0184 std::size_t fNv;
0185 std::size_t fNz;
0186 std::vector<G4TwoVector> fPolygon;
0187 std::vector<ZSection> fZSections;
0188 std::vector< std::vector<G4int> > fTriangles;
0189 G4bool fIsConvex = false;
0190 G4GeometryType fGeometryType;
0191
0192 G4int fSolidType = 0;
0193 struct plane { G4double a,b,c,d; };
0194 std::vector<plane> fPlanes;
0195 struct line { G4double k,m; };
0196 std::vector<line> fLines;
0197 std::vector<G4double> fLengths;
0198
0199 std::vector<G4double> fKScales;
0200 std::vector<G4double> fScale0s;
0201 std::vector<G4TwoVector> fKOffsets;
0202 std::vector<G4TwoVector> fOffset0s;
0203 };
0204
0205 #include "G4ExtrudedSolid.icc"
0206
0207 #endif
0208
0209 #endif