1 /*---------------------------------------------------------------------------*\
\r
3 \\ / F ield | foam-extend: Open Source CFD
\r
4 \\ / O peration | Version: 3.2
\r
5 \\ / A nd | Web: http://www.foam-extend.org
\r
6 \\/ M anipulation | For copyright notice see file Copyright
\r
7 -------------------------------------------------------------------------------
\r
9 This file is part of foam-extend.
\r
11 foam-extend is free software: you can redistribute it and/or modify it
\r
12 under the terms of the GNU General Public License as published by the
\r
13 Free Software Foundation, either version 3 of the License, or (at your
\r
14 option) any later version.
\r
16 foam-extend is distributed in the hope that it will be useful, but
\r
17 WITHOUT ANY WARRANTY; without even the implied warranty of
\r
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
19 General Public License for more details.
\r
21 You should have received a copy of the GNU General Public License
\r
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
\r
26 \*---------------------------------------------------------------------------*/
\r
28 #include "octreeDataTriSurface.H"
\r
29 #include "octreeDataTriSurfaceTreeLeaf.H"
\r
31 // * * * * * * * * * * * * * Template Specialisations * * * * * * * * * * * //
\r
34 bool Foam::treeLeaf<Foam::octreeDataTriSurface>::findNearest
\r
36 const octreeDataTriSurface& shapes,
\r
37 const point& sample,
\r
38 treeBoundBox& tightest,
\r
40 scalar& tightestDist
\r
44 const treeBoundBoxList& allBb = shapes.allBb();
\r
45 point& min = tightest.min();
\r
46 point& max = tightest.max();
\r
50 bool changed = false;
\r
53 label faceI = indices_[i];
\r
55 // Quick rejection test.
\r
56 if (tightest.overlaps(allBb[faceI]))
\r
59 scalar dist = shapes.calcNearest(faceI, sample, nearest);
\r
61 if (dist < tightestDist)
\r
63 // Update bb (centered around sample, span is dist)
\r
64 min.x() = sample.x() - dist;
\r
65 min.y() = sample.y() - dist;
\r
66 min.z() = sample.z() - dist;
\r
68 max.x() = sample.x() + dist;
\r
69 max.y() = sample.y() + dist;
\r
70 max.z() = sample.z() + dist;
\r
73 tightestDist = dist;
\r
83 // ************************************************************************* //
\r