1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 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
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
26 Foam::triSurfaceSearch
29 Helper class to search on triSurface.
34 \*---------------------------------------------------------------------------*/
36 #ifndef triSurfaceSearch_H
37 #define triSurfaceSearch_H
39 #include "pointField.H"
41 #include "pointIndexHit.H"
42 #include "indexedOctree.H"
43 #include "treeDataTriSurface.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 // Forward declaration of classes
52 class treeDataTriSurface;
53 template<class Type> class indexedOctree;
55 /*---------------------------------------------------------------------------*\
56 Class triSurfaceSearch Declaration
57 \*---------------------------------------------------------------------------*/
59 class triSurfaceSearch
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&);
81 // Static data members
83 //- Point far away; used for illegal finds
84 static const point greatPoint;
89 //- Construct from surface. Holds reference to surface!
90 triSurfaceSearch(const triSurface&);
96 const indexedOctree<treeDataTriSurface>& tree() const
101 const triSurface& surface() const
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
113 const pointField& samples,
117 //- Calculate nearest points (to searchPoints) on surface.
118 // Looks only in box of size 2*span around sample. Returns greatPoint
120 tmp<pointField> calcNearest
122 const pointField& samples,
126 //- Calculate nearest point on surface for single searchPoint. Returns
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 // ************************************************************************* //