78 point& intersectionPoint
88 const label newFacei =
tree_.shapes().faceLabels()[index];
89 const face& newFace =
mesh.faces()[newFacei];
90 const scalar newDot =
mesh.faceAreas()[newFacei] & (
end -
start);
94 const face& oldFace =
mesh.faces()[oldFacei];
100 hits_[hiti].index() == newFacei
112 treeDataFace::findIntersectOp::operator()
128 bool Foam::meshSearch::findNearer
133 scalar& nearestDistSqr
142 if (distSqr < nearestDistSqr)
144 nearestDistSqr = distSqr;
154 bool Foam::meshSearch::findNearer
160 scalar& nearestDistSqr
167 label pointi = indices[i];
171 if (distSqr < nearestDistSqr)
173 nearestDistSqr = distSqr;
184 Foam::label Foam::meshSearch::findNearestCellTree(
const point& location)
const
186 const indexedOctree<treeDataCell>& tree = cellTree();
191 magSqr(tree.bb().max()-tree.bb().min())
196 info = tree.findNearest(location,
Foam::sqr(GREAT));
202 Foam::label Foam::meshSearch::findNearestCellLinear(
const point& location)
const
206 label nearestIndex = 0;
207 scalar minProximity =
magSqr(centres[nearestIndex] - location);
223 const point& location,
224 const label seedCelli
235 label curCelli = seedCelli;
236 scalar distanceSqr =
magSqr(mesh_.cellCentres()[curCelli] - location);
247 mesh_.cellCells()[curCelli],
257 Foam::label Foam::meshSearch::findNearestFaceTree(
const point& location)
const
260 const indexedOctree<treeDataCell>& tree = cellTree();
266 magSqr(tree.bb().max()-tree.bb().min())
272 info = tree.findNearest(location,
Foam::sqr(GREAT));
278 const cell& ownFaces = mesh_.cells()[info.index()];
280 label nearestFacei = ownFaces[0];
281 scalar minProximity =
magSqr(centres[nearestFacei] - location);
296 Foam::label Foam::meshSearch::findNearestFaceLinear(
const point& location)
const
300 label nearestFacei = 0;
301 scalar minProximity =
magSqr(centres[nearestFacei] - location);
317 const point& location,
318 const label seedFacei
332 label curFacei = seedFacei;
333 scalar distanceSqr =
magSqr(centres[curFacei] - location);
337 label betterFacei = curFacei;
343 mesh_.cells()[mesh_.faceOwner()[curFacei]],
348 if (mesh_.isInternalFace(curFacei))
354 mesh_.cells()[mesh_.faceNeighbour()[curFacei]],
360 if (betterFacei == curFacei)
365 curFacei = betterFacei;
374 bool cellFound =
false;
379 while ((!cellFound) && (
n < mesh_.nCells()))
381 if (mesh_.pointInCell(location,
n, cellDecompMode_))
402 const point& location,
403 const label seedCelli
412 if (mesh_.pointInCell(location, seedCelli, cellDecompMode_))
418 label curCelli = seedCelli;
419 scalar nearestDistSqr =
magSqr(mesh_.cellCentres()[curCelli] - location);
425 const cell& cFaces = mesh_.cells()[curCelli];
427 label nearestCelli = -1;
431 label facei = cFaces[i];
433 if (mesh_.isInternalFace(facei))
435 label celli = mesh_.faceOwner()[facei];
436 if (celli == curCelli)
438 celli = mesh_.faceNeighbour()[facei];
442 if (mesh_.pointInCell(location, celli, cellDecompMode_))
448 scalar distSqr =
magSqr(mesh_.cellCentres()[celli] - location);
450 if (distSqr < nearestDistSqr)
452 nearestDistSqr = distSqr;
453 nearestCelli = celli;
458 if (nearestCelli == -1)
464 curCelli = nearestCelli;
471 Foam::label Foam::meshSearch::findNearestBoundaryFaceWalk
473 const point& location,
474 const label seedFacei
485 label curFacei = seedFacei;
487 const face&
f = mesh_.faces()[curFacei];
489 scalar minDist =
f.nearestPoint
504 label lastFacei = curFacei;
506 const labelList& myEdges = mesh_.faceEdges()[curFacei];
510 const labelList& neighbours = mesh_.edgeFaces()[myEdges[myEdgeI]];
517 label facei = neighbours[nI];
521 (facei >= mesh_.nInternalFaces())
522 && (facei != lastFacei)
525 const face&
f = mesh_.faces()[facei];
534 if (curHit.distance() < minDist)
536 minDist = curHit.distance();
551 Foam::meshSearch::meshSearch
558 cellDecompMode_(cellDecompMode)
572 Foam::meshSearch::meshSearch
580 cellDecompMode_(cellDecompMode)
609 if (!boundaryTreePtr_.valid())
615 if (!overallBbPtr_.valid())
626 overallBb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
627 overallBb.
max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
633 identity(mesh_.nBoundaryFaces(), mesh_.nInternalFaces())
636 boundaryTreePtr_.reset
654 return *boundaryTreePtr_;
661 if (!cellTreePtr_.valid())
667 if (!overallBbPtr_.valid())
678 overallBb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
679 overallBb.
max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
700 return *cellTreePtr_;
706 const point& location,
707 const label seedCelli,
708 const bool useTreeSearch
715 return findNearestCellTree(location);
719 return findNearestCellLinear(location);
723 return findNearestCellWalk(location, seedCelli);
729 const point& location,
730 const label seedFacei,
731 const bool useTreeSearch
738 return findNearestFaceTree(location);
742 return findNearestFaceLinear(location);
746 return findNearestFaceWalk(location, seedFacei);
752 const point& location,
753 const label seedCelli,
754 const bool useTreeSearch
762 return cellTree().findInside(location);
766 return findCellLinear(location);
770 return findCellWalk(location, seedCelli);
776 const point& location,
777 const label seedFacei,
778 const bool useTreeSearch
795 info = boundaryTree().findNearest
806 scalar minDist = GREAT;
812 label facei = mesh_.nInternalFaces();
813 facei < mesh_.nFaces();
817 const face&
f = mesh_.faces()[facei];
836 return findNearestBoundaryFaceWalk(location, seedFacei);
846 pointIndexHit curHit = boundaryTree().findLine(pStart, pEnd);
851 curHit.
setIndex(boundaryTree().shapes().faceLabels()[curHit.
index()]);
869 pointIndexHit curHit = boundaryTree().findLine(pStart, pEnd, iop);
870 if (!curHit.
hit())
break;
873 curHit.
setIndex(boundaryTree().shapes().faceLabels()[curHit.
index()]);
892 boundaryTreePtr_.clear();
893 cellTreePtr_.clear();
894 overallBbPtr_.clear();