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

octreeDataFace.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::octreeDataFace
00027 
00028 Description
00029     Holds data for octree to work on mesh faces.
00030 
00031     For example, calculate (in calcNearest) the correct intersection point
00032     with a face.
00033 
00034 SourceFiles
00035     octreeDataFace.C
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef octreeDataFace_H
00040 #define octreeDataFace_H
00041 
00042 #include "treeBoundBoxList.H"
00043 #include "faceList.H"
00044 #include "point.H"
00045 #include "className.H"
00046 #include "linePointRef.H"
00047 
00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00049 
00050 namespace Foam
00051 {
00052 
00053 // Forward declaration of classes
00054 class primitiveMesh;
00055 template<class Type> class octree;
00056 class polyPatch;
00057 
00058 /*---------------------------------------------------------------------------*\
00059                        Class octreeDataFace Declaration
00060 \*---------------------------------------------------------------------------*/
00061 
00062 class octreeDataFace
00063 {
00064     // Static data
00065 
00066         //- tolerance on linear dimensions
00067         static scalar tol;
00068 
00069 
00070     // Private data
00071 
00072         //- the mesh
00073         const primitiveMesh& mesh_;
00074 
00075         //- labels (in mesh indexing) of faces
00076         labelList meshFaces_;
00077 
00078         //- bbs for all above faces
00079         treeBoundBoxList allBb_;
00080 
00081 
00082     // Private Member Functions
00083 
00084         //- Set allBb to tight fitting bounding box
00085         void calcBb();
00086 
00087 public:
00088 
00089     // Declare name of the class and its debug switch
00090     ClassName("octreeDataFace");
00091 
00092     // Constructors
00093 
00094         //- Construct from selected mesh faces.
00095         octreeDataFace
00096         (
00097             const primitiveMesh&,
00098             const labelList& meshFaces,
00099             const treeBoundBoxList&
00100         );
00101 
00102         //- Construct from selected mesh faces. Tight fitting bounding boxes
00103         //  generated internally.
00104         octreeDataFace
00105         (
00106             const primitiveMesh&,
00107             const labelList& meshFaces
00108         );
00109 
00110         //- Construct from selected mesh faces.
00111         octreeDataFace
00112         (
00113             const primitiveMesh&,
00114             const UList<const labelList*>&,
00115             const UList<const treeBoundBoxList*>&
00116         );
00117 
00118         //- Construct from selected mesh faces.
00119         //  Tight-fitting bounding boxes generated internally.
00120         octreeDataFace(const primitiveMesh&, const UList<const labelList*>&);
00121 
00122         //- Construct from all faces in patch.
00123         //  Tight-fitting bounding boxes generated internally.
00124         octreeDataFace(const polyPatch&);
00125 
00126         //- Construct from all boundary faces.
00127         //  Tight-fitting bounding boxes generated internally.
00128         octreeDataFace(const primitiveMesh&);
00129 
00130         //- Construct as copy
00131         octreeDataFace(const octreeDataFace&);
00132 
00133 
00134     // Destructor
00135 
00136         ~octreeDataFace();
00137 
00138 
00139     // Member Functions
00140 
00141         // Access
00142 
00143             const primitiveMesh& mesh() const
00144             {
00145                 return mesh_;
00146             }
00147 
00148             const labelList& meshFaces() const
00149             {
00150                 return meshFaces_;
00151             }
00152 
00153             const treeBoundBoxList& allBb() const
00154             {
00155                 return allBb_;
00156             }
00157 
00158             label size() const
00159             {
00160                 return allBb_.size();
00161             }
00162 
00163 
00164         // Search
00165 
00166             //- Get type of sample
00167             label getSampleType
00168             (
00169                 const octree<octreeDataFace>&,
00170                 const point&
00171             ) const;
00172 
00173             //- Does (bb of) shape at index overlap bb
00174             bool overlaps
00175             (
00176                 const label index,
00177                 const treeBoundBox& sampleBb
00178             ) const;
00179 
00180             //- Does shape at index contain sample
00181             bool contains(const label index, const point& sample) const;
00182 
00183             //- Segment (from start to end) intersection with shape
00184             //  at index. If intersects returns true and sets intersectionPoint
00185             bool intersects
00186             (
00187                 const label index,
00188                 const point& start,
00189                 const point& end,
00190                 point& intersectionPoint
00191             ) const;
00192 
00193             //- Sets newTightest to bounding box (and returns true) if
00194             //  nearer to sample than tightest bounding box. Otherwise
00195             //  returns false.
00196             bool findTightest
00197             (
00198                 const label index,
00199                 const point& sample,
00200                 treeBoundBox& tightest
00201             ) const;
00202 
00203             //- Given index get unit normal and calculate (numerical) sign
00204             //  of sample.
00205             //  Used to determine accuracy of calcNearest or inside/outside.
00206             scalar calcSign
00207             (
00208                 const label index,
00209                 const point& sample,
00210                 vector& n
00211             ) const;
00212 
00213             //- Calculates nearest (to sample) point in shape.
00214             //  Returns point and mag(nearest - sample). Returns GREAT if
00215             //  sample does not project onto (triangle decomposition) of face.
00216             scalar calcNearest
00217             (
00218                 const label index,
00219                 const point& sample,
00220                 point& nearest
00221             ) const;
00222 
00223             //- Calculates nearest (to line segment) point in shape.
00224             //  Returns distance and both point.
00225             scalar calcNearest
00226             (
00227                 const label index,
00228                 const linePointRef& ln,
00229                 point& linePt,          // nearest point on line
00230                 point& shapePt          // nearest point on shape
00231             ) const;
00232 
00233 
00234         // Write
00235 
00236             //- Write shape at index
00237             void write(Ostream& os, const label index) const;
00238 };
00239 
00240 
00241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00242 
00243 } // End namespace Foam
00244 
00245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00246 
00247 
00248 #endif
00249 
00250 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd