Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / meshTools / searchableSurface / searchableBox.H
blobfc877df2e637208a2258f8b6014f7b680e57a8ce
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::searchableBox
27 Description
28     Searching on bounding box
30 SourceFiles
31     searchableBox.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef searchableBox_H
36 #define searchableBox_H
38 #include "searchableSurface.H"
39 #include "treeBoundBox.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 // Forward declaration of classes
48 /*---------------------------------------------------------------------------*\
49                            Class searchableBox Declaration
50 \*---------------------------------------------------------------------------*/
52 class searchableBox
54     public searchableSurface,
55     public treeBoundBox
57 private:
59     // Private Member Data
61         mutable wordList regions_;
64     // Private Member Functions
66         //- Project onto component dir of planePt and update index() (=face)
67         void projectOntoCoordPlane
68         (
69             const direction dir,
70             const point& planePt,
71             pointIndexHit& info
72         ) const;
74         //- Returns miss or hit with face (0..5)
75         pointIndexHit findNearest
76         (
77             const point& bbMid,
78             const point& sample,
79             const scalar nearestDistSqr
80         ) const;
83         //- Disallow default bitwise copy construct
84         searchableBox(const searchableBox&);
86         //- Disallow default bitwise assignment
87         void operator=(const searchableBox&);
90 public:
92     //- Runtime type information
93     TypeName("searchableBox");
96     // Constructors
98         //- Construct from components
99         searchableBox(const IOobject& io, const treeBoundBox& bb);
101         //- Construct from dictionary (used by searchableSurface)
102         searchableBox
103         (
104             const IOobject& io,
105             const dictionary& dict
106         );
108     // Destructor
110         virtual ~searchableBox();
113     // Member Functions
115         virtual const wordList& regions() const;
117         //- Whether supports volume type below
118         virtual bool hasVolumeType() const
119         {
120             return true;
121         }
123         //- Range of local indices that can be returned.
124         virtual label size() const
125         {
126             return 6;
127         }
129         //- Get representative set of element coordinates
130         //  Usually the element centres (should be of length size()).
131         virtual pointField coordinates() const;
133         // Single point queries.
135             //- Calculate nearest point on surface. Returns
136             //  - bool : any point found nearer than nearestDistSqr
137             //  - label: relevant index in surface (=face 0..5)
138             //  - point: actual nearest point found
139             pointIndexHit findNearest
140             (
141                 const point& sample,
142                 const scalar nearestDistSqr
143             ) const;
145             //- Calculate nearest point on edge. Returns
146             //  - bool : any point found nearer than nearestDistSqr
147             //  - label: relevant index in surface(=?)
148             //  - point: actual nearest point found
149             pointIndexHit findNearestOnEdge
150             (
151                 const point& sample,
152                 const scalar nearestDistSqr
153             ) const;
155             //- Find nearest to segment. Returns
156             //  - bool : any point found?
157             //  - label: relevant index in shapes (=face 0..5)
158             //  - point: actual nearest point found
159             //  sets:
160             //  - tightest  : bounding box
161             //  - linePoint : corresponding nearest point on line
162             pointIndexHit findNearest
163             (
164                 const linePointRef& ln,
165                 treeBoundBox& tightest,
166                 point& linePoint
167             ) const;
169             //- Find nearest intersection of line between start and end.
170             pointIndexHit findLine
171             (
172                 const point& start,
173                 const point& end
174             ) const;
176             //- Find any intersection of line between start and end.
177             pointIndexHit findLineAny
178             (
179                 const point& start,
180                 const point& end
181             ) const;
184         // Multiple point queries.
186             virtual void findNearest
187             (
188                 const pointField& sample,
189                 const scalarField& nearestDistSqr,
190                 List<pointIndexHit>&
191             ) const;
193             virtual void findLine
194             (
195                 const pointField& start,
196                 const pointField& end,
197                 List<pointIndexHit>&
198             ) const;
200             virtual void findLineAny
201             (
202                 const pointField& start,
203                 const pointField& end,
204                 List<pointIndexHit>&
205             ) const;
207             //- Get all intersections in order from start to end.
208             virtual void findLineAll
209             (
210                 const pointField& start,
211                 const pointField& end,
212                 List<List<pointIndexHit> >&
213             ) const;
215             //- From a set of points and indices get the region
216             virtual void getRegion
217             (
218                 const List<pointIndexHit>&,
219                 labelList& region
220             ) const;
222             //- From a set of points and indices get the normal
223             virtual void getNormal
224             (
225                 const List<pointIndexHit>&,
226                 vectorField& normal
227             ) const;
229             //- Determine type (inside/outside/mixed) for point. unknown if
230             //  cannot be determined (e.g. non-manifold surface)
231             virtual void getVolumeType
232             (
233                 const pointField&,
234                 List<volumeType>&
235             ) const;
238         // regIOobject implementation
240             bool writeData(Ostream&) const
241             {
242                 notImplemented("searchableBox::writeData(Ostream&) const");
243                 return false;
244             }
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 } // End namespace Foam
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 #endif
257 // ************************************************************************* //