Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / meshTools / indexedOctree / treeDataFace.H
blobce4e846d643df83a7d347d46ef0f9ba8371ccb9f
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::treeDataFace
28 Description
29     Encapsulation of data needed to search for faces.
31 SourceFiles
32     treeDataFace.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef treeDataFace_H
37 #define treeDataFace_H
39 #include "face.H"
40 #include "indexedOctree.H"
41 #include "treeBoundBoxList.H"
42 #include "PackedBoolList.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 // Forward declaration of classes
50 class primitiveMesh;
51 //template<class Type> class indexedOctree;
52 class polyPatch;
54 /*---------------------------------------------------------------------------*\
55                            Class treeDataFace Declaration
56 \*---------------------------------------------------------------------------*/
58 class treeDataFace
60     // Static data
62         //- tolerance on linear dimensions
63         static scalar tolSqr;
67     // Private data
69         const primitiveMesh& mesh_;
71         //- Subset of faces to work on
72         const labelList faceLabels_;
74         //- Inverse of faceLabels. For every mesh whether face is in faceLabels.
75         PackedBoolList isTreeFace_;
77         //- Whether to precalculate and store face bounding box
78         const bool cacheBb_;
80         //- face bounding boxes (valid only if cacheBb_)
81         treeBoundBoxList bbs_;
84     // Private Member Functions
86         //- Calculate face bounding box
87         treeBoundBox calcBb(const label cellI) const;
89         //- Initialise all member data
90         void update();
92 public:
94     // Declare name of the class and its debug switch
95     ClassName("treeDataFace");
98     // Constructors
100         //- Construct from mesh and subset of faces.
101         treeDataFace
102         (
103             const bool cacheBb,
104             const primitiveMesh&,
105             const labelList&
106         );
108         //- Construct from mesh. Uses all faces in mesh.
109         treeDataFace(const bool cacheBb, const primitiveMesh&);
111         //- Construct from mesh. Uses all faces in patch.
112         treeDataFace(const bool cacheBb, const polyPatch&);
115     // Member Functions
117         // Access
119             const labelList& faceLabels() const
120             {
121                 return faceLabels_;
122             }
124             const primitiveMesh& mesh() const
125             {
126                 return mesh_;
127             }
129             label size() const
130             {
131                 return faceLabels_.size();
132             }
134             //- Get representative point cloud for all shapes inside
135             //  (one point per shape)
136             pointField points() const;
139         // Search
141             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
142             //  Only makes sense for closed surfaces.
143             label getVolumeType
144             (
145                 const indexedOctree<treeDataFace>&,
146                 const point&
147             ) const;
149             //- Does (bb of) shape at index overlap bb
150             bool overlaps
151             (
152                 const label index,
153                 const treeBoundBox& sampleBb
154             ) const;
156             //- Calculates nearest (to sample) point in shape.
157             //  Returns actual point and distance (squared)
158             void findNearest
159             (
160                 const labelList& indices,
161                 const point& sample,
163                 scalar& nearestDistSqr,
164                 label& nearestIndex,
165                 point& nearestPoint
166             ) const;
168             //- Calculates nearest (to line) point in shape.
169             //  Returns point and distance (squared)
170             void findNearest
171             (
172                 const labelList& indices,
173                 const linePointRef& ln,
175                 treeBoundBox& tightest,
176                 label& minIndex,
177                 point& linePoint,
178                 point& nearestPoint
179             ) const
180             {
181                 notImplemented
182                 (
183                     "treeDataFace::findNearest"
184                     "(const labelList&, const linePointRef&, ..)"
185                 );
186             }
188             //- Calculate intersection of shape with ray. Sets result
189             //  accordingly
190             bool intersects
191             (
192                 const label index,
193                 const point& start,
194                 const point& end,
195                 point& result
196             ) const;
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 } // End namespace Foam
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 #endif
210 // ************************************************************************* //