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 #ifndef G4PolyhedraSide_hh
00057 #define G4PolyhedraSide_hh
00058
00059 #include "G4VCSGface.hh"
00060
00061 class G4IntersectingCone;
00062
00063 struct G4PolyhedraSideRZ
00064 {
00065 G4double r, z;
00066 };
00067
00068 class G4PolyhedraSide : public G4VCSGface
00069 {
00070
00071 public:
00072
00073 G4PolyhedraSide( const G4PolyhedraSideRZ *prevRZ,
00074 const G4PolyhedraSideRZ *tail,
00075 const G4PolyhedraSideRZ *head,
00076 const G4PolyhedraSideRZ *nextRZ,
00077 G4int numSide,
00078 G4double phiStart, G4double phiTotal,
00079 G4bool phiIsOpen, G4bool isAllBehind=false );
00080 virtual ~G4PolyhedraSide();
00081
00082 G4PolyhedraSide( const G4PolyhedraSide &source );
00083 G4PolyhedraSide& operator=( const G4PolyhedraSide &source );
00084
00085 G4bool Intersect( const G4ThreeVector &p, const G4ThreeVector &v,
00086 G4bool outgoing, G4double surfTolerance,
00087 G4double &distance, G4double &distFromSurface,
00088 G4ThreeVector &normal, G4bool &allBehind );
00089
00090 G4double Distance( const G4ThreeVector &p, G4bool outgoing );
00091
00092 EInside Inside( const G4ThreeVector &p, G4double tolerance,
00093 G4double *bestDistance );
00094
00095 G4ThreeVector Normal( const G4ThreeVector &p, G4double *bestDistance );
00096
00097 G4double Extent( const G4ThreeVector axis );
00098
00099 void CalculateExtent( const EAxis axis,
00100 const G4VoxelLimits &voxelLimit,
00101 const G4AffineTransform &tranform,
00102 G4SolidExtentList &extentList );
00103
00104 G4VCSGface *Clone() { return new G4PolyhedraSide( *this ); }
00105
00106 public:
00107
00108
00109
00110 G4double SurfaceTriangle( G4ThreeVector p1,
00111 G4ThreeVector p2,
00112 G4ThreeVector p3,
00113 G4ThreeVector *p4 );
00114 G4ThreeVector GetPointOnPlane( G4ThreeVector p0, G4ThreeVector p1,
00115 G4ThreeVector p2, G4ThreeVector p3,
00116 G4double *Area );
00117 G4double SurfaceArea();
00118 G4ThreeVector GetPointOnFace();
00119
00120 public:
00121
00122 G4PolyhedraSide(__void__&);
00123
00124
00125
00126
00127 protected:
00128
00129
00130
00131
00132 struct sG4PolyhedraSideVec;
00133 friend struct sG4PolyhedraSideVec;
00134
00135 typedef struct sG4PolyhedraSideEdge
00136 {
00137 G4ThreeVector normal;
00138 G4ThreeVector corner[2];
00139 G4ThreeVector cornNorm[2];
00140 } G4PolyhedraSideEdge;
00141
00142 typedef struct sG4PolyhedraSideVec
00143 {
00144 G4ThreeVector normal,
00145 center,
00146 surfPhi,
00147 surfRZ;
00148 G4PolyhedraSideEdge *edges[2];
00149
00150 G4ThreeVector edgeNorm[2];
00151 } G4PolyhedraSideVec;
00152
00153 G4bool IntersectSidePlane( const G4ThreeVector &p, const G4ThreeVector &v,
00154 const G4PolyhedraSideVec& vec,
00155 G4double normSign,
00156 G4double surfTolerance,
00157 G4double &distance,
00158 G4double &distFromSurface );
00159
00160 G4int LineHitsSegments( const G4ThreeVector &p,
00161 const G4ThreeVector &v,
00162 G4int *i1, G4int *i2 );
00163
00164 G4int ClosestPhiSegment( G4double phi );
00165
00166 G4int PhiSegment( G4double phi );
00167
00168 G4double GetPhi( const G4ThreeVector& p );
00169
00170 G4double DistanceToOneSide( const G4ThreeVector &p,
00171 const G4PolyhedraSideVec &vec,
00172 G4double *normDist );
00173
00174 G4double DistanceAway( const G4ThreeVector &p,
00175 const G4PolyhedraSideVec &vec,
00176 G4double *normDist );
00177
00178 void CopyStuff( const G4PolyhedraSide &source );
00179
00180 protected:
00181
00182 G4int numSide;
00183 G4double r[2], z[2];
00184 G4double startPhi,
00185 deltaPhi,
00186 endPhi;
00187 G4bool phiIsOpen;
00188 G4bool allBehind;
00189
00190 G4IntersectingCone *cone;
00191
00192 G4PolyhedraSideVec *vecs;
00193 G4PolyhedraSideEdge *edges;
00194 G4double lenRZ,
00195 lenPhi[2];
00196 G4double edgeNorm;
00197
00198 private:
00199
00200 std::pair<G4ThreeVector, G4double> fPhi;
00201 G4double kCarTolerance;
00202 G4double fSurfaceArea;
00203 };
00204
00205 #endif