File indexing completed on 2025-01-18 09:59:28
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 inline
0037 G4double G4VTwistSurface::DistanceToPlaneWithV(const G4ThreeVector& p,
0038 const G4ThreeVector& v,
0039 const G4ThreeVector& x0,
0040 const G4ThreeVector& n0,
0041 G4ThreeVector& xx)
0042 {
0043 G4double q = n0 * v;
0044 G4double t = kInfinity;
0045 if (q != 0.0) { t = (n0 * (x0 - p)) / q; }
0046 xx = p + t * v;
0047 return t;
0048 }
0049
0050
0051
0052
0053 inline
0054 G4double G4VTwistSurface::DistanceToPlane(const G4ThreeVector& p,
0055 const G4ThreeVector& x0,
0056 const G4ThreeVector& n0,
0057 G4ThreeVector& xx)
0058 {
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078 G4double t;
0079 G4ThreeVector n = n0.unit();
0080 t = n * (p - x0);
0081 xx = p - t * n;
0082 return t;
0083 }
0084
0085
0086
0087
0088 inline
0089 G4double G4VTwistSurface::DistanceToPlane(const G4ThreeVector& p,
0090 const G4ThreeVector& x0,
0091 const G4ThreeVector& t1,
0092 const G4ThreeVector& t2,
0093 G4ThreeVector& xx,
0094 G4ThreeVector& n)
0095 {
0096
0097
0098
0099
0100
0101
0102 n = (t1.cross(t2)).unit();
0103 return DistanceToPlane(p, x0, n, xx);
0104 }
0105
0106
0107
0108
0109 inline
0110 G4double G4VTwistSurface::DistanceToLine(const G4ThreeVector& p,
0111 const G4ThreeVector& x0,
0112 const G4ThreeVector& d,
0113 G4ThreeVector& xx)
0114 {
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138 G4double t;
0139 G4ThreeVector dir = d.unit();
0140 t = - dir * (x0 - p);
0141 xx = x0 + t * dir;
0142
0143 G4ThreeVector dist = xx - p;
0144 return dist.mag();
0145 }
0146
0147
0148
0149
0150 inline
0151 G4bool G4VTwistSurface::IsAxis0(G4int areacode) const
0152 {
0153 return (areacode & sAxis0) != 0;
0154 }
0155
0156
0157
0158
0159 inline
0160 G4bool G4VTwistSurface::IsAxis1(G4int areacode) const
0161 {
0162 return (areacode & sAxis1) != 0;
0163 }
0164
0165
0166
0167
0168 inline
0169 G4bool G4VTwistSurface::IsOutside(G4int areacode) const
0170 {
0171 return (areacode & sInside) == 0;
0172 }
0173
0174
0175
0176
0177 inline
0178 G4bool G4VTwistSurface::IsInside(G4int areacode, G4bool testbitmode) const
0179 {
0180 if ((areacode & sInside) != 0) {
0181 if (testbitmode) {
0182 return true;
0183 } else {
0184 if (((areacode & sBoundary) == 0) && ((areacode & sCorner) == 0)) return true;
0185 }
0186 }
0187 return false;
0188 }
0189
0190
0191
0192
0193 inline
0194 G4bool G4VTwistSurface::IsBoundary(G4int areacode, G4bool testbitmode) const
0195 {
0196 if ((areacode & sBoundary) == sBoundary) {
0197 if (testbitmode) {
0198 return true;
0199 } else {
0200 if ((areacode & sInside) == sInside) return true;
0201 }
0202 }
0203 return false;
0204 }
0205
0206
0207
0208
0209 inline
0210 G4bool G4VTwistSurface::IsCorner(G4int areacode, G4bool testbitmode) const
0211 {
0212 if ((areacode & sCorner) == sCorner) {
0213 if (testbitmode) {
0214 return true;
0215 } else {
0216 if ((areacode & sInside) == sInside) return true;
0217 }
0218 }
0219 return false;
0220 }
0221
0222
0223
0224
0225 inline
0226 G4int G4VTwistSurface::GetAxisType(G4int areacode, G4int whichaxis) const
0227 {
0228 G4int axiscode = areacode & sAxisMask & whichaxis;
0229
0230 if (axiscode == (sAxisX & sAxis0) ||
0231 axiscode == (sAxisX & sAxis1)) {
0232 return sAxisX;
0233 } else if (axiscode == (sAxisY & sAxis0) ||
0234 axiscode == (sAxisY & sAxis1)) {
0235 return sAxisY;
0236 } else if (axiscode == (sAxisZ & sAxis0) ||
0237 axiscode == (sAxisZ & sAxis1)) {
0238 return sAxisZ;
0239 } else if (axiscode == (sAxisRho & sAxis0) ||
0240 axiscode == (sAxisRho & sAxis1)) {
0241 return sAxisRho;
0242 } else if (axiscode == (sAxisPhi & sAxis0) ||
0243 axiscode == (sAxisPhi & sAxis1)) {
0244 return sAxisPhi;
0245 } else {
0246 std::ostringstream message;
0247 message << "Configuration not supported." << G4endl
0248 << " areacode = " << areacode;
0249 G4Exception("G4VTwistSurface::GetAxisType()","GeomSolids0001",
0250 FatalException, message);
0251 }
0252 return 1;
0253 }
0254
0255
0256
0257
0258 inline
0259 G4ThreeVector G4VTwistSurface::ComputeGlobalPoint(const G4ThreeVector& lp) const
0260 {
0261 return fRot * G4ThreeVector(lp) + fTrans;
0262 }
0263
0264
0265
0266
0267 inline
0268 G4ThreeVector G4VTwistSurface::ComputeLocalPoint(const G4ThreeVector& gp) const
0269 {
0270 return fRot.inverse() * ( G4ThreeVector(gp) - fTrans ) ;
0271 }
0272
0273
0274
0275
0276 inline G4ThreeVector
0277 G4VTwistSurface::ComputeGlobalDirection(const G4ThreeVector& lp) const
0278 {
0279 return fRot * G4ThreeVector(lp);
0280 }
0281
0282
0283
0284
0285 inline G4ThreeVector
0286 G4VTwistSurface::ComputeLocalDirection(const G4ThreeVector& gp) const
0287 {
0288 return fRot.inverse() * G4ThreeVector(gp);
0289 }
0290
0291
0292
0293
0294 inline void
0295 G4VTwistSurface::SetNeighbours(G4VTwistSurface* ax0min, G4VTwistSurface* ax1min,
0296 G4VTwistSurface* ax0max, G4VTwistSurface* ax1max)
0297 {
0298 fNeighbours[0] = ax0min;
0299 fNeighbours[1] = ax1min;
0300 fNeighbours[2] = ax0max;
0301 fNeighbours[3] = ax1max;
0302 }
0303
0304
0305
0306
0307 inline G4int
0308 G4VTwistSurface::GetNeighbours(G4int areacode, G4VTwistSurface** surfaces)
0309 {
0310
0311 G4int sAxis0Min = sAxis0 & sAxisMin ;
0312 G4int sAxis1Min = sAxis1 & sAxisMin ;
0313 G4int sAxis0Max = sAxis0 & sAxisMax ;
0314 G4int sAxis1Max = sAxis1 & sAxisMax ;
0315
0316 G4int i = 0;
0317
0318 if ( (areacode & sAxis0Min ) == sAxis0Min )
0319 {
0320 surfaces[i] = fNeighbours[0] ;
0321 ++i ;
0322 }
0323
0324 if ( ( areacode & sAxis1Min ) == sAxis1Min )
0325 {
0326 surfaces[i] = fNeighbours[1] ;
0327 ++i ;
0328 if ( i == 2 ) return i ;
0329 }
0330
0331 if ( ( areacode & sAxis0Max ) == sAxis0Max )
0332 {
0333 surfaces[i] = fNeighbours[2] ;
0334 ++i ;
0335 if ( i == 2 ) return i ;
0336 }
0337
0338 if ( ( areacode & sAxis1Max ) == sAxis1Max )
0339 {
0340 surfaces[i] = fNeighbours[3] ;
0341 ++i ;
0342 if ( i == 2 ) return i ;
0343 }
0344
0345 return i ;
0346 }
0347
0348
0349
0350
0351 inline
0352 G4ThreeVector G4VTwistSurface::GetCorner(G4int areacode) const
0353 {
0354 if ((areacode & sCorner) == 0)
0355 {
0356 std::ostringstream message;
0357 message << "Area code must represent corner." << G4endl
0358 << " areacode = " << areacode;
0359 G4Exception("G4VTwistSurface::GetCorner()","GeomSolids0002",
0360 FatalException, message);
0361 }
0362
0363 if ((areacode & sC0Min1Min) == sC0Min1Min) {
0364 return fCorners[0];
0365 } else if ((areacode & sC0Max1Min) == sC0Max1Min) {
0366 return fCorners[1];
0367 } else if ((areacode & sC0Max1Max) == sC0Max1Max) {
0368 return fCorners[2];
0369 } else if ((areacode & sC0Min1Max) == sC0Min1Max) {
0370 return fCorners[3];
0371 } else {
0372 std::ostringstream message;
0373 message << "Configuration not supported." << G4endl
0374 << " areacode = " << areacode;
0375 G4Exception("G4VTwistSurface::GetCorner()", "GeomSolids0001",
0376 FatalException, message);
0377 }
0378 return fCorners[0];
0379 }