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

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