OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

searchableBox.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-2009 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     Foam::searchableBox
00027 
00028 Description
00029     Searching on bounding box
00030 
00031 SourceFiles
00032     searchableBox.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef searchableBox_H
00037 #define searchableBox_H
00038 
00039 #include "searchableSurface.H"
00040 #include "treeBoundBox.H"
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 namespace Foam
00045 {
00046 
00047 // Forward declaration of classes
00048 
00049 /*---------------------------------------------------------------------------*\
00050                            Class searchableBox Declaration
00051 \*---------------------------------------------------------------------------*/
00052 
00053 class searchableBox
00054 :
00055     public searchableSurface,
00056     public treeBoundBox
00057 {
00058 private:
00059 
00060     // Private Member Data
00061 
00062         mutable wordList regions_;
00063 
00064 
00065     // Private Member Functions
00066 
00067         //- Project onto component dir of planePt and update index() (=face)
00068         void projectOntoCoordPlane
00069         (
00070             const direction dir,
00071             const point& planePt,
00072             pointIndexHit& info
00073         ) const;
00074 
00075         //- Returns miss or hit with face (0..5)
00076         pointIndexHit findNearest
00077         (
00078             const point& bbMid,
00079             const point& sample,
00080             const scalar nearestDistSqr
00081         ) const;
00082 
00083 
00084         //- Disallow default bitwise copy construct
00085         searchableBox(const searchableBox&);
00086 
00087         //- Disallow default bitwise assignment
00088         void operator=(const searchableBox&);
00089 
00090 
00091 public:
00092 
00093     //- Runtime type information
00094     TypeName("searchableBox");
00095 
00096 
00097     // Constructors
00098 
00099         //- Construct from components
00100         searchableBox(const IOobject& io, const treeBoundBox& bb);
00101 
00102         //- Construct from dictionary (used by searchableSurface)
00103         searchableBox
00104         (
00105             const IOobject& io,
00106             const dictionary& dict
00107         );
00108 
00109     // Destructor
00110 
00111         virtual ~searchableBox();
00112 
00113 
00114     // Member Functions
00115 
00116         virtual const wordList& regions() const;
00117 
00118         //- Whether supports volume type below
00119         virtual bool hasVolumeType() const
00120         {
00121             return true;
00122         }
00123 
00124         //- Range of local indices that can be returned.
00125         virtual label size() const
00126         {
00127             return 6;
00128         }
00129 
00130 
00131         // Single point queries.
00132 
00133             //- Calculate nearest point on surface. Returns
00134             //  - bool : any point found nearer than nearestDistSqr
00135             //  - label: relevant index in surface (=face 0..5)
00136             //  - point: actual nearest point found
00137             pointIndexHit findNearest
00138             (
00139                 const point& sample,
00140                 const scalar nearestDistSqr
00141             ) const;
00142 
00143             //- Calculate nearest point on edge. Returns
00144             //  - bool : any point found nearer than nearestDistSqr
00145             //  - label: relevant index in surface(=?)
00146             //  - point: actual nearest point found
00147             pointIndexHit findNearestOnEdge
00148             (
00149                 const point& sample,
00150                 const scalar nearestDistSqr
00151             ) const;
00152 
00153             //- Find nearest to segment. Returns
00154             //  - bool : any point found?
00155             //  - label: relevant index in shapes (=face 0..5)
00156             //  - point: actual nearest point found
00157             //  sets:
00158             //  - tightest  : bounding box
00159             //  - linePoint : corresponding nearest point on line
00160             pointIndexHit findNearest
00161             (
00162                 const linePointRef& ln,
00163                 treeBoundBox& tightest,
00164                 point& linePoint
00165             ) const;
00166 
00167             //- Find nearest intersection of line between start and end.
00168             pointIndexHit findLine
00169             (
00170                 const point& start,
00171                 const point& end
00172             ) const;
00173 
00174             //- Find any intersection of line between start and end.
00175             pointIndexHit findLineAny
00176             (
00177                 const point& start,
00178                 const point& end
00179             ) const;
00180 
00181 
00182         // Multiple point queries.
00183 
00184             virtual void findNearest
00185             (
00186                 const pointField& sample,
00187                 const scalarField& nearestDistSqr,
00188                 List<pointIndexHit>&
00189             ) const;
00190 
00191             virtual void findLine
00192             (
00193                 const pointField& start,
00194                 const pointField& end,
00195                 List<pointIndexHit>&
00196             ) const;
00197 
00198             virtual void findLineAny
00199             (
00200                 const pointField& start,
00201                 const pointField& end,
00202                 List<pointIndexHit>&
00203             ) const;
00204 
00205             //- Get all intersections in order from start to end.
00206             virtual void findLineAll
00207             (
00208                 const pointField& start,
00209                 const pointField& end,
00210                 List<List<pointIndexHit> >&
00211             ) const;
00212 
00213             //- From a set of points and indices get the region
00214             virtual void getRegion
00215             (
00216                 const List<pointIndexHit>&,
00217                 labelList& region
00218             ) const;
00219 
00220             //- From a set of points and indices get the normal
00221             virtual void getNormal
00222             (
00223                 const List<pointIndexHit>&,
00224                 vectorField& normal
00225             ) const;
00226 
00227             //- Determine type (inside/outside/mixed) for point. unknown if
00228             //  cannot be determined (e.g. non-manifold surface)
00229             virtual void getVolumeType
00230             (
00231                 const pointField&,
00232                 List<volumeType>&
00233             ) const;
00234 
00235 
00236         // regIOobject implementation
00237 
00238             bool writeData(Ostream&) const
00239             {
00240                 notImplemented("searchableBox::writeData(Ostream&) const");
00241                 return false;
00242             }
00243 
00244 };
00245 
00246 
00247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00248 
00249 } // End namespace Foam
00250 
00251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00252 
00253 #endif
00254 
00255 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd