initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / octree / octreeDataPoint.C
blob2bd844ca4b51b3a89bcf8b0858e9f19d1108990a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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"
31 #include "octree.H"
32 #include "linePointRef.H"
33 #include "pointHit.H"
35 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
37 // Construct from components
38 Foam::octreeDataPoint::octreeDataPoint(const pointField& points)
40     points_(points)
44 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
46 //- Get type of volume
47 Foam::label Foam::octreeDataPoint::getSampleType
49     const octree<octreeDataPoint>&,
50     const point&
51 ) const
53     return octree<octreeDataPoint>::UNKNOWN;
57 bool Foam::octreeDataPoint::overlaps
59     const label index,
60     const treeBoundBox& sampleBb
61 ) const
63     return sampleBb.contains(points_[index]);
67 bool Foam::octreeDataPoint::contains
69     const label,
70     const point&
71 ) const
73     notImplemented
74     (
75         "octreeDataPoint::contains(const label, const point&)"
76     );
78     return false;
82 bool Foam::octreeDataPoint::intersects
84     const label,
85     const point&,
86     const point&,
87     point&
88 ) const
90     notImplemented
91     (
92         "octreeDataPoint::intersects(const label, const point&,"
93         "const point&, point&)"
94     );
96     return false;
100 bool Foam::octreeDataPoint::findTightest
102     const label,
103     const point&,
104     treeBoundBox&
105 ) const
107     notImplemented
108     (
109         "octreeDataPoint::findTightest(const label, const point&,"
110         "treeBoundBox&)"
111     );
113     return false;
117 Foam::scalar Foam::octreeDataPoint::calcSign
119     const label,
120     const point&,
121     vector& n
122 ) const
124     n = vector::zero;
126     return 1;
130 // Calculate nearest point on/in shapei
131 inline Foam::scalar Foam::octreeDataPoint::calcNearest
133     const label index,
134     const point& sample,
135     point& nearest
136 ) const
138     nearest = points_[index];
139     return magSqr(points_[index] - sample);
143 void Foam::octreeDataPoint::write
145     Ostream& os,
146     const label index
147 ) const
149     if ((index < 0) || (index > points().size()))
150     {
151         FatalErrorIn("octreeDataPoint::write(Ostream&, const label)")
152             << "Index " << index << " outside 0.." << points().size()
153             << abort(FatalError);
154     }
155     os << ' ' << points()[index];
159 // Calculate nearest point on/in shapei
160 Foam::scalar Foam::octreeDataPoint::calcNearest
162     const label index,
163     const linePointRef& ln,
164     point& linePt,
165     point& shapePt
166 ) const
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<<
184     Foam::Ostream& os,
185     const Foam::octreeDataPoint& ocPts
188     return os << ocPts.points();
192 // ************************************************************************* //