initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / meshTools / triSurface / triSurfaceSearch / triSurfaceSearch.H
blob5f4422c2d2b722f27cc7b4956ef8c69717f50aba
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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::triSurfaceSearch
28 Description
29     Helper class to search on triSurface.
31 SourceFiles
32     triSurfaceSearch.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef triSurfaceSearch_H
37 #define triSurfaceSearch_H
39 #include "DynamicList.H"
40 #include "pointField.H"
41 #include "boolList.H"
42 #include "pointIndexHit.H"
43 #include "indexedOctree.H"
44 #include "treeDataTriSurface.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 // Forward declaration of classes
52 class triSurface;
53 class treeDataTriSurface;
54 template<class Type> class indexedOctree;
56 /*---------------------------------------------------------------------------*\
57                            Class triSurfaceSearch Declaration
58 \*---------------------------------------------------------------------------*/
60 class triSurfaceSearch
62     // Private data
64         //- Reference to surface to work on
65         const triSurface& surface_;
67         //- Octree for searches
68         autoPtr<indexedOctree<treeDataTriSurface> > treePtr_;
71     // Private Member Functions
74         //- Disallow default bitwise copy construct
75         triSurfaceSearch(const triSurfaceSearch&);
77         //- Disallow default bitwise assignment
78         void operator=(const triSurfaceSearch&);
80 public:
82     // Static data members
84         //- Point far away; used for illegal finds
85         static const point greatPoint;
88     // Constructors
90         //- Construct from surface. Holds reference to surface!
91         triSurfaceSearch(const triSurface&);
95     // Member Functions
97         const indexedOctree<treeDataTriSurface>& tree() const
98         {
99             return treePtr_();
100         }
102         const triSurface& surface() const
103         {
104             return surface_;
105         }
107         //- Calculate for each searchPoint inside/outside status.
108         boolList calcInside(const pointField& searchPoints) const;
110         //- Calculate index of nearest triangle (or -1) for each sample.
111         //  Looks only in box of size 2*span around sample.
112         labelList calcNearestTri
113         (
114             const pointField& samples,
115             const vector& span
116         ) const;
118         //- Calculate nearest points (to searchPoints) on surface.
119         //  Looks only in box of size 2*span around sample. Returns greatPoint
120         //  if not found.
121         tmp<pointField> calcNearest
122         (
123             const pointField& samples,
124             const vector& span
125         ) const;
127         //- Calculate nearest point on surface for single searchPoint. Returns
128         //  in pointIndexHit:
129         //  - hit()      : whether nearest point found within bounding box
130         //  - hitPoint() : coordinate of nearest point
131         //  - index()    : surface triangle label
132         pointIndexHit nearest(const point&, const vector& span) const;
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 } // End namespace Foam
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 #endif
144 // ************************************************************************* //