1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 "DynamicList.H"
40 #include "pointField.H"
42 #include "pointIndexHit.H"
43 #include "indexedOctree.H"
44 #include "treeDataTriSurface.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 // Forward declaration of classes
53 class treeDataTriSurface;
54 template<class Type> class indexedOctree;
56 /*---------------------------------------------------------------------------*\
57 Class triSurfaceSearch Declaration
58 \*---------------------------------------------------------------------------*/
60 class triSurfaceSearch
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&);
82 // Static data members
84 //- Point far away; used for illegal finds
85 static const point greatPoint;
90 //- Construct from surface. Holds reference to surface!
91 triSurfaceSearch(const triSurface&);
97 const indexedOctree<treeDataTriSurface>& tree() const
102 const triSurface& surface() const
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
114 const pointField& samples,
118 //- Calculate nearest points (to searchPoints) on surface.
119 // Looks only in box of size 2*span around sample. Returns greatPoint
121 tmp<pointField> calcNearest
123 const pointField& samples,
127 //- Calculate nearest point on surface for single searchPoint. Returns
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 // ************************************************************************* //