BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / OpenFOAM / algorithms / indexedOctree / treeDataCell.H
blob62bf4b4a4f86559191a183d865ffccef22d6f988
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
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
19     for more details.
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/>.
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         //- Initialise all member data
76         void update();
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 primitiveMesh&,
91             const labelUList&
92         );
94         //- Construct from mesh and subset of cells, transferring contents
95         treeDataCell
96         (
97             const bool cacheBb,
98             const primitiveMesh&,
99             const Xfer<labelList>&
100         );
102         //- Construct from mesh. Uses all cells in mesh.
103         treeDataCell(const bool cacheBb, const primitiveMesh&);
106     // Member Functions
108         // Access
110             inline const labelList& cellLabels() const
111             {
112                 return cellLabels_;
113             }
115             inline const primitiveMesh& mesh() const
116             {
117                 return mesh_;
118             }
121             inline label size() const
122             {
123                 return cellLabels_.size();
124             }
126             //- Get representative point cloud for all shapes inside
127             //  (one point per shape)
128             pointField shapePoints() const;
131         // Search
133             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
134             //  Only makes sense for closed surfaces.
135             label getVolumeType
136             (
137                 const indexedOctree<treeDataCell>&,
138                 const point&
139             ) const
140             {
141                 notImplemented
142                 (
143                     "treeDataCell::getVolumeType"
144                     "(const indexedOctree<treeDataCell>&, const point&)"
145                 );
146                 return -1;
147             }
149             //- Does (bb of) shape at index overlap bb
150             bool overlaps
151             (
152                 const label index,
153                 const treeBoundBox& sampleBb
154             ) const;
156             //- Does shape at index contain sample
157             bool contains
158             (
159                 const label index,
160                 const point& sample
161             ) const;
163             //- Calculates nearest (to sample) point in shape.
164             //  Returns actual point and distance (squared)
165             void findNearest
166             (
167                 const labelUList& indices,
168                 const point& sample,
170                 scalar& nearestDistSqr,
171                 label& nearestIndex,
172                 point& nearestPoint
173             ) const;
175             //- Calculates nearest (to line) point in shape.
176             //  Returns point and distance (squared)
177             void findNearest
178             (
179                 const labelUList& indices,
180                 const linePointRef& ln,
182                 treeBoundBox& tightest,
183                 label& minIndex,
184                 point& linePoint,
185                 point& nearestPoint
186             ) const
187             {
188                 notImplemented
189                 (
190                     "treeDataCell::findNearest"
191                     "(const labelUList&, const linePointRef&, ..)"
192                 );
193             }
195             //- Calculate intersection of shape with ray. Sets result
196             //  accordingly
197             bool intersects
198             (
199                 const label index,
200                 const point& start,
201                 const point& end,
202                 point& result
203             ) const;
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 } // End namespace Foam
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 #endif
217 // ************************************************************************* //