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

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