1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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
26 Foam::searchableSurface
29 Base class of (analytical or triangulated) surface.
30 Encapsulates all the search routines. WIP.
32 Information returned is usually a pointIndexHit:
33 - bool : was intersection/nearest found?
34 - point : intersection point or nearest point
35 - index : unique index on surface (e.g. triangle for triSurfaceMesh)
40 \*---------------------------------------------------------------------------*/
42 #ifndef searchableSurface_H
43 #define searchableSurface_H
45 #include "pointField.H"
47 #include "runTimeSelectionTables.H"
48 #include "pointIndexHit.H"
49 #include "linePointRef.H"
50 #include "objectRegistry.H"
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 // Forward declaration of classes
62 /*---------------------------------------------------------------------------*\
63 Class searchableSurface Declaration
64 \*---------------------------------------------------------------------------*/
66 class searchableSurface
78 MIXED = 1, // not used. only here to maintain consistency with
79 // indexedOctree volumeType.
91 // Private Member Functions
93 //- Disallow default bitwise copy construct
94 searchableSurface(const searchableSurface&);
96 //- Disallow default bitwise assignment
97 void operator=(const searchableSurface&);
102 //- Runtime type information
103 TypeName("searchableSurface");
105 // Declare run-time constructor selection table
107 // For the dictionary constructor
108 declareRunTimeSelectionTable
115 const dictionary& dict
121 //- Class used for the read-construction of
122 // PtrLists of searchableSurface.
134 autoPtr<searchableSurface> operator()(Istream& is) const
136 word surfaceType(is);
140 autoPtr<IOobject> namedIO(io_.clone());
141 namedIO().rename(readName);
142 return searchableSurface::New(surfaceType, namedIO(), dict);
149 searchableSurface(const IOobject& io);
152 virtual autoPtr<searchableSurface> clone() const
154 notImplemented("autoPtr<searchableSurface> clone() const");
155 return autoPtr<searchableSurface>(NULL);
161 //- Return a reference to the selected searchableSurface
162 static autoPtr<searchableSurface> New
164 const word& surfaceType,
166 const dictionary& dict
172 virtual ~searchableSurface();
178 //- Names of regions.
179 virtual const wordList& regions() const = 0;
181 //- Whether supports volume type below.
182 virtual bool hasVolumeType() const = 0;
184 //- Range of local indices that can be returned.
185 virtual label size() const = 0;
187 //- Range of global indices that can be returned.
188 virtual label globalSize() const
194 // Single point queries.
196 ////- Calculate nearest point on surface. Returns
197 //// - bool : any point found nearer than nearestDistSqr
198 //// - label: relevant index in surface
199 //// - label: region in surface
200 //// - point: actual nearest point found
201 //virtual pointIndexHit findNearest
203 // const point& sample,
204 // const scalar nearestDistSqr
207 ////- Calculate nearest point on edge. Returns
208 //// - bool : any point found nearer than nearestDistSqr
209 //// - label: relevant index in surface
210 //// - label: region in surface
211 //// - point: actual nearest point found
212 //virtual pointIndexHit findNearestOnEdge
214 // const point& sample,
215 // const scalar nearestDistSqr
218 ////- Find nearest to segment. Returns
219 //// - bool : any point found?
220 //// - label: relevant index in shapes
221 //// - label: region in surface
222 //// - point: actual nearest point found
224 //// - tightest : bounding box
225 //// - linePoint : corresponding nearest point on line
226 //virtual pointIndexHit findNearest
228 // const linePointRef& ln,
229 // treeBoundBox& tightest,
233 ////- Find nearest intersection of line between start and end.
234 //virtual pointIndexHit findLine
236 // const point& start,
240 ////- Find any intersection of line between start and end.
241 //virtual pointIndexHit findLineAny
243 // const point& start,
248 // Multiple point queries. When surface is distributed the index
249 // should be a global index. Not done yet.
251 virtual void findNearest
253 const pointField& sample,
254 const scalarField& nearestDistSqr,
258 //- Find first intersection on segment from start to end.
259 // Note: searchableSurfacesQueries expects no
260 // intersection to be found if start==end. Is problem?
261 virtual void findLine
263 const pointField& start,
264 const pointField& end,
268 //- Return any intersection on segment from start to end.
269 virtual void findLineAny
271 const pointField& start,
272 const pointField& end,
276 //- Get all intersections in order from start to end.
277 virtual void findLineAll
279 const pointField& start,
280 const pointField& end,
281 List<List<pointIndexHit> >&
284 //- From a set of points and indices get the region
285 virtual void getRegion
287 const List<pointIndexHit>&,
291 //- From a set of points and indices get the normal
292 virtual void getNormal
294 const List<pointIndexHit>&,
298 //- Determine type (inside/outside) for point. unknown if
299 // cannot be determined (e.g. non-manifold surface)
300 virtual void getVolumeType
309 //- Set bounds of surface. Bounds currently set as list of
310 // bounding boxes. The bounds are hints to the surface as for
311 // the range of queries it can expect. faceMap/pointMap can be
312 // set if the surface has done any redistribution.
313 virtual void distribute
315 const List<treeBoundBox>&,
316 const bool keepNonLocal,
317 autoPtr<mapDistribute>& faceMap,
318 autoPtr<mapDistribute>& pointMap
326 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
328 } // End namespace Foam
330 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
334 // ************************************************************************* //