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

octreeDataPoint.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::octreeDataPoint
00027 
00028 Description
00029     Encapsulation of data needed for octree searches.
00030 
00031     Used for searching for nearest point. No bounding boxes around points.
00032     Only overlaps and calcNearest are implemented, rest makes little sense.
00033     Holds (reference to) pointField.
00034 
00035 SourceFiles
00036     octreeDataPoint.C
00037     octreeDataPointTreaLeaf.H   (template specialization of treeleaf)
00038     octreeDataPointTreeLeaf.C   (template specialization of treeleaf)
00039 
00040 \*---------------------------------------------------------------------------*/
00041 
00042 #ifndef octreeDataPoint_H
00043 #define octreeDataPoint_H
00044 
00045 #include "point.H"
00046 #include "pointField.H"
00047 #include "treeBoundBox.H"
00048 #include "linePointRef.H"
00049 
00050 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00051 
00052 namespace Foam
00053 {
00054 
00055 template<class Type> class octree;
00056 
00057 /*---------------------------------------------------------------------------*\
00058                            Class octreeDataPoint Declaration
00059 \*---------------------------------------------------------------------------*/
00060 
00061 class octreeDataPoint
00062 {
00063     // Private data
00064 
00065         const pointField& points_;
00066 
00067 public:
00068 
00069     // Constructors
00070 
00071         //- Construct from components. Holds reference to points!
00072         octreeDataPoint(const pointField&);
00073 
00074 
00075     // Member Functions
00076 
00077         // Access
00078 
00079             const pointField& points() const
00080             {
00081                 return points_;
00082             }
00083 
00084             label size() const
00085             {
00086                 return points_.size();
00087             }
00088 
00089         // Search
00090 
00091             //- Get type of sample
00092             label getSampleType
00093             (
00094                 const octree<octreeDataPoint>&,
00095                 const point&
00096             ) const;
00097 
00098             //- Does (bb of) shape at index overlap bb
00099             bool overlaps
00100             (
00101                 const label index,
00102                 const treeBoundBox& sampleBb
00103             ) const;
00104 
00105             //- Does shape at index contain sample
00106             bool contains
00107             (
00108                 const label index,
00109                 const point& sample
00110             ) const;
00111 
00112             //- Segment (from start to end) intersection with shape
00113             //  at index. If intersects returns true and sets intersectionPoint
00114             bool intersects
00115             (
00116                 const label index,
00117                 const point& start,
00118                 const point& end,
00119                 point& intersectionPoint
00120             ) const;
00121 
00122             //- Sets newTightest to bounding box (and returns true) if
00123             //  nearer to sample than tightest bounding box. Otherwise
00124             //  returns false.
00125             bool findTightest
00126             (
00127                 const label index,
00128                 const point& sample,
00129                 treeBoundBox& tightest
00130             ) const;
00131 
00132             //- Given index get unit normal and calculate (numerical) sign
00133             //  of sample.
00134             //  Used to determine accuracy of calcNearest or inside/outside.
00135             //  Note: always returns GREAT since no inside/outside.
00136             scalar calcSign
00137             (
00138                 const label index,
00139                 const point& sample,
00140                 vector& n
00141             ) const;
00142 
00143 
00144             //- Calculates nearest (to sample) point on/in shape.
00145             //  Returns point and mag(nearest - sample)
00146             scalar calcNearest
00147             (
00148                 const label index,
00149                 const point& sample,
00150                 point& nearest
00151             ) const;
00152 
00153             //- Calculates nearest (to line segment) point in shape.
00154             //  Returns distance and both point.
00155             scalar calcNearest
00156             (
00157                 const label index,
00158                 const linePointRef& ln,
00159                 point& linePt,          // nearest point on line
00160                 point& shapePt          // nearest point on shape
00161             ) const;
00162 
00163 
00164 
00165         // Write
00166 
00167             //- Write shape at index
00168             void write(Ostream& os, const label index) const;
00169 
00170 
00171     // IOstream Operators
00172 
00173         friend Ostream& operator<<(Ostream&, const octreeDataPoint&);
00174 };
00175 
00176 
00177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00178 
00179 } // End namespace Foam
00180 
00181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00182 
00183 #endif
00184 
00185 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd