ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / meshTools / indexedOctree / treeDataPrimitivePatch.H
blob5b3193352a8f422282a6538c40e8f3e2ae521071
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::treeDataPrimitivePatch
27 Description
28     Encapsulation of data needed to search on PrimitivePatches
30 SourceFiles
31     treeDataPrimitivePatch.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef treeDataPrimitivePatch_H
36 #define treeDataPrimitivePatch_H
38 #include "PrimitivePatch.H"
39 //#include "indexedOctree.H"
40 #include "treeBoundBoxList.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 namespace Foam
47 // Forward declaration of classes
48 template<class Type> class indexedOctree;
51 /*---------------------------------------------------------------------------*\
52                  Class treeDataPrimitivePatchName Declaration
53 \*---------------------------------------------------------------------------*/
55 TemplateName(treeDataPrimitivePatch);
58 /*---------------------------------------------------------------------------*\
59                    Class treeDataPrimitivePatch Declaration
60 \*---------------------------------------------------------------------------*/
62 template
64     class Face,
65     template<class> class FaceList,
66     class PointField,
67     class PointType=point
69 class treeDataPrimitivePatch
71     public treeDataPrimitivePatchName
73     // Static data
75         //- tolerance on linear dimensions
76         static scalar tolSqr;
78     // Private data
80         //- Underlying geometry
81         const PrimitivePatch<Face, FaceList, PointField, PointType>& patch_;
83         //- Whether to precalculate and store face bounding box
84         const bool cacheBb_;
86         //- face bounding boxes (valid only if cacheBb_)
87         treeBoundBoxList bbs_;
90     // Private Member Functions
92         //- Calculate face bounding box
93         static treeBoundBox calcBb(const pointField&, const face&);
95         //- Initialise all member data
96         void update();
98 public:
100     // Constructors
102         //- Construct from patch.
103         treeDataPrimitivePatch
104         (
105             const bool cacheBb,
106             const PrimitivePatch<Face, FaceList, PointField, PointType>&
107         );
110     // Member Functions
112         // Access
114             label size() const
115             {
116                 return patch_.size();
117             }
119             //- Get representative point cloud for all shapes inside
120             //  (one point per shape)
121             pointField shapePoints() const;
124         // Search
126             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
127             //  Only makes sense for closed surfaces.
128             label getVolumeType
129             (
130                 const indexedOctree
131                 <
132                     treeDataPrimitivePatch
133                     <
134                         Face,
135                         FaceList,
136                         PointField,
137                         PointType
138                     >
139                 >&,
140                 const point&
141             ) const;
143             //- Does (bb of) shape at index overlap bb
144             bool overlaps
145             (
146                 const label index,
147                 const treeBoundBox& sampleBb
148             ) const;
150             //- Calculates nearest (to sample) point in shape.
151             //  Returns actual point and distance (squared)
152             void findNearest
153             (
154                 const labelUList& indices,
155                 const point& sample,
157                 scalar& nearestDistSqr,
158                 label& nearestIndex,
159                 point& nearestPoint
160             ) const;
162             //- Calculates nearest (to line) point in shape.
163             //  Returns point and distance (squared)
164             void findNearest
165             (
166                 const labelUList& indices,
167                 const linePointRef& ln,
169                 treeBoundBox& tightest,
170                 label& minIndex,
171                 point& linePoint,
172                 point& nearestPoint
173             ) const
174             {
175                 notImplemented
176                 (
177                     "treeDataPrimitivePatch::findNearest"
178                     "(const labelUList&, const linePointRef&, ..)"
179                 );
180             }
182             //- Calculate intersection of shape with ray. Sets result
183             //  accordingly
184             bool intersects
185             (
186                 const label index,
187                 const point& start,
188                 const point& end,
189                 point& result
190             ) const;
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 } // End namespace Foam
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 #ifdef NoRepository
202 #   include "treeDataPrimitivePatch.C"
203 #endif
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 #endif
209 // ************************************************************************* //