#include <G4TwistTubsFlatSide.hh>
Inheritance diagram for G4TwistTubsFlatSide:
Public Member Functions | |
G4TwistTubsFlatSide (const G4String &name, const G4RotationMatrix &rot, const G4ThreeVector &tlate, const G4ThreeVector &n, const EAxis axis1=kRho, const EAxis axis2=kPhi, G4double axis0min=-kInfinity, G4double axis1min=-kInfinity, G4double axis0max=kInfinity, G4double axis1max=kInfinity) | |
G4TwistTubsFlatSide (const G4String &name, G4double EndInnerRadius[2], G4double EndOuterRadius[2], G4double DPhi, G4double EndPhi[2], G4double EndZ[2], G4int handedness) | |
virtual | ~G4TwistTubsFlatSide () |
virtual G4ThreeVector | GetNormal (const G4ThreeVector &, G4bool isGlobal=false) |
virtual G4int | DistanceToSurface (const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol) |
virtual G4int | DistanceToSurface (const G4ThreeVector &gp, G4ThreeVector gxx[], G4double distance[], G4int areacode[]) |
virtual G4ThreeVector | SurfacePoint (G4double, G4double, G4bool isGlobal=false) |
virtual G4double | GetBoundaryMin (G4double phi) |
virtual G4double | GetBoundaryMax (G4double phi) |
virtual G4double | GetSurfaceArea () |
virtual void | GetFacets (G4int m, G4int n, G4double xyz[][3], G4int faces[][4], G4int iside) |
G4TwistTubsFlatSide (__void__ &) | |
Data Fields | |
G4double | fSurfaceArea |
Protected Member Functions | |
virtual G4int | GetAreaCode (const G4ThreeVector &xx, G4bool withTol=true) |
Definition at line 52 of file G4TwistTubsFlatSide.hh.
G4TwistTubsFlatSide::G4TwistTubsFlatSide | ( | const G4String & | name, | |
const G4RotationMatrix & | rot, | |||
const G4ThreeVector & | tlate, | |||
const G4ThreeVector & | n, | |||
const EAxis | axis1 = kRho , |
|||
const EAxis | axis2 = kPhi , |
|||
G4double | axis0min = -kInfinity , |
|||
G4double | axis1min = -kInfinity , |
|||
G4double | axis0max = kInfinity , |
|||
G4double | axis1max = kInfinity | |||
) |
Definition at line 50 of file G4TwistTubsFlatSide.cc.
References FatalErrorInArgument, G4VTwistSurface::fCurrentNormal, G4VTwistSurface::fIsValidNorm, fSurfaceArea, G4Exception(), kPhi, and kRho.
00060 : G4VTwistSurface(name, rot, tlate, 0, axis0, axis1, 00061 axis0min, axis1min, axis0max, axis1max) 00062 { 00063 if (axis0 == kPhi && axis1 == kRho) { 00064 G4Exception("G4TwistTubsFlatSide::G4TwistTubsFlatSide()", 00065 "GeomSolids0002", FatalErrorInArgument, 00066 "Should swap axis0 and axis1!"); 00067 } 00068 00069 G4ThreeVector normal = rot.inverse()*n; 00070 fCurrentNormal.normal = normal.unit(); // in local coordinate system 00071 fIsValidNorm = true; 00072 00073 SetCorners(); 00074 SetBoundaries(); 00075 00076 fSurfaceArea = 1 ; // not yet implemented. This is NOT a problem for tracking 00077 00078 }
G4TwistTubsFlatSide::G4TwistTubsFlatSide | ( | const G4String & | name, | |
G4double | EndInnerRadius[2], | |||
G4double | EndOuterRadius[2], | |||
G4double | DPhi, | |||
G4double | EndPhi[2], | |||
G4double | EndZ[2], | |||
G4int | handedness | |||
) |
Definition at line 82 of file G4TwistTubsFlatSide.cc.
References G4VTwistSurface::fAxis, G4VTwistSurface::fAxisMax, G4VTwistSurface::fAxisMin, G4VTwistSurface::fCurrentNormal, G4VTwistSurface::fHandedness, G4VTwistSurface::fIsValidNorm, G4VTwistSurface::fRot, fSurfaceArea, G4VTwistSurface::fTrans, kPhi, and kRho.
00089 : G4VTwistSurface(name) 00090 { 00091 fHandedness = handedness; // +z = +ve, -z = -ve 00092 fAxis[0] = kRho; // in local coordinate system 00093 fAxis[1] = kPhi; 00094 G4int i = (handedness < 0 ? 0 : 1); 00095 fAxisMin[0] = EndInnerRadius[i]; // Inner-hype radius at z=0 00096 fAxisMax[0] = EndOuterRadius[i]; // Outer-hype radius at z=0 00097 fAxisMin[1] = -0.5*DPhi; 00098 fAxisMax[1] = -fAxisMin[1]; 00099 fCurrentNormal.normal.set(0, 0, (fHandedness < 0 ? -1 : 1)); 00100 // Unit vector, in local coordinate system 00101 fRot.rotateZ(EndPhi[i]); 00102 fTrans.set(0, 0, EndZ[i]); 00103 fIsValidNorm = true; 00104 00105 SetCorners(); 00106 SetBoundaries(); 00107 00108 fSurfaceArea = 0.5*DPhi * (EndOuterRadius[i]*EndOuterRadius[i] 00109 - EndInnerRadius[i]*EndInnerRadius[i] ) ; 00110 00111 }
G4TwistTubsFlatSide::~G4TwistTubsFlatSide | ( | ) | [virtual] |
G4TwistTubsFlatSide::G4TwistTubsFlatSide | ( | __void__ & | ) |
Definition at line 117 of file G4TwistTubsFlatSide.cc.
00118 : G4VTwistSurface(a), fSurfaceArea(0.) 00119 { 00120 }
G4int G4TwistTubsFlatSide::DistanceToSurface | ( | const G4ThreeVector & | gp, | |
G4ThreeVector | gxx[], | |||
G4double | distance[], | |||
G4int | areacode[] | |||
) | [virtual] |
Implements G4VTwistSurface.
Definition at line 255 of file G4TwistTubsFlatSide.cc.
References G4VTwistSurface::ComputeGlobalPoint(), G4VTwistSurface::ComputeLocalPoint(), G4VTwistSurface::fCurStat, G4VTwistSurface::kCarTolerance, G4VTwistSurface::kDontValidate, G4VTwistSurface::sInside, and G4VTwistSurface::sOutside.
00259 { 00260 // Calculate distance to plane in local coordinate, 00261 // then return distance and global intersection points. 00262 // 00263 00264 fCurStat.ResetfDone(kDontValidate, &gp); 00265 00266 if (fCurStat.IsDone()) { 00267 G4int i; 00268 for (i=0; i<fCurStat.GetNXX(); i++) { 00269 gxx[i] = fCurStat.GetXX(i); 00270 distance[i] = fCurStat.GetDistance(i); 00271 areacode[i] = fCurStat.GetAreacode(i); 00272 } 00273 return fCurStat.GetNXX(); 00274 } else { 00275 // initialize 00276 G4int i; 00277 for (i=0; i<2; i++) { 00278 distance[i] = kInfinity; 00279 areacode[i] = sOutside; 00280 gxx[i].set(kInfinity, kInfinity, kInfinity); 00281 } 00282 } 00283 00284 G4ThreeVector p = ComputeLocalPoint(gp); 00285 G4ThreeVector xx; 00286 00287 // The plane is placed on origin with making its normal 00288 // parallel to z-axis. 00289 if (std::fabs(p.z()) <= 0.5 * kCarTolerance) { // if p is on the plane, return 1 00290 distance[0] = 0; 00291 xx = p; 00292 } else { 00293 distance[0] = std::fabs(p.z()); 00294 xx.set(p.x(), p.y(), 0); 00295 } 00296 00297 gxx[0] = ComputeGlobalPoint(xx); 00298 areacode[0] = sInside; 00299 G4bool isvalid = true; 00300 fCurStat.SetCurrentStatus(0, gxx[0], distance[0], areacode[0], 00301 isvalid, 1, kDontValidate, &gp); 00302 return 1; 00303 00304 }
G4int G4TwistTubsFlatSide::DistanceToSurface | ( | const G4ThreeVector & | gp, | |
const G4ThreeVector & | gv, | |||
G4ThreeVector | gxx[], | |||
G4double | distance[], | |||
G4int | areacode[], | |||
G4bool | isvalid[], | |||
EValidate | validate = kValidateWithTol | |||
) | [virtual] |
Definition at line 146 of file G4TwistTubsFlatSide.cc.
References G4VTwistSurface::ComputeGlobalPoint(), G4VTwistSurface::ComputeLocalDirection(), G4VTwistSurface::ComputeLocalPoint(), G4VTwistSurface::fCurStatWithV, G4cerr, G4endl, GetAreaCode(), G4VTwistSurface::GetName(), G4VTwistSurface::IsInside(), G4VTwistSurface::IsOutside(), G4VTwistSurface::kValidateWithoutTol, G4VTwistSurface::kValidateWithTol, G4VTwistSurface::sInside, and G4VTwistSurface::sOutside.
00153 { 00154 fCurStatWithV.ResetfDone(validate, &gp, &gv); 00155 00156 if (fCurStatWithV.IsDone()) { 00157 G4int i; 00158 for (i=0; i<fCurStatWithV.GetNXX(); i++) { 00159 gxx[i] = fCurStatWithV.GetXX(i); 00160 distance[i] = fCurStatWithV.GetDistance(i); 00161 areacode[i] = fCurStatWithV.GetAreacode(i); 00162 isvalid[i] = fCurStatWithV.IsValid(i); 00163 } 00164 return fCurStatWithV.GetNXX(); 00165 } else { 00166 // initialize 00167 G4int i; 00168 for (i=0; i<2; i++) { 00169 distance[i] = kInfinity; 00170 areacode[i] = sOutside; 00171 isvalid[i] = false; 00172 gxx[i].set(kInfinity, kInfinity, kInfinity); 00173 } 00174 } 00175 00176 G4ThreeVector p = ComputeLocalPoint(gp); 00177 G4ThreeVector v = ComputeLocalDirection(gv); 00178 00179 // 00180 // special case! 00181 // if p is on surface, distance = 0. 00182 // 00183 00184 if (std::fabs(p.z()) == 0.) { // if p is on the plane 00185 distance[0] = 0; 00186 G4ThreeVector xx = p; 00187 gxx[0] = ComputeGlobalPoint(xx); 00188 00189 if (validate == kValidateWithTol) { 00190 areacode[0] = GetAreaCode(xx); 00191 if (!IsOutside(areacode[0])) { 00192 isvalid[0] = true; 00193 } 00194 } else if (validate == kValidateWithoutTol) { 00195 areacode[0] = GetAreaCode(xx, false); 00196 if (IsInside(areacode[0])) { 00197 isvalid[0] = true; 00198 } 00199 } else { // kDontValidate 00200 areacode[0] = sInside; 00201 isvalid[0] = true; 00202 } 00203 00204 return 1; 00205 } 00206 // 00207 // special case end 00208 // 00209 00210 if (v.z() == 0) { 00211 00212 fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0], 00213 isvalid[0], 0, validate, &gp, &gv); 00214 return 0; 00215 } 00216 00217 distance[0] = - (p.z() / v.z()); 00218 00219 G4ThreeVector xx = p + distance[0]*v; 00220 gxx[0] = ComputeGlobalPoint(xx); 00221 00222 if (validate == kValidateWithTol) { 00223 areacode[0] = GetAreaCode(xx); 00224 if (!IsOutside(areacode[0])) { 00225 if (distance[0] >= 0) isvalid[0] = true; 00226 } 00227 } else if (validate == kValidateWithoutTol) { 00228 areacode[0] = GetAreaCode(xx, false); 00229 if (IsInside(areacode[0])) { 00230 if (distance[0] >= 0) isvalid[0] = true; 00231 } 00232 } else { // kDontValidate 00233 areacode[0] = sInside; 00234 if (distance[0] >= 0) isvalid[0] = true; 00235 } 00236 00237 fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0], 00238 isvalid[0], 1, validate, &gp, &gv); 00239 00240 #ifdef G4TWISTDEBUG 00241 G4cerr << "ERROR - G4TwistTubsFlatSide::DistanceToSurface(p,v)" << G4endl; 00242 G4cerr << " Name : " << GetName() << G4endl; 00243 G4cerr << " xx : " << xx << G4endl; 00244 G4cerr << " gxx[0] : " << gxx[0] << G4endl; 00245 G4cerr << " dist[0] : " << distance[0] << G4endl; 00246 G4cerr << " areacode[0] : " << areacode[0] << G4endl; 00247 G4cerr << " isvalid[0] : " << isvalid[0] << G4endl; 00248 #endif 00249 return 1; 00250 }
G4int G4TwistTubsFlatSide::GetAreaCode | ( | const G4ThreeVector & | xx, | |
G4bool | withTol = true | |||
) | [protected, virtual] |
Implements G4VTwistSurface.
Definition at line 309 of file G4TwistTubsFlatSide.cc.
References G4VTwistSurface::AmIOnLeftSide(), FatalException, G4VTwistSurface::fAxis, G4VTwistSurface::fAxisMax, G4VTwistSurface::fAxisMin, G4endl, G4Exception(), G4VTwistSurface::GetCorner(), G4GeometryTolerance::GetInstance(), G4GeometryTolerance::GetRadialTolerance(), kPhi, kRho, G4VTwistSurface::sAxis0, G4VTwistSurface::sAxis1, G4VTwistSurface::sAxisMax, G4VTwistSurface::sAxisMin, G4VTwistSurface::sAxisPhi, G4VTwistSurface::sAxisRho, G4VTwistSurface::sBoundary, G4VTwistSurface::sC0Max1Max, G4VTwistSurface::sC0Max1Min, G4VTwistSurface::sCorner, and G4VTwistSurface::sInside.
Referenced by DistanceToSurface().
00311 { 00312 00313 static const G4double rtol 00314 = 0.5*G4GeometryTolerance::GetInstance()->GetRadialTolerance(); 00315 00316 G4int areacode = sInside; 00317 00318 if (fAxis[0] == kRho && fAxis[1] == kPhi) { 00319 G4int rhoaxis = 0; 00320 // G4int phiaxis = 0; 00321 00322 G4ThreeVector dphimin; // direction of phi-minimum boundary 00323 G4ThreeVector dphimax; // direction of phi-maximum boundary 00324 dphimin = GetCorner(sC0Max1Min); 00325 dphimax = GetCorner(sC0Max1Max); 00326 00327 if (withTol) { 00328 00329 G4bool isoutside = false; 00330 00331 // test boundary of rho-axis 00332 00333 if (xx.getRho() <= fAxisMin[rhoaxis] + rtol) { 00334 00335 areacode |= (sAxis0 & (sAxisRho | sAxisMin)) | sBoundary; // rho-min 00336 if (xx.getRho() < fAxisMin[rhoaxis] - rtol) isoutside = true; 00337 00338 } else if (xx.getRho() >= fAxisMax[rhoaxis] - rtol) { 00339 00340 areacode |= (sAxis0 & (sAxisRho | sAxisMax)) | sBoundary; // rho-max 00341 if (xx.getRho() > fAxisMax[rhoaxis] + rtol) isoutside = true; 00342 00343 } 00344 00345 // test boundary of phi-axis 00346 00347 if (AmIOnLeftSide(xx, dphimin) >= 0) { // xx is on dphimin 00348 00349 areacode |= (sAxis1 & (sAxisPhi | sAxisMin)); 00350 if (areacode & sBoundary) areacode |= sCorner; // xx is on the corner. 00351 else areacode |= sBoundary; 00352 00353 if (AmIOnLeftSide(xx, dphimin) > 0) isoutside = true; 00354 00355 } else if (AmIOnLeftSide(xx, dphimax) <= 0) { // xx is on dphimax 00356 00357 areacode |= (sAxis1 & (sAxisPhi | sAxisMax)); 00358 if (areacode & sBoundary) areacode |= sCorner; // xx is on the corner. 00359 else areacode |= sBoundary; 00360 00361 if (AmIOnLeftSide(xx, dphimax) < 0) isoutside = true; 00362 00363 } 00364 00365 // if isoutside = true, clear inside bit. 00366 // if not on boundary, add axis information. 00367 00368 if (isoutside) { 00369 G4int tmpareacode = areacode & (~sInside); 00370 areacode = tmpareacode; 00371 } else if ((areacode & sBoundary) != sBoundary) { 00372 areacode |= (sAxis0 & sAxisRho) | (sAxis1 & sAxisPhi); 00373 } 00374 00375 } else { 00376 00377 // out of boundary of rho-axis 00378 00379 if (xx.getRho() < fAxisMin[rhoaxis]) { 00380 areacode |= (sAxis0 & (sAxisRho | sAxisMin)) | sBoundary; 00381 } else if (xx.getRho() > fAxisMax[rhoaxis]) { 00382 areacode |= (sAxis0 & (sAxisRho | sAxisMax)) | sBoundary; 00383 } 00384 00385 // out of boundary of phi-axis 00386 00387 if (AmIOnLeftSide(xx, dphimin, false) >= 0) { // xx is leftside or 00388 areacode |= (sAxis1 & (sAxisPhi | sAxisMin)) ; // boundary of dphimin 00389 if (areacode & sBoundary) areacode |= sCorner; // xx is on the corner. 00390 else areacode |= sBoundary; 00391 00392 } else if (AmIOnLeftSide(xx, dphimax, false) <= 0) { // xx is rightside or 00393 areacode |= (sAxis1 & (sAxisPhi | sAxisMax)) ; // boundary of dphimax 00394 if (areacode & sBoundary) areacode |= sCorner; // xx is on the corner. 00395 else areacode |= sBoundary; 00396 00397 } 00398 00399 if ((areacode & sBoundary) != sBoundary) { 00400 areacode |= (sAxis0 & sAxisRho) | (sAxis1 & sAxisPhi); 00401 } 00402 00403 } 00404 return areacode; 00405 } else { 00406 00407 std::ostringstream message; 00408 message << "Feature NOT implemented !" << G4endl 00409 << " fAxis[0] = " << fAxis[0] << G4endl 00410 << " fAxis[1] = " << fAxis[1]; 00411 G4Exception("G4TwistTubsFlatSide::GetAreaCode()", "GeomSolids0001", 00412 FatalException, message); 00413 } 00414 return areacode; 00415 }
Implements G4VTwistSurface.
Definition at line 137 of file G4TwistTubsFlatSide.hh.
References G4VTwistSurface::GetCorner(), and G4VTwistSurface::sC0Max1Max.
Referenced by GetFacets().
00138 { 00139 G4ThreeVector dphimax = GetCorner(sC0Max1Max); 00140 return std::atan2( dphimax.y(), dphimax.x() ); 00141 }
Implements G4VTwistSurface.
Definition at line 130 of file G4TwistTubsFlatSide.hh.
References G4VTwistSurface::GetCorner(), and G4VTwistSurface::sC0Max1Min.
Referenced by GetFacets().
00131 { 00132 G4ThreeVector dphimin = GetCorner(sC0Max1Min); 00133 return std::atan2( dphimin.y(), dphimin.x() ); 00134 }
void G4TwistTubsFlatSide::GetFacets | ( | G4int | m, | |
G4int | n, | |||
G4double | xyz[][3], | |||
G4int | faces[][4], | |||
G4int | iside | |||
) | [virtual] |
Implements G4VTwistSurface.
Definition at line 509 of file G4TwistTubsFlatSide.cc.
References G4VTwistSurface::fAxisMax, G4VTwistSurface::fAxisMin, G4VTwistSurface::fHandedness, GetBoundaryMax(), GetBoundaryMin(), G4VTwistSurface::GetEdgeVisibility(), G4VTwistSurface::GetFace(), G4VTwistSurface::GetNode(), and SurfacePoint().
00511 { 00512 00513 G4ThreeVector p ; 00514 00515 G4double rmin = fAxisMin[0] ; 00516 G4double rmax = fAxisMax[0] ; 00517 G4double phimin, phimax ; 00518 00519 G4double r,phi ; 00520 00521 G4int i,j ; 00522 00523 G4int nnode,nface ; 00524 00525 for ( i = 0 ; i<n ; i++ ) { 00526 00527 r = rmin + i*(rmax-rmin)/(n-1) ; 00528 00529 phimin = GetBoundaryMin(r) ; 00530 phimax = GetBoundaryMax(r) ; 00531 00532 for ( j = 0 ; j<k ; j++ ) 00533 { 00534 phi = phimin + j*(phimax-phimin)/(k-1) ; 00535 00536 nnode = GetNode(i,j,k,n,iside) ; 00537 p = SurfacePoint(phi,r,true) ; // surface point in global coord.system 00538 00539 xyz[nnode][0] = p.x() ; 00540 xyz[nnode][1] = p.y() ; 00541 xyz[nnode][2] = p.z() ; 00542 00543 if ( i<n-1 && j<k-1 ) { // conterclock wise filling 00544 00545 nface = GetFace(i,j,k,n,iside) ; 00546 00547 if (fHandedness < 0) { // lower side 00548 faces[nface][0] = GetEdgeVisibility(i,j,k,n,0,-1) * ( GetNode(i ,j ,k,n,iside)+1) ; 00549 faces[nface][1] = GetEdgeVisibility(i,j,k,n,1,-1) * ( GetNode(i ,j+1,k,n,iside)+1) ; 00550 faces[nface][2] = GetEdgeVisibility(i,j,k,n,2,-1) * ( GetNode(i+1,j+1,k,n,iside)+1) ; 00551 faces[nface][3] = GetEdgeVisibility(i,j,k,n,3,-1) * ( GetNode(i+1,j ,k,n,iside)+1) ; 00552 } else { // upper side 00553 faces[nface][0] = GetEdgeVisibility(i,j,k,n,0,1) * ( GetNode(i ,j ,k,n,iside)+1) ; 00554 faces[nface][1] = GetEdgeVisibility(i,j,k,n,1,1) * ( GetNode(i+1,j ,k,n,iside)+1) ; 00555 faces[nface][2] = GetEdgeVisibility(i,j,k,n,2,1) * ( GetNode(i+1,j+1,k,n,iside)+1) ; 00556 faces[nface][3] = GetEdgeVisibility(i,j,k,n,3,1) * ( GetNode(i ,j+1,k,n,iside)+1) ; 00557 00558 } 00559 00560 00561 00562 } 00563 } 00564 } 00565 }
G4ThreeVector G4TwistTubsFlatSide::GetNormal | ( | const G4ThreeVector & | , | |
G4bool | isGlobal = false | |||
) | [virtual] |
Implements G4VTwistSurface.
Definition at line 133 of file G4TwistTubsFlatSide.cc.
References G4VTwistSurface::ComputeGlobalDirection(), and G4VTwistSurface::fCurrentNormal.
00135 { 00136 if (isGlobal) { 00137 return ComputeGlobalDirection(fCurrentNormal.normal); 00138 } else { 00139 return fCurrentNormal.normal; 00140 } 00141 }
virtual G4double G4TwistTubsFlatSide::GetSurfaceArea | ( | ) | [inline, virtual] |
Implements G4VTwistSurface.
Definition at line 95 of file G4TwistTubsFlatSide.hh.
References fSurfaceArea.
00095 { return fSurfaceArea ; }
G4ThreeVector G4TwistTubsFlatSide::SurfacePoint | ( | G4double | , | |
G4double | , | |||
G4bool | isGlobal = false | |||
) | [inline, virtual] |
Implements G4VTwistSurface.
Definition at line 121 of file G4TwistTubsFlatSide.hh.
References G4VTwistSurface::fRot, and G4VTwistSurface::fTrans.
Referenced by GetFacets().
00122 { 00123 G4ThreeVector SurfPoint (rho*std::cos(phi) , rho*std::sin(phi) , 0); 00124 00125 if (isGlobal) { return (fRot * SurfPoint + fTrans); } 00126 return SurfPoint; 00127 }
Definition at line 99 of file G4TwistTubsFlatSide.hh.
Referenced by G4TwistTubsFlatSide(), and GetSurfaceArea().