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
29 Encapsulation of data needed for octree searches.
31 Used for searching for nearest point. No bounding boxes around points.
32 Only overlaps and calcNearest are implemented, rest makes little sense.
33 Holds (reference to) pointField.
37 octreeDataPointTreaLeaf.H (template specialization of treeleaf)
38 octreeDataPointTreeLeaf.C (template specialization of treeleaf)
40 \*---------------------------------------------------------------------------*/
42 #ifndef octreeDataPoint_H
43 #define octreeDataPoint_H
46 #include "pointField.H"
47 #include "treeBoundBox.H"
48 #include "linePointRef.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 template<class Type> class octree;
57 /*---------------------------------------------------------------------------*\
58 Class octreeDataPoint Declaration
59 \*---------------------------------------------------------------------------*/
65 const pointField& points_;
71 //- Construct from components. Holds reference to points!
72 octreeDataPoint(const pointField&);
79 const pointField& points() const
86 return points_.size();
91 //- Get type of sample
94 const octree<octreeDataPoint>&,
98 //- Does (bb of) shape at index overlap bb
102 const treeBoundBox& sampleBb
105 //- Does shape at index contain sample
112 //- Segment (from start to end) intersection with shape
113 // at index. If intersects returns true and sets intersectionPoint
119 point& intersectionPoint
122 //- Sets newTightest to bounding box (and returns true) if
123 // nearer to sample than tightest bounding box. Otherwise
129 treeBoundBox& tightest
132 //- Given index get unit normal and calculate (numerical) sign
134 // Used to determine accuracy of calcNearest or inside/outside.
135 // Note: always returns GREAT since no inside/outside.
144 //- Calculates nearest (to sample) point on/in shape.
145 // Returns point and mag(nearest - sample)
153 //- Calculates nearest (to line segment) point in shape.
154 // Returns distance and both point.
158 const linePointRef& ln,
159 point& linePt, // nearest point on line
160 point& shapePt // nearest point on shape
167 //- Write shape at index
168 void write(Ostream& os, const label index) const;
171 // IOstream Operators
173 friend Ostream& operator<<(Ostream&, const octreeDataPoint&);
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 } // End namespace Foam
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 // ************************************************************************* //