ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / meshTools / octree / octreeDataPoint.C
blobde700f28acfa742b1c771c3d5283c678f95d659c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
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
19     for more details.
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"
30 #include "octree.H"
31 #include "linePointRef.H"
32 #include "pointHit.H"
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 // Construct from components
37 Foam::octreeDataPoint::octreeDataPoint(const pointField& points)
39     points_(points)
43 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
45 //- Get type of volume
46 Foam::label Foam::octreeDataPoint::getSampleType
48     const octree<octreeDataPoint>&,
49     const point&
50 ) const
52     return octree<octreeDataPoint>::UNKNOWN;
56 bool Foam::octreeDataPoint::overlaps
58     const label index,
59     const treeBoundBox& sampleBb
60 ) const
62     return sampleBb.contains(points_[index]);
66 bool Foam::octreeDataPoint::contains
68     const label,
69     const point&
70 ) const
72     notImplemented
73     (
74         "octreeDataPoint::contains(const label, const point&)"
75     );
77     return false;
81 bool Foam::octreeDataPoint::intersects
83     const label,
84     const point&,
85     const point&,
86     point&
87 ) const
89     notImplemented
90     (
91         "octreeDataPoint::intersects(const label, const point&,"
92         "const point&, point&)"
93     );
95     return false;
99 bool Foam::octreeDataPoint::findTightest
101     const label,
102     const point&,
103     treeBoundBox&
104 ) const
106     notImplemented
107     (
108         "octreeDataPoint::findTightest(const label, const point&,"
109         "treeBoundBox&)"
110     );
112     return false;
116 Foam::scalar Foam::octreeDataPoint::calcSign
118     const label,
119     const point&,
120     vector& n
121 ) const
123     n = vector::zero;
125     return 1;
129 // Calculate nearest point on/in shapei
130 inline Foam::scalar Foam::octreeDataPoint::calcNearest
132     const label index,
133     const point& sample,
134     point& nearest
135 ) const
137     nearest = points_[index];
138     return magSqr(points_[index] - sample);
142 void Foam::octreeDataPoint::write
144     Ostream& os,
145     const label index
146 ) const
148     if ((index < 0) || (index > points().size()))
149     {
150         FatalErrorIn("octreeDataPoint::write(Ostream&, const label)")
151             << "Index " << index << " outside 0.." << points().size()
152             << abort(FatalError);
153     }
154     os << ' ' << points()[index];
158 // Calculate nearest point on/in shapei
159 Foam::scalar Foam::octreeDataPoint::calcNearest
161     const label index,
162     const linePointRef& ln,
163     point& linePt,
164     point& shapePt
165 ) const
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<<
183     Foam::Ostream& os,
184     const Foam::octreeDataPoint& ocPts
187     return os << ocPts.points();
191 // ************************************************************************* //