1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 \*---------------------------------------------------------------------------*/
29 //#include "octreeDataPointTreeLeaf.H"
30 #include "octreeDataPoint.H"
33 // * * * * * * * * * * * * * Template Specialisations * * * * * * * * * * * //
36 Foam::label Foam::treeLeaf<Foam::octreeDataPoint>::find
38 const octreeDataPoint& shapes,
44 "Foam::treeLeaf<Foam::octreeDataPoint>::find("
45 "const octreeDataPoint& shapes,"
54 bool Foam::treeLeaf<Foam::octreeDataPoint>::findNearest
56 const octreeDataPoint& shapes,
58 treeBoundBox& tightest,
64 const pointField& points = shapes.points();
65 point& tMin = tightest.min();
66 point& tMax = tightest.max();
68 scalar minDist2 = sqr(tightestDist);
73 label pointi = indices_[i];
74 scalar dist = magSqr(points[pointi] - sample);
85 tightestDist = sqrt(minDist2);
87 // New nearer. Update 'tightest' bounding box
88 tMin.x() = sample.x() - tightestDist;
89 tMin.y() = sample.y() - tightestDist;
90 tMin.z() = sample.z() - tightestDist;
92 tMax.x() = sample.x() + tightestDist;
93 tMax.y() = sample.y() + tightestDist;
94 tMax.z() = sample.z() + tightestDist;
102 // New no nearer so nothing changed
108 // ************************************************************************* //