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

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