Foam::pointIndexHit Foam::searchableSurfacesQueries::tempFindNearest
(
    const searchableSurface& surf,
    const point& pt,
    const scalar initDistSqr
)
{
    pointField onePoint(1, pt);
    scalarField oneDist(1, initDistSqr);
    List<pointIndexHit> oneHit(1);
    surf.findNearest(onePoint, oneDist, oneHit);
    return oneHit[0];
}
void Foam::AMIInterpolation<SourcePatch, TargetPatch>::projectPointsToSurface
(
    const searchableSurface& surf,
    pointField& pts
) const
{
    if (debug)
    {
        Info<< "AMI: projecting points to surface" << endl;
    }

    List<pointIndexHit> nearInfo;

    surf.findNearest(pts, scalarField(pts.size(), GREAT), nearInfo);

    label nMiss = 0;
    forAll(nearInfo, i)
    {
        const pointIndexHit& pi = nearInfo[i];

        if (pi.hit())
        {
            pts[i] = pi.hitPoint();
        }
        else
        {
            pts[i] = pts[i];
            nMiss++;
        }
    }

    if (nMiss > 0)
    {
        FatalErrorInFunction
            << "Error projecting points to surface: "
            << nMiss << " faces could not be determined"
            << abort(FatalError);
    }
}
Foam::autoPtr<Foam::searchableSurfaceFeatures>
Foam::searchableSurfaceFeatures::New
(
    const searchableSurface& surface,
    const dictionary& dict
)
{
    word searchableSurfaceFeaturesType = surface.type() + "Features";

    dictConstructorTable::iterator cstrIter =
        dictConstructorTablePtr_->find(searchableSurfaceFeaturesType);

    if (cstrIter == dictConstructorTablePtr_->end())
    {
        FatalErrorInFunction
            << "Unknown searchableSurfaceFeatures type "
            << searchableSurfaceFeaturesType << endl << endl
            << "Valid searchableSurfaceFeatures types : " << endl
            << dictConstructorTablePtr_->sortedToc()
            << exit(FatalError);
    }

    return autoPtr<searchableSurfaceFeatures>(cstrIter()(surface, dict));
}