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

octreeDataPoint.C

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 \*---------------------------------------------------------------------------*/
00025 
00026 #include "octreeDataPoint.H"
00027 
00028 #include <OpenFOAM/labelList.H>
00029 #include "treeBoundBox.H"
00030 #include "octree.H"
00031 #include <OpenFOAM/linePointRef.H>
00032 #include <OpenFOAM/pointHit.H>
00033 
00034 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00035 
00036 // Construct from components
00037 Foam::octreeDataPoint::octreeDataPoint(const pointField& points)
00038 :
00039     points_(points)
00040 {}
00041 
00042 
00043 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00044 
00045 //- Get type of volume
00046 Foam::label Foam::octreeDataPoint::getSampleType
00047 (
00048     const octree<octreeDataPoint>&,
00049     const point&
00050 ) const
00051 {
00052     return octree<octreeDataPoint>::UNKNOWN;
00053 }
00054 
00055 
00056 bool Foam::octreeDataPoint::overlaps
00057 (
00058     const label index,
00059     const treeBoundBox& sampleBb
00060 ) const
00061 {
00062     return sampleBb.contains(points_[index]);
00063 }
00064 
00065 
00066 bool Foam::octreeDataPoint::contains
00067 (
00068     const label,
00069     const point&
00070 ) const
00071 {
00072     notImplemented
00073     (
00074         "octreeDataPoint::contains(const label, const point&)"
00075     );
00076 
00077     return false;
00078 }
00079 
00080 
00081 bool Foam::octreeDataPoint::intersects
00082 (
00083     const label,
00084     const point&,
00085     const point&,
00086     point&
00087 ) const
00088 {
00089     notImplemented
00090     (
00091         "octreeDataPoint::intersects(const label, const point&,"
00092         "const point&, point&)"
00093     );
00094 
00095     return false;
00096 }
00097 
00098 
00099 bool Foam::octreeDataPoint::findTightest
00100 (
00101     const label,
00102     const point&,
00103     treeBoundBox&
00104 ) const
00105 {
00106     notImplemented
00107     (
00108         "octreeDataPoint::findTightest(const label, const point&,"
00109         "treeBoundBox&)"
00110     );
00111 
00112     return false;
00113 }
00114 
00115 
00116 Foam::scalar Foam::octreeDataPoint::calcSign
00117 (
00118     const label,
00119     const point&,
00120     vector& n
00121 ) const
00122 {
00123     n = vector::zero;
00124 
00125     return 1;
00126 }
00127 
00128 
00129 // Calculate nearest point on/in shapei
00130 inline Foam::scalar Foam::octreeDataPoint::calcNearest
00131 (
00132     const label index,
00133     const point& sample,
00134     point& nearest
00135 ) const
00136 {
00137     nearest = points_[index];
00138     return magSqr(points_[index] - sample);
00139 }
00140 
00141 
00142 void Foam::octreeDataPoint::write
00143 (
00144     Ostream& os,
00145     const label index
00146 ) const
00147 {
00148     if ((index < 0) || (index > points().size()))
00149     {
00150         FatalErrorIn("octreeDataPoint::write(Ostream&, const label)")
00151             << "Index " << index << " outside 0.." << points().size()
00152             << abort(FatalError);
00153     }
00154     os << ' ' << points()[index];
00155 }
00156 
00157 
00158 // Calculate nearest point on/in shapei
00159 Foam::scalar Foam::octreeDataPoint::calcNearest
00160 (
00161     const label index,
00162     const linePointRef& ln,
00163     point& linePt,
00164     point& shapePt
00165 ) const
00166 {
00167     // Nearest point on shape
00168     shapePt = points_[index];
00169 
00170     // Nearest point on line
00171     pointHit pHit = ln.nearestDist(shapePt);
00172 
00173     linePt = pHit.rawPoint();
00174 
00175     return pHit.distance();
00176 }
00177 
00178 
00179 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00180 
00181 Foam::Ostream& Foam::operator<<
00182 (
00183     Foam::Ostream& os,
00184     const Foam::octreeDataPoint& ocPts
00185 )
00186 {
00187     return os << ocPts.points();
00188 }
00189 
00190 
00191 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines