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

octreeDataFaceList.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::octreeDataFaceList
00026 
00027 Description
00028     Holds data for octree to work on list of faces on a bMesh
00029     (= PrimitivePatch which holds faces, not references them)
00030     Same as octreeDataFace except for that.
00031 
00032 SourceFiles
00033     octreeDataFaceList.C
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef octreeDataFaceList_H
00038 #define octreeDataFaceList_H
00039 
00040 #include <meshTools/treeBoundBoxList.H>
00041 #include <OpenFOAM/faceList.H>
00042 #include <OpenFOAM/point.H>
00043 #include <OpenFOAM/className.H>
00044 #include "bMesh.H"
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 // Forward declaration of classes
00052 template<class Type> class octree;
00053 
00054 /*---------------------------------------------------------------------------*\
00055                            Class octreeDataFaceList Declaration
00056 \*---------------------------------------------------------------------------*/
00057 
00058 class octreeDataFaceList
00059 {
00060     // Static data
00061 
00062         //- tolerance on linear dimensions
00063         static scalar tol;
00064 
00065 
00066     // Static function
00067 
00068         static inline label nexti(label max, label i)
00069         {
00070             return (i + 1) % max;
00071         }            
00072 
00073 
00074     // Private data
00075 
00076         //- the mesh
00077         const bMesh& mesh_;
00078 
00079         //- labels (in mesh indexing) of faces
00080         labelList faceLabels_;
00081 
00082         //- bbs for all above faces
00083         treeBoundBoxList allBb_;
00084 
00085 
00086     // Private Member Functions
00087 
00088         //- Set allBb to tight fitting bounding box
00089         void calcBb();
00090 
00091 public:
00092 
00093     // Declare name of the class and its debug switch
00094     ClassName("octreeDataFaceList");
00095 
00096     // Constructors
00097 
00098         //- Construct from all faces in bMesh.
00099         octreeDataFaceList(const bMesh& mesh);
00100 
00101         //- Construct from selected faces in bMesh.
00102         octreeDataFaceList(const bMesh& mesh, const labelList& faceLabels);
00103 
00104         //- Construct as copy
00105         octreeDataFaceList(const octreeDataFaceList&);
00106 
00107 
00108     // Destructor
00109 
00110         ~octreeDataFaceList();
00111 
00112 
00113     // Member Functions
00114 
00115         // Access
00116 
00117             const bMesh& mesh() const
00118             {
00119                 return mesh_;
00120             }
00121 
00122             const labelList& faceLabels() const
00123             {
00124                 return faceLabels_;
00125             }
00126 
00127             const treeBoundBoxList& allBb() const
00128             {
00129                 return allBb_;
00130             }
00131 
00132             label size() const
00133             {
00134                 return allBb_.size();
00135             }
00136 
00137         // Search
00138 
00139             //- Get type of sample
00140             label getSampleType
00141             (
00142                 const octree<octreeDataFaceList>&,
00143                 const point&
00144             ) const;
00145 
00146             //- Does (bb of) shape at index overlap bb
00147             bool overlaps
00148             (
00149                 const label index,
00150                 const treeBoundBox& sampleBb
00151             ) const;
00152 
00153             //- Does shape at index contain sample
00154             bool contains
00155             (
00156                 const label index,
00157                 const point& sample
00158             ) const;
00159 
00160             //- Segment (from start to end) intersection with shape
00161             //  at index. If intersects returns true and sets intersectionPoint
00162             bool intersects
00163             (
00164                 const label index,
00165                 const point& start,
00166                 const point& end,
00167                 point& intersectionPoint
00168             ) const;
00169 
00170             //- Sets newTightest to bounding box (and returns true) if
00171             //  nearer to sample than tightest bounding box. Otherwise
00172             //  returns false.
00173             bool findTightest
00174             (
00175                 const label index,
00176                 const point& sample,
00177                 treeBoundBox& tightest
00178             ) const;
00179 
00180             //- Given index get unit normal and calculate (numerical) sign 
00181             //  of sample.
00182             //  Used to determine accuracy of calcNearest or inside/outside.
00183             scalar calcSign
00184             (
00185                 const label index,
00186                 const point& sample,
00187                 vector& n
00188             ) const;
00189 
00190             //- Calculates nearest (to sample) point in shape.
00191             //  Returns point and mag(nearest - sample). Returns GREAT if
00192             //  sample does not project onto (triangle decomposition) of face.
00193             scalar calcNearest
00194             (
00195                 const label index,
00196                 const point& sample,
00197                 point& nearest
00198             ) const;
00199 
00200 
00201         // Edit
00202 
00203         // Write
00204 
00205             //- Write shape at index
00206             void write(Ostream& os, const label index) const;
00207 };
00208 
00209 
00210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00211 
00212 } // End namespace Foam
00213 
00214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00215 
00216 
00217 #endif
00218 
00219 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines