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

octreeDataCell.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::octreeDataCell
00026 
00027 Description
00028     Encapsulation of data needed to search in/for cells.
00029 
00030     Used to find the cell containing a point (e.g. cell-cell mapping).
00031 
00032 SourceFiles
00033     octreeDataCell.C
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef octreeDataCell_H
00038 #define octreeDataCell_H
00039 
00040 #include "treeBoundBoxList.H"
00041 #include <OpenFOAM/labelList.H>
00042 #include <OpenFOAM/linePointRef.H>
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 // Forward declaration of classes
00050 class polyMesh;
00051 template<class Type> class octree;
00052 
00053 /*---------------------------------------------------------------------------*\
00054                        Class octreeDataCell Declaration
00055 \*---------------------------------------------------------------------------*/
00056 
00057 class octreeDataCell
00058 {
00059     // Private data
00060 
00061         const polyMesh& mesh_;
00062 
00063         labelList cellLabels_;
00064 
00065         treeBoundBoxList bbs_;
00066 
00067 
00068 public:
00069 
00070     // Constructors
00071 
00072         //- Construct from components.
00073         octreeDataCell
00074         (
00075             const polyMesh&,
00076             const labelList& cellLabels,
00077             const treeBoundBoxList& bbs
00078         );
00079 
00080         //- Construct from mesh. Uses all cells in mesh.
00081         octreeDataCell(const polyMesh&);
00082 
00083 
00084     // Member Functions
00085 
00086         // Access
00087 
00088             const labelList& cellLabels() const
00089             {
00090                 return cellLabels_;
00091             }
00092 
00093             const polyMesh& mesh() const
00094             {
00095                 return mesh_;
00096             }
00097 
00098             const treeBoundBoxList& allBb() const
00099             {
00100                 return bbs_;
00101             }
00102 
00103             label size() const
00104             {
00105                 return bbs_.size();
00106             }
00107 
00108         // Search
00109 
00110             //- Get type of sample
00111             label getSampleType(octree<octreeDataCell>&, const point&) const;
00112 
00113             //- Does (bb of) shape at index overlap bb
00114             bool overlaps
00115             (
00116                 const label index,
00117                 const treeBoundBox& sampleBb
00118             ) const;
00119 
00120             //- Does shape at index contain sample
00121             bool contains
00122             (
00123                 const label index,
00124                 const point& sample
00125             ) const;
00126 
00127             //- Segment (from start to end) intersection with shape
00128             //  at index. If intersects returns true and sets intersectionPoint
00129             // BUG: not yet done.
00130             bool intersects
00131             (
00132                 const label index,
00133                 const point& start,
00134                 const point& end,
00135                 point& intersectionPoint
00136             ) const;
00137 
00138             //- Sets newTightest to bounding box (and returns true) if
00139             //  nearer to sample than tightest bounding box. Otherwise
00140             //  returns false
00141             bool findTightest
00142             (
00143                 const label index,
00144                 const point& sample,
00145                 treeBoundBox& tightest
00146             ) const;
00147 
00148             //- Given index get unit normal and calculate (numerical) sign
00149             //  of sample.
00150             //  Used to determine accuracy of calcNearest or inside/outside.
00151             //  Note: always returns GREAT since no inside/outside.
00152             scalar calcSign
00153             (
00154                 const label index,
00155                 const point& sample,
00156                 vector& n
00157             ) const;
00158 
00159             //- Calculates nearest (to sample) point in shape.
00160             //  Returns point and mag(nearest - sample)
00161             scalar calcNearest
00162             (
00163                 const Foam::label index,
00164                 const Foam::point& sample,
00165                 point& nearest
00166             ) const;
00167 
00168             //- Calculates nearest (to line segment) point in shape.
00169             //  Returns distance and both point.
00170             scalar calcNearest
00171             (
00172                 const label index,
00173                 const linePointRef& ln,
00174                 point& linePt,          // nearest point on line
00175                 point& shapePt          // nearest point on shape
00176             ) const;
00177 
00178 
00179 
00180         // Write
00181 
00182             // Write shape at index
00183             void write(Ostream& os, const label index) const;
00184 };
00185 
00186 
00187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00188 
00189 } // End namespace Foam
00190 
00191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00192 
00193 
00194 #endif
00195 
00196 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines