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

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