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

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