initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / triSurface / triSurfaceSearch / triSurfaceSearch.H
blobfb43d831f4a60aedcf07cfef946bf87334021e80
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::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 "pointField.H"
40 #include "boolList.H"
41 #include "pointIndexHit.H"
42 #include "indexedOctree.H"
43 #include "treeDataTriSurface.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 // Forward declaration of classes
51 class triSurface;
52 class treeDataTriSurface;
53 template<class Type> class indexedOctree;
55 /*---------------------------------------------------------------------------*\
56                            Class triSurfaceSearch Declaration
57 \*---------------------------------------------------------------------------*/
59 class triSurfaceSearch
61     // Private data
63         //- Reference to surface to work on
64         const triSurface& surface_;
66         //- Octree for searches
67         autoPtr<indexedOctree<treeDataTriSurface> > treePtr_;
70     // Private Member Functions
73         //- Disallow default bitwise copy construct
74         triSurfaceSearch(const triSurfaceSearch&);
76         //- Disallow default bitwise assignment
77         void operator=(const triSurfaceSearch&);
79 public:
81     // Static data members
83         //- Point far away; used for illegal finds
84         static const point greatPoint;
87     // Constructors
89         //- Construct from surface. Holds reference to surface!
90         triSurfaceSearch(const triSurface&);
94     // Member Functions
96         const indexedOctree<treeDataTriSurface>& tree() const
97         {
98             return treePtr_();
99         }
101         const triSurface& surface() const
102         {
103             return surface_;
104         }
106         //- Calculate for each searchPoint inside/outside status.
107         boolList calcInside(const pointField& searchPoints) const;
109         //- Calculate index of nearest triangle (or -1) for each sample.
110         //  Looks only in box of size 2*span around sample.
111         labelList calcNearestTri
112         (
113             const pointField& samples,
114             const vector& span
115         ) const;
117         //- Calculate nearest points (to searchPoints) on surface.
118         //  Looks only in box of size 2*span around sample. Returns greatPoint
119         //  if not found.
120         tmp<pointField> calcNearest
121         (
122             const pointField& samples,
123             const vector& span
124         ) const;
126         //- Calculate nearest point on surface for single searchPoint. Returns
127         //  in pointIndexHit:
128         //  - hit()      : whether nearest point found within bounding box
129         //  - hitPoint() : coordinate of nearest point
130         //  - index()    : surface triangle label
131         pointIndexHit nearest(const point&, const vector& span) const;
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 } // End namespace Foam
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 #endif
143 // ************************************************************************* //