/*---------------------------------------------------------------------------*\ ========= | \\ / 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 "meshTools.H" #include "bitSet.H" //#include "OFstream.H" template Foam::scalar Foam::AABBTree::tolerance_ = 1e-4; // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // template void Foam::AABBTree::writeOBJ ( const bool writeLinesOnly, const treeBoundBox& bb, label& vertI, Ostream& os ) const { const pointField pts(bb.points()); for (const point& pt : pts) { meshTools::writeOBJ(os, pt); } if (writeLinesOnly) { for (const edge& e : bb.edges) { os << "l " << e[0] + vertI + 1 << ' ' << e[1] + vertI + 1 << nl; } } else { for (const face& f : bb.faces) { os << 'f'; for (const label fpi : f) { os << ' ' << fpi + vertI + 1; } os << nl; } } vertI += pts.size(); } 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) { writeOBJ(writeLinesOnly, bb, vertI, os); } // 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 List& objects, const pointField& points, const DynamicList