Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / meshTools / triSurface / triSurfaceSearch / triSurfaceSearch.H
blobdfea9a5f3082b9e2db1aefef46c1a825e3b7d300
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::triSurfaceSearch
27 Description
28     Helper class to search on triSurface.
30 SourceFiles
31     triSurfaceSearch.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef triSurfaceSearch_H
36 #define triSurfaceSearch_H
38 #include "pointField.H"
39 #include "boolList.H"
40 #include "pointIndexHit.H"
41 #include "indexedOctree.H"
42 #include "treeDataTriSurface.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 // Forward declaration of classes
50 class triSurface;
51 class treeDataTriSurface;
52 template<class Type> class indexedOctree;
54 /*---------------------------------------------------------------------------*\
55                            Class triSurfaceSearch Declaration
56 \*---------------------------------------------------------------------------*/
58 class triSurfaceSearch
60     // Private data
62         //- Reference to surface to work on
63         const triSurface& surface_;
65         //- Octree for searches
66         autoPtr<indexedOctree<treeDataTriSurface> > treePtr_;
69     // Private Member Functions
72         //- Disallow default bitwise copy construct
73         triSurfaceSearch(const triSurfaceSearch&);
75         //- Disallow default bitwise assignment
76         void operator=(const triSurfaceSearch&);
78 public:
80     // Static data members
82         //- Point far away; used for illegal finds
83         static const point greatPoint;
86     // Constructors
88         //- Construct from surface. Holds reference to surface!
89         triSurfaceSearch(const triSurface&);
93     // Member Functions
95         const indexedOctree<treeDataTriSurface>& tree() const
96         {
97             return treePtr_();
98         }
100         const triSurface& surface() const
101         {
102             return surface_;
103         }
105         //- Calculate for each searchPoint inside/outside status.
106         boolList calcInside(const pointField& searchPoints) const;
108         //- Calculate index of nearest triangle (or -1) for each sample.
109         //  Looks only in box of size 2*span around sample.
110         labelList calcNearestTri
111         (
112             const pointField& samples,
113             const vector& span
114         ) const;
116         //- Calculate nearest points (to searchPoints) on surface.
117         //  Looks only in box of size 2*span around sample. Returns greatPoint
118         //  if not found.
119         tmp<pointField> calcNearest
120         (
121             const pointField& samples,
122             const vector& span
123         ) const;
125         //- Calculate nearest point on surface for single searchPoint. Returns
126         //  in pointIndexHit:
127         //  - hit()      : whether nearest point found within bounding box
128         //  - hitPoint() : coordinate of nearest point
129         //  - index()    : surface triangle label
130         pointIndexHit nearest(const point&, const vector& span) const;
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 } // End namespace Foam
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 #endif
142 // ************************************************************************* //