ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / meshTools / octree / octreeDataCell.H
blobf39ad2c3cc27c76fada1d52c4f2060d39aa9359a
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::octreeDataCell
27 Description
28     Encapsulation of data needed to search in/for cells.
30     Used to find the cell containing a point (e.g. cell-cell mapping).
32 SourceFiles
33     octreeDataCell.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef octreeDataCell_H
38 #define octreeDataCell_H
40 #include "treeBoundBoxList.H"
41 #include "labelList.H"
42 #include "linePointRef.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 // Forward declaration of classes
50 class polyMesh;
51 template<class Type> class octree;
53 /*---------------------------------------------------------------------------*\
54                        Class octreeDataCell Declaration
55 \*---------------------------------------------------------------------------*/
57 class octreeDataCell
59     // Private data
61         const polyMesh& mesh_;
63         labelList cellLabels_;
65         treeBoundBoxList bbs_;
68 public:
70     // Constructors
72         //- Construct from components.
73         octreeDataCell
74         (
75             const polyMesh&,
76             const labelList& cellLabels,
77             const treeBoundBoxList& bbs
78         );
80         //- Construct from mesh. Uses all cells in mesh.
81         octreeDataCell(const polyMesh&);
84     // Member Functions
86         // Access
88             const labelList& cellLabels() const
89             {
90                 return cellLabels_;
91             }
93             const polyMesh& mesh() const
94             {
95                 return mesh_;
96             }
98             const treeBoundBoxList& allBb() const
99             {
100                 return bbs_;
101             }
103             label size() const
104             {
105                 return bbs_.size();
106             }
108         // Search
110             //- Get type of sample
111             label getSampleType(octree<octreeDataCell>&, const point&) const;
113             //- Does (bb of) shape at index overlap bb
114             bool overlaps
115             (
116                 const label index,
117                 const treeBoundBox& sampleBb
118             ) const;
120             //- Does shape at index contain sample
121             bool contains
122             (
123                 const label index,
124                 const point& sample
125             ) const;
127             //- Segment (from start to end) intersection with shape
128             //  at index. If intersects returns true and sets intersectionPoint
129             // BUG: not yet done.
130             bool intersects
131             (
132                 const label index,
133                 const point& start,
134                 const point& end,
135                 point& intersectionPoint
136             ) const;
138             //- Sets newTightest to bounding box (and returns true) if
139             //  nearer to sample than tightest bounding box. Otherwise
140             //  returns false
141             bool findTightest
142             (
143                 const label index,
144                 const point& sample,
145                 treeBoundBox& tightest
146             ) const;
148             //- Given index get unit normal and calculate (numerical) sign
149             //  of sample.
150             //  Used to determine accuracy of calcNearest or inside/outside.
151             //  Note: always returns GREAT since no inside/outside.
152             scalar calcSign
153             (
154                 const label index,
155                 const point& sample,
156                 vector& n
157             ) const;
159             //- Calculates nearest (to sample) point in shape.
160             //  Returns point and mag(nearest - sample)
161             scalar calcNearest
162             (
163                 const Foam::label index,
164                 const Foam::point& sample,
165                 point& nearest
166             ) const;
168             //- Calculates nearest (to line segment) point in shape.
169             //  Returns distance and both point.
170             scalar calcNearest
171             (
172                 const label index,
173                 const linePointRef& ln,
174                 point& linePt,          // nearest point on line
175                 point& shapePt          // nearest point on shape
176             ) const;
180         // Write
182             // Write shape at index
183             void write(Ostream& os, const label index) const;
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 } // End namespace Foam
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 #endif
196 // ************************************************************************* //