Check if any point on shape is inside cubeBb.
| 434 | |
| 435 | // Check if any point on shape is inside cubeBb. |
| 436 | bool Foam::treeDataFace::overlaps |
| 437 | ( |
| 438 | const label index, |
| 439 | const treeBoundBox& cubeBb |
| 440 | ) const |
| 441 | { |
| 442 | // 1. Quick rejection: bb does not intersect face bb at all |
| 443 | if (cacheBb_) |
| 444 | { |
| 445 | if (!cubeBb.overlaps(bbs_[index])) |
| 446 | { |
| 447 | return false; |
| 448 | } |
| 449 | } |
| 450 | else |
| 451 | { |
| 452 | if (!cubeBb.overlaps(calcBb(faceLabels_[index]))) |
| 453 | { |
| 454 | return false; |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | const pointField& points = mesh_.points(); |
| 459 | |
| 460 | |
| 461 | // 2. Check if one or more face points inside |
| 462 | label facei = faceLabels_[index]; |
| 463 | |
| 464 | const face& f = mesh_.faces()[facei]; |
| 465 | if (cubeBb.containsAny(points, f)) |
| 466 | { |
| 467 | return true; |
| 468 | } |
| 469 | |
| 470 | // 3. Difficult case: all points are outside but connecting edges might |
| 471 | // go through cube. Use triangle-bounding box intersection. |
| 472 | const point& fc = mesh_.faceCentres()[facei]; |
| 473 | |
| 474 | forAll(f, fp) |
| 475 | { |
| 476 | bool triIntersects = triangleFuncs::intersectBb |
| 477 | ( |
| 478 | points[f[fp]], |
| 479 | points[f[f.fcIndex(fp)]], |
| 480 | fc, |
| 481 | cubeBb |
| 482 | ); |
| 483 | |
| 484 | if (triIntersects) |
| 485 | { |
| 486 | return true; |
| 487 | } |
| 488 | } |
| 489 | return false; |
| 490 | } |
| 491 | |
| 492 | |
| 493 | void Foam::treeDataFace::findNearestOp::operator() |