BUGFIX: Illegal use of uninitialised value (backport)
[foam-extend-3.2.git] / applications / utilities / surface / surfaceToPatch / treeDataPrimitivePatch.H
blob0928b97cd8d73f2d9a3f0185c51ed65020b43d18
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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::treeDataPrimitivePatch
28 Description
29     Encapsulation of data needed to search on PrimitivePatches
31 SourceFiles
32     treeDataPrimitivePatch.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef treeDataPrimitivePatch_H
37 #define treeDataPrimitivePatch_H
39 #include "PrimitivePatch.H"
40 //#include "indexedOctree.H"
41 #include "treeBoundBoxList.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 // Forward declaration of classes
49 template<class Type> class indexedOctree;
52 /*---------------------------------------------------------------------------*\
53                  Class treeDataPrimitivePatchName Declaration
54 \*---------------------------------------------------------------------------*/
56 TemplateName(treeDataPrimitivePatch);
59 /*---------------------------------------------------------------------------*\
60                            Class treeDataPrimitivePatch Declaration
61 \*---------------------------------------------------------------------------*/
63 template
65     class Face,
66     template<class> class FaceList,
67     class PointField,
68     class PointType=point
70 class treeDataPrimitivePatch
72     public treeDataPrimitivePatchName
74     // Static data
76         //- tolerance on linear dimensions
77         static scalar tolSqr;
79     // Private data
81         //- Underlying geometry
82         const PrimitivePatch<Face, FaceList, PointField, PointType>& patch_;
84         //- Whether to precalculate and store face bounding box
85         const bool cacheBb_;
87         //- face bounding boxes (valid only if cacheBb_)
88         treeBoundBoxList bbs_;
91     // Private Member Functions
93         //- Calculate face bounding box
94         static treeBoundBox calcBb(const pointField&, const face&);
96         //- Initialise all member data
97         void update();
99 public:
101     // Constructors
103         //- Construct from patch.
104         treeDataPrimitivePatch
105         (
106             const bool cacheBb,
107             const PrimitivePatch<Face, FaceList, PointField, PointType>&
108         );
111     // Member Functions
113         // Access
115             label size() const
116             {
117                 return patch_.size();
118             }
120             //- Get representative point cloud for all shapes inside
121             //  (one point per shape)
122             pointField points() const;
125         // Search
127             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
128             //  Only makes sense for closed surfaces.
129             label getVolumeType
130             (
131                 const indexedOctree
132                 <
133                     treeDataPrimitivePatch
134                     <
135                         Face,
136                         FaceList,
137                         PointField,
138                         PointType
139                     >
140                 >&,
141                 const point&
142             ) const;
144             //- Does (bb of) shape at index overlap bb
145             bool overlaps
146             (
147                 const label index,
148                 const treeBoundBox& sampleBb
149             ) const;
151             //- Calculates nearest (to sample) point in shape.
152             //  Returns actual point and distance (squared)
153             void findNearest
154             (
155                 const labelList& indices,
156                 const point& sample,
158                 scalar& nearestDistSqr,
159                 label& nearestIndex,
160                 point& nearestPoint
161             ) const;
163             //- Calculates nearest (to line) point in shape.
164             //  Returns point and distance (squared)
165             void findNearest
166             (
167                 const labelList& indices,
168                 const linePointRef& ln,
170                 treeBoundBox& tightest,
171                 label& minIndex,
172                 point& linePoint,
173                 point& nearestPoint
174             ) const
175             {
176                 notImplemented
177                 (
178                     "treeDataPrimitivePatch::findNearest"
179                     "(const labelList&, const linePointRef&, ..)"
180                 );
181             }
183             //- Calculate intersection of shape with ray. Sets result
184             //  accordingly
185             bool intersects
186             (
187                 const label index,
188                 const point& start,
189                 const point& end,
190                 point& result
191             ) const;
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 } // End namespace Foam
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 #ifdef NoRepository
203 #   include "treeDataPrimitivePatch.C"
204 #endif
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 #endif
210 // ************************************************************************* //