Formatting
[foam-extend-3.2.git] / src / foam / algorithms / octree / indexedOctree / treeDataFace.H
blob1d6ae279b2e6c50384d7e2a231603d63f98bfc32
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::treeDataFace
27 Description
28     Encapsulation of data needed to search for faces.
30 SourceFiles
31     treeDataFace.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef treeDataFace_H
36 #define treeDataFace_H
38 #include "face.H"
39 #include "indexedOctree.H"
40 #include "treeBoundBoxList.H"
41 #include "PackedBoolList.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 // Forward declaration of classes
49 class primitiveMesh;
50 //template<class Type> class indexedOctree;
51 class polyPatch;
53 /*---------------------------------------------------------------------------*\
54                            Class treeDataFace Declaration
55 \*---------------------------------------------------------------------------*/
57 class treeDataFace
59     // Static data
61         //- tolerance on linear dimensions
62         static scalar tolSqr;
66     // Private data
68         const primitiveMesh& mesh_;
70         //- Subset of faces to work on
71         const labelList faceLabels_;
73         //- Inverse of faceLabels. For every mesh whether face is in faceLabels.
74         PackedBoolList isTreeFace_;
76         //- Whether to precalculate and store face bounding box
77         const bool cacheBb_;
79         //- face bounding boxes (valid only if cacheBb_)
80         treeBoundBoxList bbs_;
83     // Private Member Functions
85         //- Calculate face bounding box
86         treeBoundBox calcBb(const label cellI) const;
88         //- Initialise all member data
89         void update();
91 public:
93     // Declare name of the class and its debug switch
94     ClassName("treeDataFace");
97     // Constructors
99         //- Construct from mesh and subset of faces.
100         treeDataFace
101         (
102             const bool cacheBb,
103             const primitiveMesh&,
104             const labelList&
105         );
107         //- Construct from mesh. Uses all faces in mesh.
108         treeDataFace(const bool cacheBb, const primitiveMesh&);
110         //- Construct from mesh. Uses all faces in patch.
111         treeDataFace(const bool cacheBb, const polyPatch&);
114     // Member Functions
116         // Access
118             const labelList& faceLabels() const
119             {
120                 return faceLabels_;
121             }
123             const primitiveMesh& mesh() const
124             {
125                 return mesh_;
126             }
128             label size() const
129             {
130                 return faceLabels_.size();
131             }
133             //- Get representative point cloud for all shapes inside
134             //  (one point per shape)
135             pointField points() const;
138         // Search
140             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
141             //  Only makes sense for closed surfaces.
142             label getVolumeType
143             (
144                 const indexedOctree<treeDataFace>&,
145                 const point&
146             ) const;
148             //- Does (bb of) shape at index overlap bb
149             bool overlaps
150             (
151                 const label index,
152                 const treeBoundBox& sampleBb
153             ) const;
155             //- Calculates nearest (to sample) point in shape.
156             //  Returns actual point and distance (squared)
157             void findNearest
158             (
159                 const labelList& indices,
160                 const point& sample,
162                 scalar& nearestDistSqr,
163                 label& nearestIndex,
164                 point& nearestPoint
165             ) const;
167             //- Calculates nearest (to line) point in shape.
168             //  Returns point and distance (squared)
169             void findNearest
170             (
171                 const labelList& indices,
172                 const linePointRef& ln,
174                 treeBoundBox& tightest,
175                 label& minIndex,
176                 point& linePoint,
177                 point& nearestPoint
178             ) const
179             {
180                 notImplemented
181                 (
182                     "treeDataFace::findNearest"
183                     "(const labelList&, const linePointRef&, ..)"
184                 );
185             }
187             //- Calculate intersection of shape with ray. Sets result
188             //  accordingly
189             bool intersects
190             (
191                 const label index,
192                 const point& start,
193                 const point& end,
194                 point& result
195             ) const;
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 } // End namespace Foam
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 #endif
209 // ************************************************************************* //