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

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