1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "octreeDataPoint.H"
28 #include "labelList.H"
29 #include "treeBoundBox.H"
31 #include "linePointRef.H"
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 // Construct from components
37 Foam::octreeDataPoint::octreeDataPoint(const pointField& points)
43 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
45 //- Get type of volume
46 Foam::label Foam::octreeDataPoint::getSampleType
48 const octree<octreeDataPoint>&,
52 return octree<octreeDataPoint>::UNKNOWN;
56 bool Foam::octreeDataPoint::overlaps
59 const treeBoundBox& sampleBb
62 return sampleBb.contains(points_[index]);
66 bool Foam::octreeDataPoint::contains
74 "octreeDataPoint::contains(const label, const point&)"
81 bool Foam::octreeDataPoint::intersects
91 "octreeDataPoint::intersects(const label, const point&,"
92 "const point&, point&)"
99 bool Foam::octreeDataPoint::findTightest
108 "octreeDataPoint::findTightest(const label, const point&,"
116 Foam::scalar Foam::octreeDataPoint::calcSign
129 // Calculate nearest point on/in shapei
130 inline Foam::scalar Foam::octreeDataPoint::calcNearest
137 nearest = points_[index];
138 return magSqr(points_[index] - sample);
142 void Foam::octreeDataPoint::write
148 if ((index < 0) || (index > points().size()))
150 FatalErrorIn("octreeDataPoint::write(Ostream&, const label)")
151 << "Index " << index << " outside 0.." << points().size()
152 << abort(FatalError);
154 os << ' ' << points()[index];
158 // Calculate nearest point on/in shapei
159 Foam::scalar Foam::octreeDataPoint::calcNearest
162 const linePointRef& ln,
167 // Nearest point on shape
168 shapePt = points_[index];
170 // Nearest point on line
171 pointHit pHit = ln.nearestDist(shapePt);
173 linePt = pHit.rawPoint();
175 return pHit.distance();
179 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
181 Foam::Ostream& Foam::operator<<
184 const Foam::octreeDataPoint& ocPts
187 return os << ocPts.points();
191 // ************************************************************************* //