OpenFOAM logo
Open Source CFD Toolkit

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-2005 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     triSurfaceSearch
00027 
00028 Description
00029     Helper class to search on triSurface.
00030 
00031 SourceFiles
00032     triSurfaceSearch.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef triSurfaceSearch_H
00037 #define triSurfaceSearch_H
00038 
00039 #include "DynamicList.H"
00040 #include "pointField.H"
00041 #include "boolList.H"
00042 #include "pointIndexHit.H"
00043 #include "treeBoundBox.H"
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 // Class forward declarations
00051 class triSurface;
00052 class octreeDataTriSurface;
00053 template<class Type> class octree;
00054 
00055 /*---------------------------------------------------------------------------*\
00056                            Class triSurfaceSearch Declaration
00057 \*---------------------------------------------------------------------------*/
00058 
00059 class triSurfaceSearch
00060 {
00061     // Private data
00062 
00063         //- Reference to surface to work on
00064         const triSurface& surface_;
00065 
00066         //- Octree for searches
00067         const octree<octreeDataTriSurface>* treePtr_;
00068 
00069 
00070     // Private Member Functions
00071 
00072 
00073         //- Disallow default bitwise copy construct
00074         triSurfaceSearch(const triSurfaceSearch&);
00075 
00076         //- Disallow default bitwise assignment
00077         void operator=(const triSurfaceSearch&);
00078 
00079 public:
00080 
00081     // Static data members
00082 
00083         //- Point far away; used for illegal finds
00084         static const point greatPoint;
00085 
00086 
00087     // Constructors
00088 
00089         //- Construct from surface. Holds reference to surface!
00090         triSurfaceSearch(const triSurface&);
00091 
00092     // Destructor
00093 
00094         ~triSurfaceSearch();
00095 
00096 
00097     // Member Functions
00098 
00099         const octree<octreeDataTriSurface>& tree() const
00100         {
00101             return *treePtr_;
00102         }
00103 
00104         const triSurface& surface() const
00105         {
00106             return surface_;
00107         }
00108 
00109         //- Calculate for each searchPoint inside/outside status.
00110         boolList calcInside(const pointField& searchPoints) const;
00111 
00112         //- Calculate index of nearest triangle (or -1) for each sample.
00113         //  Looks only in box of size 2*span around sample.
00114         labelList calcNearestTri
00115         (
00116             const pointField& samples,
00117             const vector& span
00118         ) const;
00119 
00120         //- Calculate nearest points (to searchPoints) on surface.
00121         //  Looks only in box of size 2*span around sample. Returns greatPoint
00122         //  if not found.
00123         tmp<pointField> calcNearest
00124         (
00125             const pointField& samples,
00126             const vector& span
00127         ) const;
00128 
00129         //- Calculate nearest point on surface for single searchPoint. Returns
00130         //  in pointIndexHit:
00131         //  - hit()      : whether nearest point found within bounding box
00132         //  - hitPoint() : coordinate of nearest point
00133         //  - index()    : surface triangle label
00134         pointIndexHit nearest(const point&, const vector& span) const;
00135 };
00136 
00137 
00138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00139 
00140 } // End namespace Foam
00141 
00142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00143 
00144 #endif
00145 
00146 // ************************************************************************* //
For further information go to www.openfoam.org