Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / foam / algorithms / octree / indexedOctree / treeDataPoint.H
blobdad56e33e4e7941939e23419ed4da5509bc9edff
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  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 SourceFiles
34     treeDataPoint.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef treeDataPoint_H
39 #define treeDataPoint_H
41 #include "pointField.H"
42 #include "treeBoundBox.H"
43 #include "linePointRef.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 // Forward declaration of classes
51 template<class Type> class indexedOctree;
53 /*---------------------------------------------------------------------------*\
54                            Class treeDataPoint Declaration
55 \*---------------------------------------------------------------------------*/
57 class treeDataPoint
59     // Private data
61         const pointField& points_;
63 public:
65     // Declare name of the class and its debug switch
66     ClassName("treeDataPoint");
69     // Constructors
71         //- Construct from components. Holds reference to points!
72         treeDataPoint(const pointField& points);
75     // Member Functions
77         // Access
79             label size() const
80             {
81                 return points_.size();
82             }
84             //- Get representative point cloud for all shapes inside
85             //  (one point per shape)
86             pointField points() const;
89         // Search
91             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
92             //  Only makes sense for closed surfaces.
93             label getVolumeType
94             (
95                 const indexedOctree<treeDataPoint>&,
96                 const point&
97             ) const;
99             //- Does (bb of) shape at index overlap bb
100             bool overlaps
101             (
102                 const label index,
103                 const treeBoundBox& sampleBb
104             ) const;
106             //- Calculates nearest (to sample) point in shape.
107             //  Returns actual point and distance (squared)
108             void findNearest
109             (
110                 const labelList& indices,
111                 const point& sample,
113                 scalar& nearestDistSqr,
114                 label& nearestIndex,
115                 point& nearestPoint
116             ) const;
118             //- Calculates nearest (to line) point in shape.
119             //  Returns point and distance (squared)
120             void findNearest
121             (
122                 const labelList& indices,
123                 const linePointRef& ln,
125                 treeBoundBox& tightest,
126                 label& minIndex,
127                 point& linePoint,
128                 point& nearestPoint
129             ) const;
131             //- Calculate intersection of shape with ray. Sets result
132             //  accordingly
133             bool intersects
134             (
135                 const label index,
136                 const point& start,
137                 const point& end,
138                 point& result
139             ) const
140             {
141                 notImplemented
142                 (
143                     "treeDataPoint::intersects(const label, const point&,"
144                     "const point&, point&)"
145                 );
146                 return false;
147             }
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 } // End namespace Foam
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 #endif
161 // ************************************************************************* //