initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / searchableSurface / searchableSurface.H
blob35b9dc9fb5a1ff9f3ba054492f7130ab2beee4a2
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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 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
19     for more details.
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
25 Class
26     Foam::searchableSurface
28 Description
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)
37 SourceFiles
38     searchableSurface.C
40 \*---------------------------------------------------------------------------*/
42 #ifndef searchableSurface_H
43 #define searchableSurface_H
45 #include "pointField.H"
46 #include "typeInfo.H"
47 #include "runTimeSelectionTables.H"
48 #include "pointIndexHit.H"
49 #include "linePointRef.H"
50 #include "objectRegistry.H"
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 namespace Foam
57 // Forward declaration of classes
58 class objectRegistry;
59 class mapDistribute;
60 class treeBoundBox;
62 /*---------------------------------------------------------------------------*\
63                            Class searchableSurface Declaration
64 \*---------------------------------------------------------------------------*/
66 class searchableSurface
68     public regIOobject
70 public:
72     // Data types
74         //- volume types
75         enum volumeType
76         {
77             UNKNOWN = 0,
78             MIXED = 1,      // not used. only here to maintain consistency with
79                             // indexedOctree volumeType.
80             INSIDE = 2,
81             OUTSIDE = 3
82         };
84 private:
86     // Private data
88         const word name_;
91     // Private Member Functions
93         //- Disallow default bitwise copy construct
94         searchableSurface(const searchableSurface&);
96         //- Disallow default bitwise assignment
97         void operator=(const searchableSurface&);
100 public:
102     //- Runtime type information
103     TypeName("searchableSurface");
105     // Declare run-time constructor selection table
107         // For the dictionary constructor
108         declareRunTimeSelectionTable
109         (
110             autoPtr,
111             searchableSurface,
112             dict,
113             (
114                 const IOobject& io,
115                 const dictionary& dict
116             ),
117             (io, dict)
118         );
121         //- Class used for the read-construction of
122         //  PtrLists of searchableSurface.
123         class iNew
124         {
125             IOobject& io_;
127         public:
129             iNew(IOobject& io)
130             :
131                 io_(io)
132             {}
134             autoPtr<searchableSurface> operator()(Istream& is) const
135             {
136                 word surfaceType(is);
137                 word readName(is);
138                 dictionary dict(is);
140                 autoPtr<IOobject> namedIO(io_.clone());
141                 namedIO().rename(readName);
142                 return searchableSurface::New(surfaceType, namedIO(), dict);
143             }
144         };
147     // Constructors
149         searchableSurface(const IOobject& io);
151         //- Clone
152         virtual autoPtr<searchableSurface> clone() const
153         {
154             notImplemented("autoPtr<searchableSurface> clone() const");
155             return autoPtr<searchableSurface>(NULL);
156         }
159     // Selectors
161         //- Return a reference to the selected searchableSurface
162         static autoPtr<searchableSurface> New
163         (
164             const word& surfaceType,
165             const IOobject& io,
166             const dictionary& dict
167         );
170     // Destructor
172         virtual ~searchableSurface();
175     // Member Functions
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
189         {
190             return size();
191         }
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
202             //(
203             //    const point& sample,
204             //    const scalar nearestDistSqr
205             //) const = 0;
206             //
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
213             //(
214             //    const point& sample,
215             //    const scalar nearestDistSqr
216             //) const = 0;
217             //
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
223             ////  sets:
224             ////  - tightest  : bounding box
225             ////  - linePoint : corresponding nearest point on line
226             //virtual pointIndexHit findNearest
227             //(
228             //    const linePointRef& ln,
229             //    treeBoundBox& tightest,
230             //    point& linePoint
231             //) const = 0;
232             //
233             ////- Find nearest intersection of line between start and end.
234             //virtual pointIndexHit findLine
235             //(
236             //    const point& start,
237             //    const point& end
238             //) const = 0;
239             //
240             ////- Find any intersection of line between start and end.
241             //virtual pointIndexHit findLineAny
242             //(
243             //    const point& start,
244             //    const point& end
245             //) const = 0;
248         // Multiple point queries. When surface is distributed the index
249         // should be a global index. Not done yet.
251             virtual void findNearest
252             (
253                 const pointField& sample,
254                 const scalarField& nearestDistSqr,
255                 List<pointIndexHit>&
256             ) const = 0;
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
262             (
263                 const pointField& start,
264                 const pointField& end,
265                 List<pointIndexHit>&
266             ) const = 0;
268             //- Return any intersection on segment from start to end.
269             virtual void findLineAny
270             (
271                 const pointField& start,
272                 const pointField& end,
273                 List<pointIndexHit>&
274             ) const = 0;
276             //- Get all intersections in order from start to end.
277             virtual void findLineAll
278             (
279                 const pointField& start,
280                 const pointField& end,
281                 List<List<pointIndexHit> >&
282             ) const = 0;
284             //- From a set of points and indices get the region
285             virtual void getRegion
286             (
287                 const List<pointIndexHit>&,
288                 labelList& region
289             ) const = 0;
291             //- From a set of points and indices get the normal
292             virtual void getNormal
293             (
294                 const List<pointIndexHit>&,
295                 vectorField& normal
296             ) const = 0;
298             //- Determine type (inside/outside) for point. unknown if
299             //  cannot be determined (e.g. non-manifold surface)
300             virtual void getVolumeType
301             (
302                 const pointField&,
303                 List<volumeType>&
304             ) const = 0;
307         // Other
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
314             (
315                 const List<treeBoundBox>&,
316                 const bool keepNonLocal,
317                 autoPtr<mapDistribute>& faceMap,
318                 autoPtr<mapDistribute>& pointMap
319             )
320             {}
326 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
328 } // End namespace Foam
330 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332 #endif
334 // ************************************************************************* //