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/>.
28 Encapsulation of data needed for octree searches.
30 Used for searching for nearest point. No bounding boxes around points.
31 Only overlaps and calcNearest are implemented, rest makes little sense.
32 Holds (reference to) pointField.
36 octreeDataPointTreaLeaf.H (template specialization of treeleaf)
37 octreeDataPointTreeLeaf.C (template specialization of treeleaf)
39 \*---------------------------------------------------------------------------*/
41 #ifndef octreeDataPoint_H
42 #define octreeDataPoint_H
45 #include "pointField.H"
46 #include "treeBoundBox.H"
47 #include "linePointRef.H"
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 template<class Type> class octree;
56 /*---------------------------------------------------------------------------*\
57 Class octreeDataPoint Declaration
58 \*---------------------------------------------------------------------------*/
64 const pointField& points_;
70 //- Construct from components. Holds reference to points!
71 explicit octreeDataPoint(const pointField&);
78 const pointField& points() const
85 return points_.size();
90 //- Get type of sample
93 const octree<octreeDataPoint>&,
97 //- Does (bb of) shape at index overlap bb
101 const treeBoundBox& sampleBb
104 //- Does shape at index contain sample
111 //- Segment (from start to end) intersection with shape
112 // at index. If intersects returns true and sets intersectionPoint
118 point& intersectionPoint
121 //- Sets newTightest to bounding box (and returns true) if
122 // nearer to sample than tightest bounding box. Otherwise
128 treeBoundBox& tightest
131 //- Given index get unit normal and calculate (numerical) sign
133 // Used to determine accuracy of calcNearest or inside/outside.
134 // Note: always returns GREAT since no inside/outside.
143 //- Calculates nearest (to sample) point on/in shape.
144 // Returns point and mag(nearest - sample)
152 //- Calculates nearest (to line segment) point in shape.
153 // Returns distance and both point.
157 const linePointRef& ln,
158 point& linePt, // nearest point on line
159 point& shapePt // nearest point on shape
166 //- Write shape at index
167 void write(Ostream& os, const label index) const;
170 // IOstream Operators
172 friend Ostream& operator<<(Ostream&, const octreeDataPoint&);
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 } // End namespace Foam
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 // ************************************************************************* //