Formatting
[foam-extend-3.2.git] / src / foam / algorithms / octree / indexedOctree / treeDataCell.H
blobd60fd6808e7571c7d08a9e07e7d0d0173b119ee0
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::treeDataCell
27 Description
28     Encapsulation of data needed to search in/for cells. Used to find the
29     cell containing a point (e.g. cell-cell mapping).
31 SourceFiles
32     treeDataCell.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef treeDataCell_H
37 #define treeDataCell_H
39 #include "treeBoundBoxList.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 // Forward declaration of classes
47 class primitiveMesh;
48 template<class Type> class indexedOctree;
50 /*---------------------------------------------------------------------------*\
51                            Class treeDataCell Declaration
52 \*---------------------------------------------------------------------------*/
54 class treeDataCell
56     // Private data
58         const primitiveMesh& mesh_;
60         //- Subset of cells to work on
61         const labelList cellLabels_;
63         //- Whether to precalculate and store cell bounding box
64         const bool cacheBb_;
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 public:
77     // Declare name of the class and its debug switch
78     ClassName("treeDataCell");
81     // Constructors
83         //- Construct from mesh and subset of cells.
84         treeDataCell
85         (
86             const bool cacheBb,
87             const primitiveMesh&,
88             const labelList&
89         );
91         //- Construct from mesh. Uses all cells in mesh.
92         treeDataCell(const bool cacheBb, const primitiveMesh&);
95     // Member Functions
97         // Access
99             const labelList& cellLabels() const
100             {
101                 return cellLabels_;
102             }
104             const primitiveMesh& mesh() const
105             {
106                 return mesh_;
107             }
110             label size() const
111             {
112                 return cellLabels_.size();
113             }
115             //- Get representative point cloud for all shapes inside
116             //  (one point per shape)
117             pointField points() const;
120         // Search
122             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface
123             //  Only makes sense for closed surfaces
124             label getVolumeType
125             (
126                 const indexedOctree<treeDataCell>&,
127                 const point&
128             ) const
129             {
130                 notImplemented
131                 (
132                     "treeDataCell::getVolumeType"
133                     "(const indexedOctree<treeDataCell>&, const point&)"
134                 );
135                 return -1;
136             }
138             //- Does (bb of) shape at index overlap bb
139             bool overlaps
140             (
141                 const label index,
142                 const treeBoundBox& sampleBb
143             ) const;
145             //- Calculates nearest (to sample) point in shape.
146             //  Returns actual point and distance (squared)
147             void findNearest
148             (
149                 const labelList& indices,
150                 const point& sample,
152                 scalar& nearestDistSqr,
153                 label& nearestIndex,
154                 point& nearestPoint
155             ) const;
157             //- Calculates nearest (to line) point in shape.
158             //  Returns point and distance (squared)
159             void findNearest
160             (
161                 const labelList& indices,
162                 const linePointRef& ln,
164                 treeBoundBox& tightest,
165                 label& minIndex,
166                 point& linePoint,
167                 point& nearestPoint
168             ) const
169             {
170                 notImplemented
171                 (
172                     "treeDataCell::findNearest"
173                     "(const labelList&, const linePointRef&, ..)"
174                 );
175             }
177             //- Calculate intersection of shape with ray. Sets result
178             //  accordingly
179             bool intersects
180             (
181                 const label index,
182                 const point& start,
183                 const point& end,
184                 point& result
185             ) const;
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 } // End namespace Foam
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 #endif
199 // ************************************************************************* //