/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- 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 "AABBTree.H" #include "bitSet.H" // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // template void Foam::AABBTree::writeOBJ ( const bool leavesOnly, const bool writeLinesOnly, const treeBoundBox& bb, const label nodeI, const List>& bbs, const List>& nodes, label& vertI, Ostream& os ) const { if (!leavesOnly || nodeI < 0) { AABBTreeBase::writeOBJ(os, bb, vertI, writeLinesOnly); } // recurse to find leaves if (nodeI >= 0) { writeOBJ ( leavesOnly, writeLinesOnly, bbs[nodeI].first(), nodes[nodeI].first(), bbs, nodes, vertI, os ); writeOBJ ( leavesOnly, writeLinesOnly, bbs[nodeI].second(), nodes[nodeI].second(), bbs, nodes, vertI, os ); } } template void Foam::AABBTree::createBoxes ( const bool equalBinSize, const label level, const UList& objects, const pointField& points, const labelUList& objectIDs, const treeBoundBox& bb, const label nodeI, DynamicList>& bbs, DynamicList& nodes, DynamicList& addressing ) const { const vector span = bb.span(); // Determine which direction to divide the box direction maxDir = 0; scalar maxSpan = span[maxDir]; for (label dirI = 1; dirI < 3; ++dirI) { if (span[dirI] > maxSpan) { maxSpan = span[dirI]; maxDir = dirI; } } scalar pivotValue; if (equalBinSize) { // Pick up points used by this set of objects bitSet isUsedPoint(points.size()); DynamicList component(points.size()); for (const label objI : objectIDs) { const Type& obj = objects[objI]; for (const label pointI : obj) { if (isUsedPoint.set(pointI)) { component.append(points[pointI][maxDir]); } } } // Determine the median Foam::sort(component); pivotValue = component[component.size()/2]; } else { // Geometric middle pivotValue = bb.min()[maxDir] + 0.5*maxSpan; } const scalar divMin = pivotValue + tolerance_*maxSpan; const scalar divMax = pivotValue - tolerance_*maxSpan; // Assign the objects to min or max bin DynamicList