named regIOobject for dictionary
[OpenFOAM-1.6.x.git] / src / meshTools / indexedOctree / treeDataCell.H
blob100dcb62cf7659a852daf95532ec31f0e3bfde4a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 "treeBoundBoxList.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 namespace Foam
47 // Forward declaration of classes
48 class primitiveMesh;
49 template<class Type> class indexedOctree;
51 /*---------------------------------------------------------------------------*\
52                            Class treeDataCell Declaration
53 \*---------------------------------------------------------------------------*/
55 class treeDataCell
57     // Private data
59         const primitiveMesh& mesh_;
61         //- Subset of cells to work on
62         const labelList cellLabels_;
64         //- Whether to precalculate and store cell bounding box
65         const bool cacheBb_;
67         //- cell bounding boxes (valid only if cacheBb_)
68         treeBoundBoxList bbs_;
71     // Private Member Functions
73         //- Calculate cell bounding box
74         treeBoundBox calcCellBb(const label cellI) const;
76 public:
78     // Declare name of the class and its debug switch
79     ClassName("treeDataCell");
82     // Constructors
84         //- Construct from mesh and subset of cells.
85         treeDataCell
86         (
87             const bool cacheBb,
88             const primitiveMesh&,
89             const labelList&
90         );
92         //- Construct from mesh. Uses all cells in mesh.
93         treeDataCell(const bool cacheBb, const primitiveMesh&);
96     // Member Functions
98         // Access
100             const labelList& cellLabels() const
101             {
102                 return cellLabels_;
103             }
105             const primitiveMesh& mesh() const
106             {
107                 return mesh_;
108             }
111             label size() const
112             {
113                 return cellLabels_.size();
114             }
116             //- Get representative point cloud for all shapes inside
117             //  (one point per shape)
118             pointField points() const;
121         // Search
123             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
124             //  Only makes sense for closed surfaces.
125             label getVolumeType
126             (
127                 const indexedOctree<treeDataCell>&,
128                 const point&
129             ) const
130             {
131                 notImplemented
132                 (
133                     "treeDataCell::getVolumeType"
134                     "(const indexedOctree<treeDataCell>&, const point&)"
135                 );
136                 return -1;
137             }
139             //- Does (bb of) shape at index overlap bb
140             bool overlaps
141             (
142                 const label index,
143                 const treeBoundBox& sampleBb
144             ) const;
146             //- Calculates nearest (to sample) point in shape.
147             //  Returns actual point and distance (squared)
148             void findNearest
149             (
150                 const labelList& indices,
151                 const point& sample,
153                 scalar& nearestDistSqr,
154                 label& nearestIndex,
155                 point& nearestPoint
156             ) const;
158             //- Calculates nearest (to line) point in shape.
159             //  Returns point and distance (squared)
160             void findNearest
161             (
162                 const labelList& indices,
163                 const linePointRef& ln,
165                 treeBoundBox& tightest,
166                 label& minIndex,
167                 point& linePoint,
168                 point& nearestPoint
169             ) const
170             {
171                 notImplemented
172                 (
173                     "treeDataCell::findNearest"
174                     "(const labelList&, const linePointRef&, ..)"
175                 );
176             }
178             //- Calculate intersection of shape with ray. Sets result
179             //  accordingly
180             bool intersects
181             (
182                 const label index,
183                 const point& start,
184                 const point& end,
185                 point& result
186             ) const;
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 } // End namespace Foam
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 #endif
200 // ************************************************************************* //