fix face direction
[OpenFOAM-1.5.x.git] / src / meshTools / indexedOctree / treeDataCell.H
blob1cb15db6fe9a8f37f6ca752427513fb3ff06bd50
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
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::treeDataCell
28 Description
29     Encapsulation of data needed to search in/for cells. Used to find the
30     cell containing a point (e.g. cell-cell mapping).
32 SourceFiles
33     treeDataCell.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef treeDataCell_H
38 #define treeDataCell_H
40 #include "treeBoundBox.H"
41 #include "treeBoundBoxList.H"
42 #include "labelList.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 // Forward declaration of classes
50 class polyMesh;
51 template<class Type> class indexedOctree;
53 /*---------------------------------------------------------------------------*\
54                            Class treeDataCell Declaration
55 \*---------------------------------------------------------------------------*/
57 class treeDataCell
59     // Private data
61         const polyMesh& mesh_;
63         //- Subset of cells to work on
64         const labelList cellLabels_;
66         //- Whether to precalculate and store cell bounding box
67         const bool cacheBb_;
69         //- cell bounding boxes (valid only if cacheBb_)
70         treeBoundBoxList bbs_;
73     // Private Member Functions
75         //- Calculate cell bounding box
76         treeBoundBox calcCellBb(const label cellI) const;
78 public:
80     // Declare name of the class and its debug switch
81     ClassName("treeDataCell");
84     // Constructors
86         //- Construct from mesh and subset of cells.
87         treeDataCell
88         (
89             const bool cacheBb,
90             const polyMesh&,
91             const labelList&
92         );
94         //- Construct from mesh. Uses all cells in mesh.
95         treeDataCell(const bool cacheBb, const polyMesh&);
98     // Member Functions
100         // Access
102             const labelList& cellLabels() const
103             {
104                 return cellLabels_;
105             }
107             const polyMesh& mesh() const
108             {
109                 return mesh_;
110             }
113             label size() const
114             {
115                 return cellLabels_.size();
116             }
118             //- Get representative point cloud for all shapes inside
119             //  (one point per shape)
120             pointField points() const;
123         // Search
125             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
126             //  Only makes sense for closed surfaces.
127             label getVolumeType
128             (
129                 const indexedOctree<treeDataCell>&,
130                 const point&
131             ) const
132             {
133                 notImplemented
134                 (
135                     "treeDataCell::getVolumeType"
136                     "(const indexedOctree<treeDataCell>&, const point&)"
137                 );
138                 return -1;
139             }
141             //- Does (bb of) shape at index overlap bb
142             bool overlaps
143             (
144                 const label index,
145                 const treeBoundBox& sampleBb
146             ) const;
148             //- Calculates nearest (to sample) point in shape.
149             //  Returns actual point and distance (squared)
150             void findNearest
151             (
152                 const labelList& indices,
153                 const point& sample,
155                 scalar& nearestDistSqr,
156                 label& nearestIndex,
157                 point& nearestPoint
158             ) const;
160             //- Calculates nearest (to line) point in shape.
161             //  Returns point and distance (squared)
162             void findNearest
163             (
164                 const labelList& indices,
165                 const linePointRef& ln,
167                 treeBoundBox& tightest,
168                 label& minIndex,
169                 point& linePoint,
170                 point& nearestPoint
171             ) const
172             {
173                 notImplemented
174                 (
175                     "treeDataCell::findNearest"
176                     "(const labelList&, const linePointRef&, ..)"
177                 );
178             }
180             //- Calculate intersection of shape with ray. Sets result
181             //  accordingly
182             bool intersects
183             (
184                 const label index,
185                 const point& start,
186                 const point& end,
187                 point& result
188             ) const;
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 } // End namespace Foam
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 #endif
202 // ************************************************************************* //