File indexing completed on 2025-01-18 09:58:57
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 #ifndef G4PolyhedraSide_hh
0048 #define G4PolyhedraSide_hh
0049
0050 #include "G4VCSGface.hh"
0051
0052 class G4IntersectingCone;
0053
0054 struct G4PolyhedraSideRZ
0055 {
0056 G4double r, z;
0057 };
0058
0059
0060
0061
0062 #include "G4GeomSplitter.hh"
0063
0064
0065
0066
0067 class G4PhSideData
0068 {
0069 public:
0070
0071 void initialize()
0072 {
0073 fPhix = 0.; fPhiy = 0.; fPhiz = 0.; fPhik = 0.;
0074 }
0075
0076 G4double fPhix=0., fPhiy=0., fPhiz=0., fPhik=0.;
0077 };
0078
0079
0080
0081
0082
0083 using G4PhSideManager = G4GeomSplitter<G4PhSideData>;
0084
0085
0086
0087
0088 class G4PolyhedraSide : public G4VCSGface
0089 {
0090
0091 public:
0092
0093 G4PolyhedraSide( const G4PolyhedraSideRZ* prevRZ,
0094 const G4PolyhedraSideRZ* tail,
0095 const G4PolyhedraSideRZ* head,
0096 const G4PolyhedraSideRZ* nextRZ,
0097 G4int numSide,
0098 G4double phiStart, G4double phiTotal,
0099 G4bool phiIsOpen, G4bool isAllBehind = false );
0100 ~G4PolyhedraSide() override;
0101
0102 G4PolyhedraSide( const G4PolyhedraSide& source );
0103 G4PolyhedraSide& operator=( const G4PolyhedraSide& source );
0104
0105 G4bool Intersect( const G4ThreeVector& p, const G4ThreeVector& v,
0106 G4bool outgoing, G4double surfTolerance,
0107 G4double& distance, G4double& distFromSurface,
0108 G4ThreeVector& normal, G4bool& allBehind ) override;
0109
0110 G4double Distance( const G4ThreeVector& p, G4bool outgoing ) override;
0111
0112 EInside Inside( const G4ThreeVector &p, G4double tolerance,
0113 G4double *bestDistance ) override;
0114
0115 G4ThreeVector Normal( const G4ThreeVector& p,
0116 G4double* bestDistance ) override;
0117
0118 G4double Extent( const G4ThreeVector axis ) override;
0119
0120 void CalculateExtent( const EAxis axis,
0121 const G4VoxelLimits &voxelLimit,
0122 const G4AffineTransform& tranform,
0123 G4SolidExtentList& extentList ) override;
0124
0125 G4VCSGface* Clone() override { return new G4PolyhedraSide( *this ); }
0126
0127
0128
0129 G4double SurfaceTriangle( const G4ThreeVector& p1,
0130 const G4ThreeVector& p2,
0131 const G4ThreeVector& p3,
0132 G4ThreeVector* p4 );
0133 G4ThreeVector GetPointOnPlane( const G4ThreeVector& p0, const G4ThreeVector& p1,
0134 const G4ThreeVector& p2, const G4ThreeVector& p3,
0135 G4double* Area );
0136 G4double SurfaceArea() override;
0137 G4ThreeVector GetPointOnFace() override;
0138
0139 G4PolyhedraSide(__void__&);
0140
0141
0142
0143
0144 inline G4int GetInstanceID() const { return instanceID; }
0145
0146
0147 static const G4PhSideManager& GetSubInstanceManager();
0148
0149
0150
0151
0152
0153 struct sG4PolyhedraSideVec;
0154 friend struct sG4PolyhedraSideVec;
0155
0156 using G4PolyhedraSideEdge = struct sG4PolyhedraSideEdge
0157 {
0158 G4ThreeVector normal;
0159 G4ThreeVector corner[2];
0160 G4ThreeVector cornNorm[2];
0161 };
0162
0163 using G4PolyhedraSideVec = struct sG4PolyhedraSideVec
0164 {
0165 G4ThreeVector normal,
0166 center,
0167 surfPhi,
0168 surfRZ;
0169 G4PolyhedraSideEdge* edges[2];
0170
0171 G4ThreeVector edgeNorm[2];
0172 };
0173
0174 protected:
0175
0176 G4bool IntersectSidePlane( const G4ThreeVector& p, const G4ThreeVector& v,
0177 const G4PolyhedraSideVec& vec,
0178 G4double normSign,
0179 G4double surfTolerance,
0180 G4double &distance,
0181 G4double &distFromSurface );
0182
0183 G4int LineHitsSegments( const G4ThreeVector& p,
0184 const G4ThreeVector& v,
0185 G4int* i1, G4int* i2 );
0186
0187 G4int ClosestPhiSegment( G4double phi );
0188
0189 G4int PhiSegment( G4double phi );
0190
0191 G4double GetPhi( const G4ThreeVector& p );
0192
0193 G4double DistanceToOneSide( const G4ThreeVector& p,
0194 const G4PolyhedraSideVec& vec,
0195 G4double* normDist );
0196
0197 G4double DistanceAway( const G4ThreeVector& p,
0198 const G4PolyhedraSideVec& vec,
0199 G4double* normDist );
0200
0201 void CopyStuff( const G4PolyhedraSide& source );
0202
0203 protected:
0204
0205 G4int numSide = 0;
0206 G4double r[2], z[2];
0207 G4double startPhi,
0208 deltaPhi,
0209 endPhi;
0210 G4bool phiIsOpen = false;
0211 G4bool allBehind = false;
0212
0213 G4IntersectingCone* cone = nullptr;
0214
0215 G4PolyhedraSideVec* vecs = nullptr;
0216 G4PolyhedraSideEdge* edges = nullptr;
0217 G4double lenRZ,
0218 lenPhi[2];
0219 G4double edgeNorm;
0220
0221 private:
0222
0223 G4double kCarTolerance;
0224 G4double fSurfaceArea = 0.0;
0225
0226 G4int instanceID;
0227
0228 G4GEOM_DLL static G4PhSideManager subInstanceManager;
0229
0230 };
0231
0232 #endif