#include <G4IntersectionSolid.hh>
Inheritance diagram for G4IntersectionSolid:
Definition at line 53 of file G4IntersectionSolid.hh.
G4IntersectionSolid::G4IntersectionSolid | ( | const G4String & | pName, | |
G4VSolid * | pSolidA, | |||
G4VSolid * | pSolidB | |||
) |
Definition at line 63 of file G4IntersectionSolid.cc.
Referenced by Clone().
00066 : G4BooleanSolid(pName,pSolidA,pSolidB) 00067 { 00068 }
G4IntersectionSolid::G4IntersectionSolid | ( | const G4String & | pName, | |
G4VSolid * | pSolidA, | |||
G4VSolid * | pSolidB, | |||
G4RotationMatrix * | rotMatrix, | |||
const G4ThreeVector & | transVector | |||
) |
Definition at line 73 of file G4IntersectionSolid.cc.
00078 : G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector) 00079 { 00080 }
G4IntersectionSolid::G4IntersectionSolid | ( | const G4String & | pName, | |
G4VSolid * | pSolidA, | |||
G4VSolid * | pSolidB, | |||
const G4Transform3D & | transform | |||
) |
Definition at line 86 of file G4IntersectionSolid.cc.
00090 : G4BooleanSolid(pName,pSolidA,pSolidB,transform) 00091 { 00092 }
G4IntersectionSolid::~G4IntersectionSolid | ( | ) | [virtual] |
G4IntersectionSolid::G4IntersectionSolid | ( | __void__ & | ) |
G4IntersectionSolid::G4IntersectionSolid | ( | const G4IntersectionSolid & | rhs | ) |
G4bool G4IntersectionSolid::CalculateExtent | ( | const EAxis | pAxis, | |
const G4VoxelLimits & | pVoxelLimit, | |||
const G4AffineTransform & | pTransform, | |||
G4double & | pMin, | |||
G4double & | pMax | |||
) | const [virtual] |
Implements G4VSolid.
Definition at line 144 of file G4IntersectionSolid.cc.
References G4VSolid::CalculateExtent(), G4BooleanSolid::fPtrSolidA, and G4BooleanSolid::fPtrSolidB.
00149 { 00150 G4bool retA, retB, out; 00151 G4double minA, minB, maxA, maxB; 00152 00153 retA = fPtrSolidA 00154 ->CalculateExtent( pAxis, pVoxelLimit, pTransform, minA, maxA); 00155 retB = fPtrSolidB 00156 ->CalculateExtent( pAxis, pVoxelLimit, pTransform, minB, maxB); 00157 00158 if( retA && retB ) 00159 { 00160 pMin = std::max( minA, minB ); 00161 pMax = std::min( maxA, maxB ); 00162 out = (pMax > pMin); // true; 00163 #ifdef G4BOOLDEBUG 00164 // G4cout.precision(16); 00165 // G4cout<<"pMin = "<<pMin<<"; pMax = "<<pMax<<G4endl; 00166 #endif 00167 } 00168 else out = false; 00169 00170 return out; // It exists in this slice only if both exist in it. 00171 }
G4VSolid * G4IntersectionSolid::Clone | ( | ) | const [virtual] |
Reimplemented from G4VSolid.
Reimplemented in G4BREPSolidOpenPCone.
Definition at line 520 of file G4IntersectionSolid.cc.
References G4IntersectionSolid().
00521 { 00522 return new G4IntersectionSolid(*this); 00523 }
void G4IntersectionSolid::ComputeDimensions | ( | G4VPVParameterisation * | p, | |
const G4int | n, | |||
const G4VPhysicalVolume * | pRep | |||
) | [virtual] |
G4NURBS * G4IntersectionSolid::CreateNURBS | ( | ) | const [virtual] |
Reimplemented from G4VSolid.
Definition at line 556 of file G4IntersectionSolid.cc.
00557 { 00558 // Take into account boolean operation - see CreatePolyhedron. 00559 // return new G4NURBSbox (1.0, 1.0, 1.0); 00560 return 0; 00561 }
G4Polyhedron * G4IntersectionSolid::CreatePolyhedron | ( | ) | const [virtual] |
Reimplemented from G4VSolid.
Definition at line 540 of file G4IntersectionSolid.cc.
References processor, and G4BooleanSolid::StackPolyhedron().
00541 { 00542 HepPolyhedronProcessor processor; 00543 // Stack components and components of components recursively 00544 // See G4BooleanSolid::StackPolyhedron 00545 G4Polyhedron* top = StackPolyhedron(processor, this); 00546 G4Polyhedron* result = new G4Polyhedron(*top); 00547 if (processor.execute(*result)) { return result; } 00548 else { return 0; } 00549 }
void G4IntersectionSolid::DescribeYourselfTo | ( | G4VGraphicsScene & | scene | ) | const [virtual] |
Implements G4VSolid.
Reimplemented in G4BREPSolidOpenPCone.
Definition at line 530 of file G4IntersectionSolid.cc.
References G4VGraphicsScene::AddSolid().
00531 { 00532 scene.AddSolid (*this); 00533 }
G4double G4IntersectionSolid::DistanceToIn | ( | const G4ThreeVector & | p | ) | const [virtual] |
Implements G4VSolid.
Definition at line 373 of file G4IntersectionSolid.cc.
References G4VSolid::DistanceToIn(), G4BooleanSolid::fPtrSolidA, G4BooleanSolid::fPtrSolidB, G4cerr, G4cout, G4endl, G4VSolid::Inside(), Inside(), kInside, and kOutside.
00374 { 00375 #ifdef G4BOOLDEBUG 00376 if( Inside(p) == kInside ) 00377 { 00378 G4cout << "WARNING - Invalid call in " 00379 << "G4IntersectionSolid::DistanceToIn(p)" << G4endl 00380 << " Point p is inside !" << G4endl; 00381 G4cout << " p = " << p << G4endl; 00382 G4cerr << "WARNING - Invalid call in " 00383 << "G4IntersectionSolid::DistanceToIn(p)" << G4endl 00384 << " Point p is inside !" << G4endl; 00385 G4cerr << " p = " << p << G4endl; 00386 } 00387 #endif 00388 EInside sideA = fPtrSolidA->Inside(p) ; 00389 EInside sideB = fPtrSolidB->Inside(p) ; 00390 G4double dist=0.0 ; 00391 00392 if( sideA != kInside && sideB != kOutside ) 00393 { 00394 dist = fPtrSolidA->DistanceToIn(p) ; 00395 } 00396 else 00397 { 00398 if( sideB != kInside && sideA != kOutside ) 00399 { 00400 dist = fPtrSolidB->DistanceToIn(p) ; 00401 } 00402 else 00403 { 00404 dist = std::min(fPtrSolidA->DistanceToIn(p), 00405 fPtrSolidB->DistanceToIn(p) ) ; 00406 } 00407 } 00408 return dist ; 00409 }
G4double G4IntersectionSolid::DistanceToIn | ( | const G4ThreeVector & | p, | |
const G4ThreeVector & | v | |||
) | const [virtual] |
Implements G4VSolid.
Definition at line 272 of file G4IntersectionSolid.cc.
References G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), G4BooleanSolid::fPtrSolidA, G4BooleanSolid::fPtrSolidB, G4cerr, G4cout, G4endl, G4VSolid::Inside(), Inside(), kInside, and kSurface.
00274 { 00275 G4double dist = 0.0; 00276 if( Inside(p) == kInside ) 00277 { 00278 #ifdef G4BOOLDEBUG 00279 G4cout << "WARNING - Invalid call in " 00280 << "G4IntersectionSolid::DistanceToIn(p,v)" << G4endl 00281 << " Point p is inside !" << G4endl; 00282 G4cout << " p = " << p << G4endl; 00283 G4cout << " v = " << v << G4endl; 00284 G4cerr << "WARNING - Invalid call in " 00285 << "G4IntersectionSolid::DistanceToIn(p,v)" << G4endl 00286 << " Point p is inside !" << G4endl; 00287 G4cerr << " p = " << p << G4endl; 00288 G4cerr << " v = " << v << G4endl; 00289 #endif 00290 } 00291 else // if( Inside(p) == kSurface ) 00292 { 00293 EInside wA = fPtrSolidA->Inside(p); 00294 EInside wB = fPtrSolidB->Inside(p); 00295 00296 G4ThreeVector pA = p, pB = p; 00297 G4double dA = 0., dA1=0., dA2=0.; 00298 G4double dB = 0., dB1=0., dB2=0.; 00299 G4bool doA = true, doB = true; 00300 00301 while(true) 00302 { 00303 if(doA) 00304 { 00305 // find next valid range for A 00306 00307 dA1 = 0.; 00308 00309 if( wA != kInside ) 00310 { 00311 dA1 = fPtrSolidA->DistanceToIn(pA, v); 00312 00313 if( dA1 == kInfinity ) return kInfinity; 00314 00315 pA += dA1*v; 00316 } 00317 dA2 = dA1 + fPtrSolidA->DistanceToOut(pA, v); 00318 } 00319 dA1 += dA; 00320 dA2 += dA; 00321 00322 if(doB) 00323 { 00324 // find next valid range for B 00325 00326 dB1 = 0.; 00327 if(wB != kInside) 00328 { 00329 dB1 = fPtrSolidB->DistanceToIn(pB, v); 00330 00331 if(dB1 == kInfinity) return kInfinity; 00332 00333 pB += dB1*v; 00334 } 00335 dB2 = dB1 + fPtrSolidB->DistanceToOut(pB, v); 00336 } 00337 dB1 += dB; 00338 dB2 += dB; 00339 00340 // check if they overlap 00341 00342 if( dA1 < dB1 ) 00343 { 00344 if( dB1 < dA2 ) return dB1; 00345 00346 dA = dA2; 00347 pA = p + dA*v; // continue from here 00348 wA = kSurface; 00349 doA = true; 00350 doB = false; 00351 } 00352 else 00353 { 00354 if( dA1 < dB2 ) return dA1; 00355 00356 dB = dB2; 00357 pB = p + dB*v; // continue from here 00358 wB = kSurface; 00359 doB = true; 00360 doA = false; 00361 } 00362 } 00363 } 00364 return dist ; 00365 }
G4double G4IntersectionSolid::DistanceToOut | ( | const G4ThreeVector & | p | ) | const [virtual] |
Implements G4VSolid.
Definition at line 475 of file G4IntersectionSolid.cc.
References G4VSolid::DistanceToOut(), G4BooleanSolid::fPtrSolidA, G4BooleanSolid::fPtrSolidB, G4cerr, G4cout, G4endl, Inside(), and kOutside.
00476 { 00477 #ifdef G4BOOLDEBUG 00478 if( Inside(p) == kOutside ) 00479 { 00480 G4cout << "WARNING - Invalid call in " 00481 << "G4IntersectionSolid::DistanceToOut(p)" << G4endl 00482 << " Point p is outside !" << G4endl; 00483 G4cout << " p = " << p << G4endl; 00484 G4cerr << "WARNING - Invalid call in " 00485 << "G4IntersectionSolid::DistanceToOut(p)" << G4endl 00486 << " Point p is outside !" << G4endl; 00487 G4cerr << " p = " << p << G4endl; 00488 } 00489 #endif 00490 00491 return std::min(fPtrSolidA->DistanceToOut(p), 00492 fPtrSolidB->DistanceToOut(p) ) ; 00493 00494 }
G4double G4IntersectionSolid::DistanceToOut | ( | const G4ThreeVector & | p, | |
const G4ThreeVector & | v, | |||
const G4bool | calcNorm = false , |
|||
G4bool * | validNorm = 0 , |
|||
G4ThreeVector * | n = 0 | |||
) | const [virtual] |
Implements G4VSolid.
Definition at line 416 of file G4IntersectionSolid.cc.
References G4VSolid::DistanceToOut(), G4BooleanSolid::fPtrSolidA, G4BooleanSolid::fPtrSolidB, G4cerr, G4cout, G4endl, Inside(), and kOutside.
00421 { 00422 G4bool validNormA, validNormB; 00423 G4ThreeVector nA, nB; 00424 00425 #ifdef G4BOOLDEBUG 00426 if( Inside(p) == kOutside ) 00427 { 00428 G4cout << "Position:" << G4endl << G4endl; 00429 G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl; 00430 G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl; 00431 G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl; 00432 G4cout << "Direction:" << G4endl << G4endl; 00433 G4cout << "v.x() = " << v.x() << G4endl; 00434 G4cout << "v.y() = " << v.y() << G4endl; 00435 G4cout << "v.z() = " << v.z() << G4endl << G4endl; 00436 G4cout << "WARNING - Invalid call in " 00437 << "G4IntersectionSolid::DistanceToOut(p,v)" << G4endl 00438 << " Point p is outside !" << G4endl; 00439 G4cout << " p = " << p << G4endl; 00440 G4cout << " v = " << v << G4endl; 00441 G4cerr << "WARNING - Invalid call in " 00442 << "G4IntersectionSolid::DistanceToOut(p,v)" << G4endl 00443 << " Point p is outside !" << G4endl; 00444 G4cerr << " p = " << p << G4endl; 00445 G4cerr << " v = " << v << G4endl; 00446 } 00447 #endif 00448 G4double distA = fPtrSolidA->DistanceToOut(p,v,calcNorm,&validNormA,&nA) ; 00449 G4double distB = fPtrSolidB->DistanceToOut(p,v,calcNorm,&validNormB,&nB) ; 00450 00451 G4double dist = std::min(distA,distB) ; 00452 00453 if( calcNorm ) 00454 { 00455 if ( distA < distB ) 00456 { 00457 *validNorm = validNormA; 00458 *n = nA; 00459 } 00460 else 00461 { 00462 *validNorm = validNormB; 00463 *n = nB; 00464 } 00465 } 00466 00467 return dist ; 00468 }
G4GeometryType G4IntersectionSolid::GetEntityType | ( | ) | const [virtual] |
Reimplemented from G4BooleanSolid.
Definition at line 511 of file G4IntersectionSolid.cc.
00512 { 00513 return G4String("G4IntersectionSolid"); 00514 }
EInside G4IntersectionSolid::Inside | ( | const G4ThreeVector & | p | ) | const [virtual] |
Implements G4VSolid.
Definition at line 177 of file G4IntersectionSolid.cc.
References G4BooleanSolid::fPtrSolidA, G4BooleanSolid::fPtrSolidB, G4VSolid::Inside(), kInside, kOutside, and kSurface.
Referenced by DistanceToIn(), and DistanceToOut().
00178 { 00179 EInside positionA = fPtrSolidA->Inside(p) ; 00180 00181 if( positionA == kOutside ) return kOutside ; 00182 00183 EInside positionB = fPtrSolidB->Inside(p) ; 00184 00185 if(positionA == kInside && positionB == kInside) 00186 { 00187 return kInside ; 00188 } 00189 else 00190 { 00191 if((positionA == kInside && positionB == kSurface) || 00192 (positionB == kInside && positionA == kSurface) || 00193 (positionA == kSurface && positionB == kSurface) ) 00194 { 00195 return kSurface ; 00196 } 00197 else 00198 { 00199 return kOutside ; 00200 } 00201 } 00202 }
G4IntersectionSolid & G4IntersectionSolid::operator= | ( | const G4IntersectionSolid & | rhs | ) |
Definition at line 126 of file G4IntersectionSolid.cc.
References G4BooleanSolid::operator=().
Referenced by G4BREPSolidOpenPCone::operator=().
00127 { 00128 // Check assignment to self 00129 // 00130 if (this == &rhs) { return *this; } 00131 00132 // Copy base class data 00133 // 00134 G4BooleanSolid::operator=(rhs); 00135 00136 return *this; 00137 }
G4ThreeVector G4IntersectionSolid::SurfaceNormal | ( | const G4ThreeVector & | p | ) | const [virtual] |
Implements G4VSolid.
Definition at line 208 of file G4IntersectionSolid.cc.
References G4VSolid::DistanceToOut(), G4BooleanSolid::fPtrSolidA, G4BooleanSolid::fPtrSolidB, G4cerr, G4cout, G4endl, G4VSolid::Inside(), kOutside, kSurface, and G4VSolid::SurfaceNormal().
00209 { 00210 G4ThreeVector normal; 00211 EInside insideA, insideB; 00212 00213 insideA= fPtrSolidA->Inside(p); 00214 insideB= fPtrSolidB->Inside(p); 00215 00216 #ifdef G4BOOLDEBUG 00217 if( (insideA == kOutside) || (insideB == kOutside) ) 00218 { 00219 G4cout << "WARNING - Invalid call in " 00220 << "G4IntersectionSolid::SurfaceNormal(p)" << G4endl 00221 << " Point p is outside !" << G4endl; 00222 G4cout << " p = " << p << G4endl; 00223 G4cerr << "WARNING - Invalid call in " 00224 << "G4IntersectionSolid::SurfaceNormal(p)" << G4endl 00225 << " Point p is outside !" << G4endl; 00226 G4cerr << " p = " << p << G4endl; 00227 } 00228 #endif 00229 00230 // OLD: if(fPtrSolidA->DistanceToOut(p) <= fPtrSolidB->DistanceToOut(p) ) 00231 00232 // On the surface of both is difficult ... treat it like on A now! 00233 // 00234 // if( (insideA == kSurface) && (insideB == kSurface) ) 00235 // normal= fPtrSolidA->SurfaceNormal(p) ; 00236 // else 00237 if( insideA == kSurface ) 00238 { 00239 normal= fPtrSolidA->SurfaceNormal(p) ; 00240 } 00241 else if( insideB == kSurface ) 00242 { 00243 normal= fPtrSolidB->SurfaceNormal(p) ; 00244 } 00245 // We are on neither surface, so we should generate an exception 00246 else 00247 { 00248 if(fPtrSolidA->DistanceToOut(p) <= fPtrSolidB->DistanceToOut(p) ) 00249 normal= fPtrSolidA->SurfaceNormal(p) ; 00250 else 00251 normal= fPtrSolidB->SurfaceNormal(p) ; 00252 #ifdef G4BOOLDEBUG 00253 G4cout << "WARNING - Invalid call in " 00254 << "G4IntersectionSolid::SurfaceNormal(p)" << G4endl 00255 << " Point p is out of surface !" << G4endl; 00256 G4cout << " p = " << p << G4endl; 00257 G4cerr << "WARNING - Invalid call in " 00258 << "G4IntersectionSolid::SurfaceNormal(p)" << G4endl 00259 << " Point p is out of surface !" << G4endl; 00260 G4cerr << " p = " << p << G4endl; 00261 #endif 00262 } 00263 00264 return normal; 00265 }