00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 #ifndef G4ExtrudedSolid_HH
00063 #define G4ExtrudedSolid_HH
00064
00065 #include <vector>
00066
00067 #include "G4TwoVector.hh"
00068
00069 #include "G4TessellatedSolid.hh"
00070
00071 class G4VFacet;
00072
00073 class G4ExtrudedSolid : public G4TessellatedSolid
00074 {
00075
00076 public:
00077
00078 struct ZSection
00079 {
00080 ZSection(G4double z, G4TwoVector offset, G4double scale)
00081 : fZ(z), fOffset(offset), fScale(scale) {}
00082
00083 G4double fZ;
00084 G4TwoVector fOffset;
00085 G4double fScale;
00086 };
00087
00088 public:
00089
00090 G4ExtrudedSolid( const G4String& pName,
00091 std::vector<G4TwoVector> polygon,
00092 std::vector<ZSection> zsections);
00093
00094
00095 G4ExtrudedSolid( const G4String& pName,
00096 std::vector<G4TwoVector> polygon,
00097 G4double halfZ,
00098 G4TwoVector off1, G4double scale1,
00099 G4TwoVector off2, G4double scale2 );
00100
00101
00102 virtual ~G4ExtrudedSolid();
00103
00104
00105
00106
00107 inline G4int GetNofVertices() const;
00108 inline G4TwoVector GetVertex(G4int index) const;
00109 inline std::vector<G4TwoVector> GetPolygon() const;
00110
00111 inline G4int GetNofZSections() const;
00112 inline ZSection GetZSection(G4int index) const;
00113 inline std::vector<ZSection> GetZSections() const;
00114
00115
00116
00117 EInside Inside (const G4ThreeVector &p) const;
00118 G4double DistanceToOut(const G4ThreeVector &p,
00119 const G4ThreeVector &v,
00120 const G4bool calcNorm=false,
00121 G4bool *validNorm=0, G4ThreeVector *n=0) const;
00122 G4double DistanceToOut (const G4ThreeVector &p) const;
00123 G4GeometryType GetEntityType () const;
00124 G4VSolid* Clone() const;
00125
00126 std::ostream& StreamInfo(std::ostream &os) const;
00127
00128 public:
00129
00130 G4ExtrudedSolid(__void__&);
00131
00132
00133
00134
00135 G4ExtrudedSolid(const G4ExtrudedSolid& rhs);
00136 G4ExtrudedSolid& operator=(const G4ExtrudedSolid& rhs);
00137
00138
00139 private:
00140
00141 void ComputeProjectionParameters();
00142
00143 G4ThreeVector GetVertex(G4int iz, G4int ind) const;
00144 G4TwoVector ProjectPoint(const G4ThreeVector& point) const;
00145
00146 G4bool IsSameLine(G4TwoVector p,
00147 G4TwoVector l1, G4TwoVector l2) const;
00148 G4bool IsSameLineSegment(G4TwoVector p,
00149 G4TwoVector l1, G4TwoVector l2) const;
00150 G4bool IsSameSide(G4TwoVector p1, G4TwoVector p2,
00151 G4TwoVector l1, G4TwoVector l2) const;
00152 G4bool IsPointInside(G4TwoVector a, G4TwoVector b, G4TwoVector c,
00153 G4TwoVector p) const;
00154 G4double GetAngle(G4TwoVector p0, G4TwoVector pa, G4TwoVector pb) const;
00155
00156 G4VFacet* MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const;
00157 G4VFacet* MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const;
00158
00159 G4bool AddGeneralPolygonFacets();
00160 G4bool MakeFacets();
00161 G4bool IsConvex() const;
00162
00163
00164 private:
00165
00166 G4int fNv;
00167 G4int fNz;
00168 std::vector<G4TwoVector> fPolygon;
00169 std::vector<ZSection> fZSections;
00170 std::vector< std::vector<G4int> > fTriangles;
00171 G4bool fIsConvex;
00172 G4GeometryType fGeometryType;
00173
00174 std::vector<G4double> fKScales;
00175 std::vector<G4double> fScale0s;
00176 std::vector<G4TwoVector> fKOffsets;
00177 std::vector<G4TwoVector> fOffset0s;
00178 };
00179
00180 #include "G4ExtrudedSolid.icc"
00181
00182 #endif