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
25 \*---------------------------------------------------------------------------*/
27 #include "octreeDataPoint.H"
29 #include "labelList.H"
30 #include "treeBoundBox.H"
32 #include "linePointRef.H"
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 // Construct from components
38 Foam::octreeDataPoint::octreeDataPoint(const pointField& points)
44 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
46 //- Get type of volume
47 Foam::label Foam::octreeDataPoint::getSampleType
49 const octree<octreeDataPoint>&,
53 return octree<octreeDataPoint>::UNKNOWN;
57 bool Foam::octreeDataPoint::overlaps
60 const treeBoundBox& sampleBb
63 return sampleBb.contains(points_[index]);
67 bool Foam::octreeDataPoint::contains
75 "octreeDataPoint::contains(const label, const point&)"
82 bool Foam::octreeDataPoint::intersects
92 "octreeDataPoint::intersects(const label, const point&,"
93 "const point&, point&)"
100 bool Foam::octreeDataPoint::findTightest
109 "octreeDataPoint::findTightest(const label, const point&,"
117 Foam::scalar Foam::octreeDataPoint::calcSign
130 // Calculate nearest point on/in shapei
131 inline Foam::scalar Foam::octreeDataPoint::calcNearest
138 nearest = points_[index];
139 return magSqr(points_[index] - sample);
143 void Foam::octreeDataPoint::write
149 if ((index < 0) || (index > points().size()))
151 FatalErrorIn("octreeDataPoint::write(Ostream&, const label)")
152 << "Index " << index << " outside 0.." << points().size()
153 << abort(FatalError);
155 os << ' ' << points()[index];
159 // Calculate nearest point on/in shapei
160 Foam::scalar Foam::octreeDataPoint::calcNearest
163 const linePointRef& ln,
168 // Nearest point on shape
169 shapePt = points_[index];
171 // Nearest point on line
172 pointHit pHit = ln.nearestDist(shapePt);
174 linePt = pHit.rawPoint();
176 return pHit.distance();
180 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
182 Foam::Ostream& Foam::operator<<
185 const Foam::octreeDataPoint& ocPts
188 return os << ocPts.points();
192 // ************************************************************************* //