Forward compatibility: flex
[foam-extend-3.2.git] / src / meshTools / searchableSurface / searchableSphere.H
blob83d23666439f4beb5ea8a30814f18af7b1cf142f
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::searchableSphere
27 Description
28     Searching on sphere
30 SourceFiles
31     searchableSphere.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef searchableSphere_H
36 #define searchableSphere_H
38 #include "treeBoundBox.H"
39 #include "searchableSurface.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 // Forward declaration of classes
48 /*---------------------------------------------------------------------------*\
49                            Class searchableSphere Declaration
50 \*---------------------------------------------------------------------------*/
52 class searchableSphere
54     public searchableSurface
56 private:
58     // Private Member Data
60         //- Centre point
61         const point centre_;
63         //- Radius squared
64         const scalar radius_;
66         //- Names of regions
67         mutable wordList regions_;
70     // Private Member Functions
72         //- Find nearest point on sphere.
73         pointIndexHit findNearest
74         (
75             const point& sample,
76             const scalar nearestDistSqr
77         ) const;
79         //- Find intersection with sphere
80         void findLineAll
81         (
82             const point& start,
83             const point& end,
84             pointIndexHit& near,
85             pointIndexHit& far
86         ) const;
89         //- Disallow default bitwise copy construct
90         searchableSphere(const searchableSphere&);
92         //- Disallow default bitwise assignment
93         void operator=(const searchableSphere&);
96 public:
98     //- Runtime type information
99     TypeName("searchableSphere");
102     // Constructors
104         //- Construct from components
105         searchableSphere(const IOobject& io, const point&, const scalar radius);
107         //- Construct from dictionary (used by searchableSurface)
108         searchableSphere
109         (
110             const IOobject& io,
111             const dictionary& dict
112         );
114     // Destructor
116         virtual ~searchableSphere();
119     // Member Functions
121         virtual const wordList& regions() const;
123         //- Whether supports volume type below
124         virtual bool hasVolumeType() const
125         {
126             return true;
127         }
129         //- Range of local indices that can be returned.
130         virtual label size() const
131         {
132             return 1;
133         }
135         //- Get representative set of element coordinates
136         //  Usually the element centres (should be of length size()).
137         virtual pointField coordinates() const
138         {
139             return pointField(1, centre_);
140         }
143         // Multiple point queries.
145             virtual void findNearest
146             (
147                 const pointField& sample,
148                 const scalarField& nearestDistSqr,
149                 List<pointIndexHit>&
150             ) const;
152             virtual void findLine
153             (
154                 const pointField& start,
155                 const pointField& end,
156                 List<pointIndexHit>&
157             ) const;
159             virtual void findLineAny
160             (
161                 const pointField& start,
162                 const pointField& end,
163                 List<pointIndexHit>&
164             ) const;
166             //- Get all intersections in order from start to end.
167             virtual void findLineAll
168             (
169                 const pointField& start,
170                 const pointField& end,
171                 List<List<pointIndexHit> >&
172             ) const;
174             //- From a set of points and indices get the region
175             virtual void getRegion
176             (
177                 const List<pointIndexHit>&,
178                 labelList& region
179             ) const;
181             //- From a set of points and indices get the normal
182             virtual void getNormal
183             (
184                 const List<pointIndexHit>&,
185                 vectorField& normal
186             ) const;
188             //- Determine type (inside/outside/mixed) for point. unknown if
189             //  cannot be determined (e.g. non-manifold surface)
190             virtual void getVolumeType
191             (
192                 const pointField&,
193                 List<volumeType>&
194             ) const;
197         // regIOobject implementation
199             bool writeData(Ostream&) const
200             {
201                 notImplemented("searchableSphere::writeData(Ostream&) const");
202                 return false;
203             }
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 } // End namespace Foam
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 #endif
216 // ************************************************************************* //