FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

triSurfaceSearch.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::triSurfaceSearch
00026 
00027 Description
00028     Helper class to search on triSurface.
00029 
00030 SourceFiles
00031     triSurfaceSearch.C
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef triSurfaceSearch_H
00036 #define triSurfaceSearch_H
00037 
00038 #include <OpenFOAM/pointField.H>
00039 #include <OpenFOAM/boolList.H>
00040 #include <meshTools/pointIndexHit.H>
00041 #include <meshTools/indexedOctree.H>
00042 #include <meshTools/treeDataTriSurface.H>
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 // Forward declaration of classes
00050 class triSurface;
00051 class treeDataTriSurface;
00052 template<class Type> class indexedOctree;
00053 
00054 /*---------------------------------------------------------------------------*\
00055                            Class triSurfaceSearch Declaration
00056 \*---------------------------------------------------------------------------*/
00057 
00058 class triSurfaceSearch
00059 {
00060     // Private data
00061 
00062         //- Reference to surface to work on
00063         const triSurface& surface_;
00064 
00065         //- Octree for searches
00066         autoPtr<indexedOctree<treeDataTriSurface> > treePtr_;
00067 
00068 
00069     // Private Member Functions
00070 
00071 
00072         //- Disallow default bitwise copy construct
00073         triSurfaceSearch(const triSurfaceSearch&);
00074 
00075         //- Disallow default bitwise assignment
00076         void operator=(const triSurfaceSearch&);
00077 
00078 public:
00079 
00080     // Static data members
00081 
00082         //- Point far away; used for illegal finds
00083         static const point greatPoint;
00084 
00085 
00086     // Constructors
00087 
00088         //- Construct from surface. Holds reference to surface!
00089         triSurfaceSearch(const triSurface&);
00090 
00091 
00092 
00093     // Member Functions
00094 
00095         const indexedOctree<treeDataTriSurface>& tree() const
00096         {
00097             return treePtr_();
00098         }
00099 
00100         const triSurface& surface() const
00101         {
00102             return surface_;
00103         }
00104 
00105         //- Calculate for each searchPoint inside/outside status.
00106         boolList calcInside(const pointField& searchPoints) const;
00107 
00108         //- Calculate index of nearest triangle (or -1) for each sample.
00109         //  Looks only in box of size 2*span around sample.
00110         labelList calcNearestTri
00111         (
00112             const pointField& samples,
00113             const vector& span
00114         ) const;
00115 
00116         //- Calculate nearest points (to searchPoints) on surface.
00117         //  Looks only in box of size 2*span around sample. Returns greatPoint
00118         //  if not found.
00119         tmp<pointField> calcNearest
00120         (
00121             const pointField& samples,
00122             const vector& span
00123         ) const;
00124 
00125         //- Calculate nearest point on surface for single searchPoint. Returns
00126         //  in pointIndexHit:
00127         //  - hit()      : whether nearest point found within bounding box
00128         //  - hitPoint() : coordinate of nearest point
00129         //  - index()    : surface triangle label
00130         pointIndexHit nearest(const point&, const vector& span) const;
00131 };
00132 
00133 
00134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00135 
00136 } // End namespace Foam
00137 
00138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00139 
00140 #endif
00141 
00142 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines