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. Used to find the
29 cell containing a point (e.g. cell-cell mapping).
34 \*---------------------------------------------------------------------------*/
36 #ifndef treeDataCell_H
37 #define treeDataCell_H
39 #include "treeBoundBoxList.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 // Forward declaration of classes
48 template<class Type> class indexedOctree;
50 /*---------------------------------------------------------------------------*\
51 Class treeDataCell Declaration
52 \*---------------------------------------------------------------------------*/
58 const primitiveMesh& mesh_;
60 //- Subset of cells to work on
61 const labelList cellLabels_;
63 //- Whether to precalculate and store cell bounding box
66 //- cell bounding boxes (valid only if cacheBb_)
67 treeBoundBoxList bbs_;
70 // Private Member Functions
72 //- Calculate cell bounding box
73 treeBoundBox calcCellBb(const label cellI) const;
75 //- Initialise all member data
80 // Declare name of the class and its debug switch
81 ClassName("treeDataCell");
86 //- Construct from mesh and subset of cells.
94 //- Construct from mesh and subset of cells, transferring contents
99 const Xfer<labelList>&
102 //- Construct from mesh. Uses all cells in mesh.
103 treeDataCell(const bool cacheBb, const primitiveMesh&);
110 inline const labelList& cellLabels() const
115 inline const primitiveMesh& mesh() const
121 inline label size() const
123 return cellLabels_.size();
126 //- Get representative point cloud for all shapes inside
127 // (one point per shape)
128 pointField shapePoints() const;
133 //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
134 // Only makes sense for closed surfaces.
137 const indexedOctree<treeDataCell>&,
143 "treeDataCell::getVolumeType"
144 "(const indexedOctree<treeDataCell>&, const point&)"
149 //- Does (bb of) shape at index overlap bb
153 const treeBoundBox& sampleBb
156 //- Does shape at index contain sample
163 //- Calculates nearest (to sample) point in shape.
164 // Returns actual point and distance (squared)
167 const labelUList& indices,
170 scalar& nearestDistSqr,
175 //- Calculates nearest (to line) point in shape.
176 // Returns point and distance (squared)
179 const labelUList& indices,
180 const linePointRef& ln,
182 treeBoundBox& tightest,
190 "treeDataCell::findNearest"
191 "(const labelUList&, const linePointRef&, ..)"
195 //- Calculate intersection of shape with ray. Sets result
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 } // End namespace Foam
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 // ************************************************************************* //