ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / meshTools / indexedOctree / treeDataPolyMeshCell.H
blobe793dfec6c2c8fd5aa187ab0a1d4c3cd33c33c37
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::treeDataPolyMeshCell
27 Description
28     Encapsulation of data needed to search in/for cells. Used to find the
29     cell containing a point (e.g. cell-cell mapping).
31     Note: similar to treeDataCell but stores polyMesh reference so
32     can use tetDecomposition instead of pointInCell. WIP. This will probably
33     be rewritten.
35 SourceFiles
36     treeDataPolyMeshCell.C
38 \*---------------------------------------------------------------------------*/
40 #ifndef treeDataPolyMeshCell_H
41 #define treeDataPolyMeshCell_H
43 #include "treeBoundBoxList.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 // Forward declaration of classes
51 class polyMesh;
52 template<class Type> class indexedOctree;
54 /*---------------------------------------------------------------------------*\
55                         Class treeDataPolyMeshCell Declaration
56 \*---------------------------------------------------------------------------*/
58 class treeDataPolyMeshCell
60     // Private data
62         const polyMesh& mesh_;
64         //- Subset of cells to work on
65         const labelList cellLabels_;
67         //- Whether to precalculate and store cell bounding box
68         const bool cacheBb_;
70         //- cell bounding boxes (valid only if cacheBb_)
71         treeBoundBoxList bbs_;
74     // Private Member Functions
76         //- Calculate cell bounding box
77         treeBoundBox calcCellBb(const label cellI) const;
79         //- Initialise all member data
80         void update();
82 public:
84     // Declare name of the class and its debug switch
85     ClassName("treeDataPolyMeshCell");
88     // Constructors
90         //- Construct from mesh and subset of cells.
91         treeDataPolyMeshCell
92         (
93             const bool cacheBb,
94             const polyMesh&,
95             const labelUList&
96         );
98         //- Construct from mesh and subset of cells, transferring contents
99         treeDataPolyMeshCell
100         (
101             const bool cacheBb,
102             const polyMesh&,
103             const Xfer<labelList>&
104         );
106         //- Construct from mesh. Uses all cells in mesh.
107         treeDataPolyMeshCell(const bool cacheBb, const polyMesh&);
110     // Member Functions
112         // Access
114             inline const labelList& cellLabels() const
115             {
116                 return cellLabels_;
117             }
119             inline const polyMesh& mesh() const
120             {
121                 return mesh_;
122             }
125             inline label size() const
126             {
127                 return cellLabels_.size();
128             }
130             //- Get representative point cloud for all shapes inside
131             //  (one point per shape)
132             pointField shapePoints() const;
135         // Search
137             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
138             //  Only makes sense for closed surfaces.
139             label getVolumeType
140             (
141                 const indexedOctree<treeDataPolyMeshCell>&,
142                 const point&
143             ) const
144             {
145                 notImplemented
146                 (
147                     "treeDataPolyMeshCell::getVolumeType"
148                     "(const indexedOctree<treeDataPolyMeshCell>&, const point&)"
149                 );
150                 return -1;
151             }
153             //- Does (bb of) shape at index overlap bb
154             bool overlaps
155             (
156                 const label index,
157                 const treeBoundBox& sampleBb
158             ) const;
160             //- Does shape at index contain sample
161             bool contains
162             (
163                 const label index,
164                 const point& sample
165             ) const;
167             //- Calculates nearest (to sample) point in shape.
168             //  Returns actual point and distance (squared)
169             void findNearest
170             (
171                 const labelUList& indices,
172                 const point& sample,
174                 scalar& nearestDistSqr,
175                 label& nearestIndex,
176                 point& nearestPoint
177             ) const;
179             //- Calculates nearest (to line) point in shape.
180             //  Returns point and distance (squared)
181             void findNearest
182             (
183                 const labelUList& indices,
184                 const linePointRef& ln,
186                 treeBoundBox& tightest,
187                 label& minIndex,
188                 point& linePoint,
189                 point& nearestPoint
190             ) const
191             {
192                 notImplemented
193                 (
194                     "treeDataPolyMeshCell::findNearest"
195                     "(const labelUList&, const linePointRef&, ..)"
196                 );
197             }
199             //- Calculate intersection of shape with ray. Sets result
200             //  accordingly
201             bool intersects
202             (
203                 const label index,
204                 const point& start,
205                 const point& end,
206                 point& result
207             ) const;
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 } // End namespace Foam
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 #endif
221 // ************************************************************************* //