/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "dynamicIndexedOctree.H" #include "linePointRef.H" #include "OFstream.H" #include "ListOps.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template Foam::scalar Foam::dynamicIndexedOctree::perturbTol_ = 10*SMALL; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template bool Foam::dynamicIndexedOctree::overlaps ( const point& p0, const point& p1, const scalar nearestDistSqr, const point& sample ) { // Find out where sample is in relation to bb. // Find nearest point on bb. scalar distSqr = 0; for (direction dir = 0; dir < vector::nComponents; dir++) { scalar d0 = p0[dir] - sample[dir]; scalar d1 = p1[dir] - sample[dir]; if ((d0 > 0) != (d1 > 0)) { // sample inside both extrema. This component does not add any // distance. } else if (mag(d0) < mag(d1)) { distSqr += d0*d0; } else { distSqr += d1*d1; } if (distSqr > nearestDistSqr) { return false; } } return true; } template bool Foam::dynamicIndexedOctree::overlaps ( const treeBoundBox& parentBb, const direction octant, const scalar nearestDistSqr, const point& sample ) { //- Accelerated version of // treeBoundBox subBb(parentBb.subBbox(mid, octant)) // overlaps // ( // subBb.min(), // subBb.max(), // nearestDistSqr, // sample // ) const point& min = parentBb.min(); const point& max = parentBb.max(); point other; if (octant & treeBoundBox::RIGHTHALF) { other.x() = max.x(); } else { other.x() = min.x(); } if (octant & treeBoundBox::TOPHALF) { other.y() = max.y(); } else { other.y() = min.y(); } if (octant & treeBoundBox::FRONTHALF) { other.z() = max.z(); } else { other.z() = min.z(); } const point mid(0.5*(min+max)); return overlaps(mid, other, nearestDistSqr, sample); } template void Foam::dynamicIndexedOctree::divide ( const autoPtr>& indices, const treeBoundBox& bb, contentListList& result ) const { for (direction octant = 0; octant < 8; octant++) { result.append ( autoPtr> ( new DynamicList