MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / overlaps

Function overlaps

src/meshTools/indexedOctree/treeDataFace.C:436–490  ·  view source on GitHub ↗

Check if any point on shape is inside cubeBb.

Source from the content-addressed store, hash-verified

434
435// Check if any point on shape is inside cubeBb.
436bool 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
493void Foam::treeDataFace::findNearestOp::operator()

Callers

nothing calls this directly

Calls 6

triangleFuncsClass · 0.85
forAllFunction · 0.50
overlapsMethod · 0.45
pointsMethod · 0.45
facesMethod · 0.45
fcIndexMethod · 0.45

Tested by

no test coverage detected