1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
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/>.
28 Encapsulation of data needed to search in/for cells.
30 Used to find the cell containing a point (e.g. cell-cell mapping).
35 \*---------------------------------------------------------------------------*/
37 #ifndef octreeDataCell_H
38 #define octreeDataCell_H
40 #include "treeBoundBoxList.H"
41 #include "labelList.H"
42 #include "linePointRef.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 // Forward declaration of classes
51 template<class Type> class octree;
53 /*---------------------------------------------------------------------------*\
54 Class octreeDataCell Declaration
55 \*---------------------------------------------------------------------------*/
61 const polyMesh& mesh_;
63 labelList cellLabels_;
65 treeBoundBoxList bbs_;
72 //- Construct from components.
76 const labelList& cellLabels,
77 const treeBoundBoxList& bbs
80 //- Construct from mesh. Uses all cells in mesh.
81 octreeDataCell(const polyMesh&);
88 const labelList& cellLabels() const
93 const polyMesh& mesh() const
98 const treeBoundBoxList& allBb() const
110 //- Get type of sample
111 label getSampleType(octree<octreeDataCell>&, const point&) const;
113 //- Does (bb of) shape at index overlap bb
117 const treeBoundBox& sampleBb
120 //- Does shape at index contain sample
127 //- Segment (from start to end) intersection with shape
128 // at index. If intersects returns true and sets intersectionPoint
129 // BUG: not yet done.
135 point& intersectionPoint
138 //- Sets newTightest to bounding box (and returns true) if
139 // nearer to sample than tightest bounding box. Otherwise
145 treeBoundBox& tightest
148 //- Given index get unit normal and calculate (numerical) sign
150 // Used to determine accuracy of calcNearest or inside/outside.
151 // Note: always returns GREAT since no inside/outside.
159 //- Calculates nearest (to sample) point in shape.
160 // Returns point and mag(nearest - sample)
163 const Foam::label index,
164 const Foam::point& sample,
168 //- Calculates nearest (to line segment) point in shape.
169 // Returns distance and both point.
173 const linePointRef& ln,
174 point& linePt, // nearest point on line
175 point& shapePt // nearest point on shape
182 // Write shape at index
183 void write(Ostream& os, const label index) const;
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 } // End namespace Foam
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 // ************************************************************************* //