1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
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
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/>.
25 Foam::triSurfaceSearch
28 Helper class to search on triSurface.
33 \*---------------------------------------------------------------------------*/
35 #ifndef triSurfaceSearch_H
36 #define triSurfaceSearch_H
38 #include "pointField.H"
40 #include "pointIndexHit.H"
41 #include "indexedOctree.H"
42 #include "treeDataTriSurface.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 // Forward declaration of classes
51 class treeDataTriSurface;
52 template<class Type> class indexedOctree;
54 /*---------------------------------------------------------------------------*\
55 Class triSurfaceSearch Declaration
56 \*---------------------------------------------------------------------------*/
58 class triSurfaceSearch
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&);
80 // Static data members
82 //- Point far away; used for illegal finds
83 static const point greatPoint;
88 //- Construct from surface. Holds reference to surface!
89 triSurfaceSearch(const triSurface&);
95 const indexedOctree<treeDataTriSurface>& tree() const
100 const triSurface& surface() const
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
112 const pointField& samples,
116 //- Calculate nearest points (to searchPoints) on surface.
117 // Looks only in box of size 2*span around sample. Returns greatPoint
119 tmp<pointField> calcNearest
121 const pointField& samples,
125 //- Calculate nearest point on surface for single searchPoint. Returns
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 // ************************************************************************* //