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
00063
00064
00065
00066
00067 #ifndef G4GenericTrap_HH
00068 #define G4GenericTrap_HH
00069
00070 #include <vector>
00071
00072 #include "G4TwoVector.hh"
00073 #include "G4VSolid.hh"
00074 #include "globals.hh"
00075
00076 class G4VFacet;
00077 class G4TessellatedSolid;
00078
00079 class G4GenericTrap : public G4VSolid
00080 {
00081 public:
00082
00083 G4GenericTrap( const G4String& name, G4double halfZ,
00084 const std::vector<G4TwoVector>& vertices );
00085
00086
00087 ~G4GenericTrap();
00088
00089
00090
00091
00092 inline G4double GetZHalfLength() const;
00093 inline G4int GetNofVertices() const;
00094 inline G4TwoVector GetVertex(G4int index) const;
00095 inline const std::vector<G4TwoVector>& GetVertices() const;
00096 inline G4double GetTwistAngle(G4int index) const;
00097 inline G4bool IsTwisted() const;
00098 inline G4int GetVisSubdivisions() const;
00099 inline void SetVisSubdivisions(G4int subdiv);
00100
00101
00102
00103 EInside Inside(const G4ThreeVector& p) const;
00104 G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const;
00105 G4double DistanceToIn(const G4ThreeVector& p,
00106 const G4ThreeVector& v) const;
00107 G4double DistanceToIn(const G4ThreeVector& p) const;
00108 G4double DistanceToOut(const G4ThreeVector& p,
00109 const G4ThreeVector& v,
00110 const G4bool calcNorm = false,
00111 G4bool *validNorm = 0,
00112 G4ThreeVector *n = 0) const;
00113 G4double DistanceToOut(const G4ThreeVector& p) const;
00114 G4bool CalculateExtent(const EAxis pAxis,
00115 const G4VoxelLimits& pVoxelLimit,
00116 const G4AffineTransform& pTransform,
00117 G4double& pmin, G4double& pmax) const;
00118
00119 G4GeometryType GetEntityType() const;
00120
00121 G4VSolid* Clone() const;
00122
00123 std::ostream& StreamInfo(std::ostream& os) const;
00124
00125 G4ThreeVector GetPointOnSurface() const ;
00126
00127 G4double GetCubicVolume();
00128 G4double GetSurfaceArea();
00129
00130
00131
00132 G4Polyhedron* GetPolyhedron () const;
00133 void DescribeYourselfTo(G4VGraphicsScene& scene) const;
00134 G4VisExtent GetExtent() const;
00135 G4Polyhedron* CreatePolyhedron() const;
00136 G4NURBS* CreateNURBS() const;
00137
00138 public:
00139
00140 G4GenericTrap(__void__&);
00141
00142
00143
00144
00145 G4GenericTrap(const G4GenericTrap& rhs);
00146 G4GenericTrap& operator=(const G4GenericTrap& rhs);
00147
00148
00149 private:
00150
00151
00152
00153 inline void SetTwistAngle(G4int index, G4double twist);
00154 G4bool ComputeIsTwisted() ;
00155 G4bool CheckOrder(const std::vector<G4TwoVector>& vertices) const;
00156 G4bool IsSegCrossing(const G4TwoVector& a, const G4TwoVector& b,
00157 const G4TwoVector& c, const G4TwoVector& d) const;
00158 G4bool IsSegCrossingZ(const G4TwoVector& a, const G4TwoVector& b,
00159 const G4TwoVector& c, const G4TwoVector& d) const;
00160 G4ThreeVectorList* CreateRotatedVertices(const
00161 G4AffineTransform& pTransform) const;
00162 void ReorderVertices(std::vector<G4ThreeVector>& vertices) const;
00163 void ComputeBBox();
00164 inline G4ThreeVector GetMinimumBBox() const;
00165 inline G4ThreeVector GetMaximumBBox() const;
00166
00167 G4VFacet* MakeDownFacet(const std::vector<G4ThreeVector>& fromVertices,
00168 G4int ind1, G4int ind2, G4int ind3) const;
00169 G4VFacet* MakeUpFacet(const std::vector<G4ThreeVector>& fromVertices,
00170 G4int ind1, G4int ind2, G4int ind3) const;
00171 G4VFacet* MakeSideFacet(const G4ThreeVector& downVertex0,
00172 const G4ThreeVector& downVertex1,
00173 const G4ThreeVector& upVertex1,
00174 const G4ThreeVector& upVertex0) const;
00175 G4TessellatedSolid* CreateTessellatedSolid() const;
00176
00177 EInside InsidePolygone(const G4ThreeVector& p,
00178 const std::vector<G4TwoVector>& poly) const;
00179 G4double DistToPlane(const G4ThreeVector& p,
00180 const G4ThreeVector& v, const G4int ipl) const ;
00181 G4double DistToTriangle(const G4ThreeVector& p,
00182 const G4ThreeVector& v, const G4int ipl) const;
00183 G4ThreeVector NormalToPlane(const G4ThreeVector& p,
00184 const G4int ipl) const;
00185 G4double SafetyToFace(const G4ThreeVector& p, const G4int iseg) const;
00186 G4double GetFaceSurfaceArea(const G4ThreeVector& p0,
00187 const G4ThreeVector& p1,
00188 const G4ThreeVector& p2,
00189 const G4ThreeVector& p3) const;
00190 protected:
00191
00192 mutable G4Polyhedron* fpPolyhedron;
00193
00194 private:
00195
00196
00197
00198 static const G4int fgkNofVertices;
00199 static const G4double fgkTolerance;
00200
00201
00202
00203 G4double fDz;
00204 std::vector<G4TwoVector> fVertices;
00205 G4bool fIsTwisted;
00206 G4double fTwist[4];
00207 G4TessellatedSolid* fTessellatedSolid;
00208 G4ThreeVector fMinBBoxVector;
00209 G4ThreeVector fMaxBBoxVector;
00210 G4int fVisSubdivisions;
00211
00212 enum ESide {kUndefined,kXY0,kXY1,kXY2,kXY3,kMZ,kPZ};
00213
00214
00215 G4double fSurfaceArea;
00216 G4double fCubicVolume;
00217
00218 };
00219
00220 #include "G4GenericTrap.icc"
00221
00222 #endif