1 /*---------------------------------------------------------------------------*\
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 -------------------------------------------------------------------------------
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/>.
25 Foam::searchableSurface
28 Base class of (analytical or triangulated) surface.
29 Encapsulates all the search routines. WIP.
31 Information returned is usually a pointIndexHit:
32 - bool : was intersection/nearest found?
33 - point : intersection point or nearest point
34 - index : unique index on surface (e.g. triangle for triSurfaceMesh)
39 \*---------------------------------------------------------------------------*/
41 #ifndef searchableSurface_H
42 #define searchableSurface_H
44 #include "pointField.H"
46 #include "runTimeSelectionTables.H"
47 #include "pointIndexHit.H"
48 #include "linePointRef.H"
49 #include "objectRegistry.H"
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 // Forward declaration of classes
61 /*---------------------------------------------------------------------------*\
62 Class searchableSurface Declaration
63 \*---------------------------------------------------------------------------*/
65 class searchableSurface
77 MIXED = 1, // not used. only here to maintain consistency with
78 // indexedOctree volumeType.
90 // Private Member Functions
92 //- Disallow default bitwise copy construct
93 searchableSurface(const searchableSurface&);
95 //- Disallow default bitwise assignment
96 void operator=(const searchableSurface&);
101 //- Runtime type information
102 TypeName("searchableSurface");
104 // Declare run-time constructor selection table
106 // For the dictionary constructor
107 declareRunTimeSelectionTable
114 const dictionary& dict
120 //- Class used for the read-construction of
121 // PtrLists of searchableSurface.
133 autoPtr<searchableSurface> operator()(Istream& is) const
135 word surfaceType(is);
139 autoPtr<IOobject> namedIO(io_.clone());
140 namedIO().rename(readName);
141 return searchableSurface::New(surfaceType, namedIO(), dict);
148 searchableSurface(const IOobject& io);
151 virtual autoPtr<searchableSurface> clone() const
153 notImplemented("autoPtr<searchableSurface> clone() const");
154 return autoPtr<searchableSurface>(NULL);
160 //- Return a reference to the selected searchableSurface
161 static autoPtr<searchableSurface> New
163 const word& surfaceType,
165 const dictionary& dict
171 virtual ~searchableSurface();
177 //- Names of regions.
178 virtual const wordList& regions() const = 0;
180 //- Whether supports volume type below.
181 virtual bool hasVolumeType() const = 0;
183 //- Range of local indices that can be returned.
184 virtual label size() const = 0;
186 //- Range of global indices that can be returned.
187 virtual label globalSize() const
192 //- Get representative set of element coordinates
193 // Usually the element centres (should be of length size()).
194 virtual pointField coordinates() const = 0;
197 // Single point queries.
199 ////- Calculate nearest point on surface. Returns
200 //// - bool : any point found nearer than nearestDistSqr
201 //// - label: relevant index in surface
202 //// - label: region in surface
203 //// - point: actual nearest point found
204 //virtual pointIndexHit findNearest
206 // const point& sample,
207 // const scalar nearestDistSqr
210 ////- Calculate nearest point on edge. Returns
211 //// - bool : any point found nearer than nearestDistSqr
212 //// - label: relevant index in surface
213 //// - label: region in surface
214 //// - point: actual nearest point found
215 //virtual pointIndexHit findNearestOnEdge
217 // const point& sample,
218 // const scalar nearestDistSqr
221 ////- Find nearest to segment. Returns
222 //// - bool : any point found?
223 //// - label: relevant index in shapes
224 //// - label: region in surface
225 //// - point: actual nearest point found
227 //// - tightest : bounding box
228 //// - linePoint : corresponding nearest point on line
229 //virtual pointIndexHit findNearest
231 // const linePointRef& ln,
232 // treeBoundBox& tightest,
236 ////- Find nearest intersection of line between start and end.
237 //virtual pointIndexHit findLine
239 // const point& start,
243 ////- Find any intersection of line between start and end.
244 //virtual pointIndexHit findLineAny
246 // const point& start,
251 // Multiple point queries. When surface is distributed the index
252 // should be a global index. Not done yet.
254 virtual void findNearest
256 const pointField& sample,
257 const scalarField& nearestDistSqr,
261 //- Find first intersection on segment from start to end.
262 // Note: searchableSurfacesQueries expects no
263 // intersection to be found if start==end. Is problem?
264 virtual void findLine
266 const pointField& start,
267 const pointField& end,
271 //- Return any intersection on segment from start to end.
272 virtual void findLineAny
274 const pointField& start,
275 const pointField& end,
279 //- Get all intersections in order from start to end.
280 virtual void findLineAll
282 const pointField& start,
283 const pointField& end,
284 List<List<pointIndexHit> >&
287 //- From a set of points and indices get the region
288 virtual void getRegion
290 const List<pointIndexHit>&,
294 //- From a set of points and indices get the normal
295 virtual void getNormal
297 const List<pointIndexHit>&,
301 //- Determine type (inside/outside) for point. unknown if
302 // cannot be determined (e.g. non-manifold surface)
303 virtual void getVolumeType
312 //- Set bounds of surface. Bounds currently set as list of
313 // bounding boxes. The bounds are hints to the surface as for
314 // the range of queries it can expect. faceMap/pointMap can be
315 // set if the surface has done any redistribution.
316 virtual void distribute
318 const List<treeBoundBox>&,
319 const bool keepNonLocal,
320 autoPtr<mapDistribute>& faceMap,
321 autoPtr<mapDistribute>& pointMap
325 //- WIP. Store element-wise field.
326 virtual void setField(const labelList& values)
329 //- WIP. From a set of hits (points and
330 // indices) get the specified field. Misses do not get set. Return
331 // empty field if not supported.
332 virtual void getField(const List<pointIndexHit>&, labelList& values)
341 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
343 } // End namespace Foam
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 // ************************************************************************* //