ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / meshTools / indexedOctree / treeDataPoint.H
blobabd0a4024a7a58179a482384412858611bf26a2f
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::treeDataPoint
27 Description
28     Holds (reference to) pointField. Encapsulation of data needed for
29     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.
33     Optionally works on subset of points.
35 SourceFiles
36     treeDataPoint.C
38 \*---------------------------------------------------------------------------*/
40 #ifndef treeDataPoint_H
41 #define treeDataPoint_H
43 #include "pointField.H"
44 #include "treeBoundBox.H"
45 #include "linePointRef.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 namespace Foam
52 // Forward declaration of classes
53 template<class Type> class indexedOctree;
55 /*---------------------------------------------------------------------------*\
56                            Class treeDataPoint Declaration
57 \*---------------------------------------------------------------------------*/
59 class treeDataPoint
61     // Private data
63         const pointField& points_;
65         //- Subset of points to work on (or empty)
66         const labelList pointLabels_;
68         const bool useSubset_;
70 public:
72     // Declare name of the class and its debug switch
73     ClassName("treeDataPoint");
76     // Constructors
78         //- Construct from pointField. Holds reference!
79         treeDataPoint(const pointField&);
81         //- Construct from subset of pointField. Holds reference!
82         treeDataPoint(const pointField&, const labelList&);
85     // Member Functions
87         // Access
89             inline label size() const
90             {
91                 return
92                 (
93                     useSubset_
94                   ? pointLabels_.size()
95                   : points_.size()
96                 );
97             }
99             inline const labelList& pointLabels() const
100             {
101                 return pointLabels_;
102             }
104             const pointField& points() const
105             {
106                 return points_;
107             }
109             //- Get representative point cloud for all shapes inside
110             //  (one point per shape)
111             pointField shapePoints() const;
114         // Search
116             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
117             //  Only makes sense for closed surfaces.
118             label getVolumeType
119             (
120                 const indexedOctree<treeDataPoint>&,
121                 const point&
122             ) const;
124             //- Does (bb of) shape at index overlap bb
125             bool overlaps
126             (
127                 const label index,
128                 const treeBoundBox& sampleBb
129             ) const;
131             //- Calculates nearest (to sample) point in shape.
132             //  Returns actual point and distance (squared)
133             void findNearest
134             (
135                 const labelUList& indices,
136                 const point& sample,
138                 scalar& nearestDistSqr,
139                 label& nearestIndex,
140                 point& nearestPoint
141             ) const;
143             //- Calculates nearest (to line) point in shape.
144             //  Returns point and distance (squared)
145             void findNearest
146             (
147                 const labelUList& indices,
148                 const linePointRef& ln,
150                 treeBoundBox& tightest,
151                 label& minIndex,
152                 point& linePoint,
153                 point& nearestPoint
154             ) const;
156             //- Calculate intersection of shape with ray. Sets result
157             //  accordingly
158             bool intersects
159             (
160                 const label index,
161                 const point& start,
162                 const point& end,
163                 point& result
164             ) const
165             {
166                 notImplemented
167                 (
168                     "treeDataPoint::intersects(const label, const point&,"
169                     "const point&, point&)"
170                 );
171                 return false;
172             }
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 } // End namespace Foam
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 #endif
186 // ************************************************************************* //