ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / meshTools / octree / octreeDataPoint.H
blob2ea8cfb50b73a38bef3d6c393e4901be089b39ea
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 Class
25     Foam::octreeDataPoint
27 Description
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.
34 SourceFiles
35     octreeDataPoint.C
36     octreeDataPointTreaLeaf.H   (template specialization of treeleaf)
37     octreeDataPointTreeLeaf.C   (template specialization of treeleaf)
39 \*---------------------------------------------------------------------------*/
41 #ifndef octreeDataPoint_H
42 #define octreeDataPoint_H
44 #include "point.H"
45 #include "pointField.H"
46 #include "treeBoundBox.H"
47 #include "linePointRef.H"
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 namespace Foam
54 template<class Type> class octree;
56 /*---------------------------------------------------------------------------*\
57                            Class octreeDataPoint Declaration
58 \*---------------------------------------------------------------------------*/
60 class octreeDataPoint
62     // Private data
64         const pointField& points_;
66 public:
68     // Constructors
70         //- Construct from components. Holds reference to points!
71         explicit octreeDataPoint(const pointField&);
74     // Member Functions
76         // Access
78             const pointField& points() const
79             {
80                 return points_;
81             }
83             label size() const
84             {
85                 return points_.size();
86             }
88         // Search
90             //- Get type of sample
91             label getSampleType
92             (
93                 const octree<octreeDataPoint>&,
94                 const point&
95             ) const;
97             //- Does (bb of) shape at index overlap bb
98             bool overlaps
99             (
100                 const label index,
101                 const treeBoundBox& sampleBb
102             ) const;
104             //- Does shape at index contain sample
105             bool contains
106             (
107                 const label index,
108                 const point& sample
109             ) const;
111             //- Segment (from start to end) intersection with shape
112             //  at index. If intersects returns true and sets intersectionPoint
113             bool intersects
114             (
115                 const label index,
116                 const point& start,
117                 const point& end,
118                 point& intersectionPoint
119             ) const;
121             //- Sets newTightest to bounding box (and returns true) if
122             //  nearer to sample than tightest bounding box. Otherwise
123             //  returns false.
124             bool findTightest
125             (
126                 const label index,
127                 const point& sample,
128                 treeBoundBox& tightest
129             ) const;
131             //- Given index get unit normal and calculate (numerical) sign
132             //  of sample.
133             //  Used to determine accuracy of calcNearest or inside/outside.
134             //  Note: always returns GREAT since no inside/outside.
135             scalar calcSign
136             (
137                 const label index,
138                 const point& sample,
139                 vector& n
140             ) const;
143             //- Calculates nearest (to sample) point on/in shape.
144             //  Returns point and mag(nearest - sample)
145             scalar calcNearest
146             (
147                 const label index,
148                 const point& sample,
149                 point& nearest
150             ) const;
152             //- Calculates nearest (to line segment) point in shape.
153             //  Returns distance and both point.
154             scalar calcNearest
155             (
156                 const label index,
157                 const linePointRef& ln,
158                 point& linePt,          // nearest point on line
159                 point& shapePt          // nearest point on shape
160             ) const;
164         // Write
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 #endif
184 // ************************************************************************* //