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

treeDataFace.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::treeDataFace
00026 
00027 Description
00028     Encapsulation of data needed to search for faces.
00029 
00030 SourceFiles
00031     treeDataFace.C
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef treeDataFace_H
00036 #define treeDataFace_H
00037 
00038 #include <OpenFOAM/face.H>
00039 #include "indexedOctree.H"
00040 #include <meshTools/treeBoundBoxList.H>
00041 #include <OpenFOAM/PackedBoolList.H>
00042 
00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00044 
00045 namespace Foam
00046 {
00047 
00048 // Forward declaration of classes
00049 class primitiveMesh;
00050 //template<class Type> class indexedOctree;
00051 class polyPatch;
00052 
00053 /*---------------------------------------------------------------------------*\
00054                            Class treeDataFace Declaration
00055 \*---------------------------------------------------------------------------*/
00056 
00057 class treeDataFace
00058 {
00059     // Static data
00060 
00061         //- tolerance on linear dimensions
00062         static scalar tolSqr;
00063 
00064 
00065 
00066     // Private data
00067 
00068         const primitiveMesh& mesh_;
00069 
00070         //- Subset of faces to work on
00071         const labelList faceLabels_;
00072 
00073         //- Inverse of faceLabels. For every mesh whether face is in faceLabels.
00074         PackedBoolList isTreeFace_;
00075 
00076         //- Whether to precalculate and store face bounding box
00077         const bool cacheBb_;
00078 
00079         //- face bounding boxes (valid only if cacheBb_)
00080         treeBoundBoxList bbs_;
00081 
00082 
00083     // Private Member Functions
00084 
00085         //- Calculate face bounding box
00086         treeBoundBox calcBb(const label cellI) const;
00087 
00088         //- Initialise all member data
00089         void update();
00090 
00091 public:
00092 
00093     // Declare name of the class and its debug switch
00094     ClassName("treeDataFace");
00095 
00096 
00097     // Constructors
00098 
00099         //- Construct from mesh and subset of faces.
00100         treeDataFace
00101         (
00102             const bool cacheBb,
00103             const primitiveMesh&,
00104             const labelList&
00105         );
00106 
00107         //- Construct from mesh. Uses all faces in mesh.
00108         treeDataFace(const bool cacheBb, const primitiveMesh&);
00109 
00110         //- Construct from mesh. Uses all faces in patch.
00111         treeDataFace(const bool cacheBb, const polyPatch&);
00112 
00113 
00114     // Member Functions
00115 
00116         // Access
00117 
00118             const labelList& faceLabels() const
00119             {
00120                 return faceLabels_;
00121             }
00122 
00123             const primitiveMesh& mesh() const
00124             {
00125                 return mesh_;
00126             }
00127 
00128             label size() const
00129             {
00130                 return faceLabels_.size();
00131             }
00132 
00133             //- Get representative point cloud for all shapes inside
00134             //  (one point per shape)
00135             pointField points() const;
00136 
00137 
00138         // Search
00139 
00140             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
00141             //  Only makes sense for closed surfaces.
00142             label getVolumeType
00143             (
00144                 const indexedOctree<treeDataFace>&,
00145                 const point&
00146             ) const;
00147 
00148             //- Does (bb of) shape at index overlap bb
00149             bool overlaps
00150             (
00151                 const label index,
00152                 const treeBoundBox& sampleBb
00153             ) const;
00154 
00155             //- Calculates nearest (to sample) point in shape.
00156             //  Returns actual point and distance (squared)
00157             void findNearest
00158             (
00159                 const labelList& indices,
00160                 const point& sample,
00161 
00162                 scalar& nearestDistSqr,
00163                 label& nearestIndex,
00164                 point& nearestPoint
00165             ) const;
00166 
00167             //- Calculates nearest (to line) point in shape.
00168             //  Returns point and distance (squared)
00169             void findNearest
00170             (
00171                 const labelList& indices,
00172                 const linePointRef& ln,
00173 
00174                 treeBoundBox& tightest,
00175                 label& minIndex,
00176                 point& linePoint,
00177                 point& nearestPoint
00178             ) const
00179             {
00180                 notImplemented
00181                 (
00182                     "treeDataFace::findNearest"
00183                     "(const labelList&, const linePointRef&, ..)"
00184                 );
00185             }
00186 
00187             //- Calculate intersection of shape with ray. Sets result
00188             //  accordingly
00189             bool intersects
00190             (
00191                 const label index,
00192                 const point& start,
00193                 const point& end,
00194                 point& result
00195             ) const;
00196 
00197 };
00198 
00199 
00200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00201 
00202 } // End namespace Foam
00203 
00204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00205 
00206 
00207 #endif
00208 
00209 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines