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 / treeDataEdge.H
blobc5a78f4f62eb7c83cffff17edb4586115b3a4e24
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::treeDataEdge
27 Description
28     Holds data for octree to work on an edges subset.
30 SourceFiles
31     treeDataEdge.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef treeDataEdge_H
36 #define treeDataEdge_H
38 #include "treeBoundBoxList.H"
39 #include "linePointRef.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 // Forward declaration of classes
47 template<class Type> class indexedOctree;
49 /*---------------------------------------------------------------------------*\
50                            Class treeDataEdge Declaration
51 \*---------------------------------------------------------------------------*/
53 class treeDataEdge
55     // Static data
57         //- tolerance on linear dimensions
58         static scalar tol;
61     // Private data
63         //- Reference to edgeList
64         const edgeList& edges_;
66         //- Reference to points
67         const pointField& points_;
69         //- labels of edges
70         const labelList edgeLabels_;
72         //- Whether to precalculate and store face bounding box
73         const bool cacheBb_;
75         //- bbs for all above edges (valid only if cacheBb_)
76         treeBoundBoxList bbs_;
79     // Private Member Functions
81         //- Calculate edge bounding box
82         treeBoundBox calcBb(const label edgeI) const;
84 public:
86     // Declare name of the class and its debug switch
87     ClassName("treeDataEdge");
90     // Constructors
92         //- Construct from selected edges. !Holds references to edges and points
93         treeDataEdge
94         (
95             const bool cacheBb,
96             const edgeList& edges,
97             const pointField& points,
98             const labelList& edgeLabels
99         );
102     // Member Functions
104         // Access
106             label size() const
107             {
108                 return edgeLabels_.size();
109             }
111             //- Get representative point cloud for all shapes inside
112             //  (one point per shape)
113             pointField points() const;
116         // Search
118             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
119             //  Only makes sense for closed surfaces.
120             label getVolumeType
121             (
122                 const indexedOctree<treeDataEdge>&,
123                 const point&
124             ) const;
126             //- Does (bb of) shape at index overlap bb
127             bool overlaps
128             (
129                 const label index,
130                 const treeBoundBox& sampleBb
131             ) const;
133             //- Calculates nearest (to sample) point in shape.
134             //  Returns actual point and distance (squared)
135             void findNearest
136             (
137                 const labelList& indices,
138                 const point& sample,
140                 scalar& nearestDistSqr,
141                 label& nearestIndex,
142                 point& nearestPoint
143             ) const;
145             //- Calculates nearest (to line) point in shape.
146             //  Returns point and distance (squared)
147             void findNearest
148             (
149                 const labelList& indices,
150                 const linePointRef& ln,
152                 treeBoundBox& tightest,
153                 label& minIndex,
154                 point& linePoint,
155                 point& nearestPoint
156             ) const;
158             //- Calculate intersection of shape with ray. Sets result
159             //  accordingly
160             bool intersects
161             (
162                 const label index,
163                 const point& start,
164                 const point& end,
165                 point& result
166             ) const
167             {
168                 notImplemented
169                 (
170                     "treeDataEdge::intersects(const label, const point&,"
171                     "const point&, point&)"
172                 );
173                 return false;
174             }
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 } // End namespace Foam
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 #endif
188 // ************************************************************************* //